diff options
Diffstat (limited to 'fs/xfs/xfs_trans_inode.c')
-rw-r--r-- | fs/xfs/xfs_trans_inode.c | 74 |
1 files changed, 26 insertions, 48 deletions
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index 2559dfec946..cdc53a1050c 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c | |||
@@ -24,20 +24,16 @@ | |||
24 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
27 | #include "xfs_dir2.h" | ||
28 | #include "xfs_dmapi.h" | ||
29 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
30 | #include "xfs_bmap_btree.h" | 28 | #include "xfs_bmap_btree.h" |
31 | #include "xfs_alloc_btree.h" | 29 | #include "xfs_alloc_btree.h" |
32 | #include "xfs_ialloc_btree.h" | 30 | #include "xfs_ialloc_btree.h" |
33 | #include "xfs_dir2_sf.h" | ||
34 | #include "xfs_attr_sf.h" | ||
35 | #include "xfs_dinode.h" | 31 | #include "xfs_dinode.h" |
36 | #include "xfs_inode.h" | 32 | #include "xfs_inode.h" |
37 | #include "xfs_btree.h" | 33 | #include "xfs_btree.h" |
38 | #include "xfs_ialloc.h" | ||
39 | #include "xfs_trans_priv.h" | 34 | #include "xfs_trans_priv.h" |
40 | #include "xfs_inode_item.h" | 35 | #include "xfs_inode_item.h" |
36 | #include "xfs_trace.h" | ||
41 | 37 | ||
42 | #ifdef XFS_TRANS_DEBUG | 38 | #ifdef XFS_TRANS_DEBUG |
43 | STATIC void | 39 | STATIC void |
@@ -47,7 +43,6 @@ xfs_trans_inode_broot_debug( | |||
47 | #define xfs_trans_inode_broot_debug(ip) | 43 | #define xfs_trans_inode_broot_debug(ip) |
48 | #endif | 44 | #endif |
49 | 45 | ||
50 | |||
51 | /* | 46 | /* |
52 | * Get an inode and join it to the transaction. | 47 | * Get an inode and join it to the transaction. |
53 | */ | 48 | */ |
@@ -63,77 +58,65 @@ xfs_trans_iget( | |||
63 | int error; | 58 | int error; |
64 | 59 | ||
65 | error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp); | 60 | error = xfs_iget(mp, tp, ino, flags, lock_flags, ipp); |
66 | if (!error && tp) | 61 | if (!error && tp) { |
67 | xfs_trans_ijoin(tp, *ipp, lock_flags); | 62 | xfs_trans_ijoin(tp, *ipp); |
63 | (*ipp)->i_itemp->ili_lock_flags = lock_flags; | ||
64 | } | ||
68 | return error; | 65 | return error; |
69 | } | 66 | } |
70 | 67 | ||
71 | /* | 68 | /* |
72 | * Add the locked inode to the transaction. | 69 | * Add a locked inode to the transaction. |
73 | * The inode must be locked, and it cannot be associated with any | 70 | * |
74 | * transaction. The caller must specify the locks already held | 71 | * The inode must be locked, and it cannot be associated with any transaction. |
75 | * on the inode. | ||
76 | */ | 72 | */ |
77 | void | 73 | void |
78 | xfs_trans_ijoin( | 74 | xfs_trans_ijoin( |
79 | xfs_trans_t *tp, | 75 | struct xfs_trans *tp, |
80 | xfs_inode_t *ip, | 76 | struct xfs_inode *ip) |
81 | uint lock_flags) | ||
82 | { | 77 | { |
83 | xfs_inode_log_item_t *iip; | 78 | xfs_inode_log_item_t *iip; |
84 | 79 | ||
85 | ASSERT(ip->i_transp == NULL); | 80 | ASSERT(ip->i_transp == NULL); |
86 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 81 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
87 | ASSERT(lock_flags & XFS_ILOCK_EXCL); | ||
88 | if (ip->i_itemp == NULL) | 82 | if (ip->i_itemp == NULL) |
89 | xfs_inode_item_init(ip, ip->i_mount); | 83 | xfs_inode_item_init(ip, ip->i_mount); |
90 | iip = ip->i_itemp; | 84 | iip = ip->i_itemp; |
91 | ASSERT(iip->ili_flags == 0); | 85 | ASSERT(iip->ili_lock_flags == 0); |
92 | 86 | ||
93 | /* | 87 | /* |
94 | * Get a log_item_desc to point at the new item. | 88 | * Get a log_item_desc to point at the new item. |
95 | */ | 89 | */ |
96 | (void) xfs_trans_add_item(tp, (xfs_log_item_t*)(iip)); | 90 | xfs_trans_add_item(tp, &iip->ili_item); |
97 | 91 | ||
98 | xfs_trans_inode_broot_debug(ip); | 92 | xfs_trans_inode_broot_debug(ip); |
99 | 93 | ||
100 | /* | 94 | /* |
101 | * If the IO lock is already held, mark that in the inode log item. | ||
102 | */ | ||
103 | if (lock_flags & XFS_IOLOCK_EXCL) { | ||
104 | iip->ili_flags |= XFS_ILI_IOLOCKED_EXCL; | ||
105 | } else if (lock_flags & XFS_IOLOCK_SHARED) { | ||
106 | iip->ili_flags |= XFS_ILI_IOLOCKED_SHARED; | ||
107 | } | ||
108 | |||
109 | /* | ||
110 | * Initialize i_transp so we can find it with xfs_inode_incore() | 95 | * Initialize i_transp so we can find it with xfs_inode_incore() |
111 | * in xfs_trans_iget() above. | 96 | * in xfs_trans_iget() above. |
112 | */ | 97 | */ |
113 | ip->i_transp = tp; | 98 | ip->i_transp = tp; |
114 | } | 99 | } |
115 | 100 | ||
116 | |||
117 | |||
118 | /* | 101 | /* |
119 | * Mark the inode as not needing to be unlocked when the inode item's | 102 | * Add a locked inode to the transaction. |
120 | * IOP_UNLOCK() routine is called. The inode must already be locked | 103 | * |
121 | * and associated with the given transaction. | 104 | * |
105 | * Grabs a reference to the inode which will be dropped when the transaction | ||
106 | * is commited. The inode will also be unlocked at that point. The inode | ||
107 | * must be locked, and it cannot be associated with any transaction. | ||
122 | */ | 108 | */ |
123 | /*ARGSUSED*/ | ||
124 | void | 109 | void |
125 | xfs_trans_ihold( | 110 | xfs_trans_ijoin_ref( |
126 | xfs_trans_t *tp, | 111 | struct xfs_trans *tp, |
127 | xfs_inode_t *ip) | 112 | struct xfs_inode *ip, |
113 | uint lock_flags) | ||
128 | { | 114 | { |
129 | ASSERT(ip->i_transp == tp); | 115 | xfs_trans_ijoin(tp, ip); |
130 | ASSERT(ip->i_itemp != NULL); | 116 | IHOLD(ip); |
131 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 117 | ip->i_itemp->ili_lock_flags = lock_flags; |
132 | |||
133 | ip->i_itemp->ili_flags |= XFS_ILI_HOLD; | ||
134 | } | 118 | } |
135 | 119 | ||
136 | |||
137 | /* | 120 | /* |
138 | * This is called to mark the fields indicated in fieldmask as needing | 121 | * This is called to mark the fields indicated in fieldmask as needing |
139 | * to be logged when the transaction is committed. The inode must | 122 | * to be logged when the transaction is committed. The inode must |
@@ -149,17 +132,12 @@ xfs_trans_log_inode( | |||
149 | xfs_inode_t *ip, | 132 | xfs_inode_t *ip, |
150 | uint flags) | 133 | uint flags) |
151 | { | 134 | { |
152 | xfs_log_item_desc_t *lidp; | ||
153 | |||
154 | ASSERT(ip->i_transp == tp); | 135 | ASSERT(ip->i_transp == tp); |
155 | ASSERT(ip->i_itemp != NULL); | 136 | ASSERT(ip->i_itemp != NULL); |
156 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 137 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
157 | 138 | ||
158 | lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)(ip->i_itemp)); | ||
159 | ASSERT(lidp != NULL); | ||
160 | |||
161 | tp->t_flags |= XFS_TRANS_DIRTY; | 139 | tp->t_flags |= XFS_TRANS_DIRTY; |
162 | lidp->lid_flags |= XFS_LID_DIRTY; | 140 | ip->i_itemp->ili_item.li_desc->lid_flags |= XFS_LID_DIRTY; |
163 | 141 | ||
164 | /* | 142 | /* |
165 | * Always OR in the bits from the ili_last_fields field. | 143 | * Always OR in the bits from the ili_last_fields field. |