diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-06-23 21:36:58 -0400 |
---|---|---|
committer | Alex Elder <aelder@sgi.com> | 2010-07-26 14:16:36 -0400 |
commit | 898621d5a72c6799a9a13fce20443b4b6699899c (patch) | |
tree | 6cd994bd8d24f4f4f6ac5b5b57e0b99ee02d4ba6 /fs/xfs/xfs_rename.c | |
parent | 4d16e9246fc3b3cf7bc95609eff66929a39daa06 (diff) |
xfs: simplify inode to transaction joining
Currently we need to either call IHOLD or xfs_trans_ihold on an inode when
joining it to a transaction via xfs_trans_ijoin.
This patches instead makes xfs_trans_ijoin usable on it's own by doing
an implicity xfs_trans_ihold, which also allows us to drop the third
argument. For the case where we want to hold a reference on the inode
a xfs_trans_ijoin_ref wrapper is added which does the IHOLD and marks
the inode for needing an xfs_iput. In addition to the cleaner interface
to the caller this also simplifies the implementation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_rename.c')
-rw-r--r-- | fs/xfs/xfs_rename.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c index 8edb1074847a..778c87a8ebfc 100644 --- a/fs/xfs/xfs_rename.c +++ b/fs/xfs/xfs_rename.c | |||
@@ -169,26 +169,14 @@ xfs_rename( | |||
169 | /* | 169 | /* |
170 | * Join all the inodes to the transaction. From this point on, | 170 | * Join all the inodes to the transaction. From this point on, |
171 | * we can rely on either trans_commit or trans_cancel to unlock | 171 | * we can rely on either trans_commit or trans_cancel to unlock |
172 | * them. Note that we need to add a vnode reference to the | 172 | * them. |
173 | * directories since trans_commit & trans_cancel will decrement | ||
174 | * them when they unlock the inodes. Also, we need to be careful | ||
175 | * not to add an inode to the transaction more than once. | ||
176 | */ | 173 | */ |
177 | IHOLD(src_dp); | 174 | xfs_trans_ijoin_ref(tp, src_dp, XFS_ILOCK_EXCL); |
178 | xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL); | 175 | if (new_parent) |
179 | 176 | xfs_trans_ijoin_ref(tp, target_dp, XFS_ILOCK_EXCL); | |
180 | if (new_parent) { | 177 | xfs_trans_ijoin_ref(tp, src_ip, XFS_ILOCK_EXCL); |
181 | IHOLD(target_dp); | 178 | if (target_ip) |
182 | xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL); | 179 | xfs_trans_ijoin_ref(tp, target_ip, XFS_ILOCK_EXCL); |
183 | } | ||
184 | |||
185 | IHOLD(src_ip); | ||
186 | xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL); | ||
187 | |||
188 | if (target_ip) { | ||
189 | IHOLD(target_ip); | ||
190 | xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); | ||
191 | } | ||
192 | 180 | ||
193 | /* | 181 | /* |
194 | * If we are using project inheritance, we only allow renames | 182 | * If we are using project inheritance, we only allow renames |