aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_rename.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_rename.c')
-rw-r--r--fs/xfs/xfs_rename.c61
1 files changed, 13 insertions, 48 deletions
diff --git a/fs/xfs/xfs_rename.c b/fs/xfs/xfs_rename.c
index c903130be7fd..86471bb40fd4 100644
--- a/fs/xfs/xfs_rename.c
+++ b/fs/xfs/xfs_rename.c
@@ -42,31 +42,6 @@
42 42
43 43
44/* 44/*
45 * Given an array of up to 4 inode pointers, unlock the pointed to inodes.
46 * If there are fewer than 4 entries in the array, the empty entries will
47 * be at the end and will have NULL pointers in them.
48 */
49STATIC void
50xfs_rename_unlock4(
51 xfs_inode_t **i_tab,
52 uint lock_mode)
53{
54 int i;
55
56 xfs_iunlock(i_tab[0], lock_mode);
57 for (i = 1; i < 4; i++) {
58 if (i_tab[i] == NULL)
59 break;
60
61 /*
62 * Watch out for duplicate entries in the table.
63 */
64 if (i_tab[i] != i_tab[i-1])
65 xfs_iunlock(i_tab[i], lock_mode);
66 }
67}
68
69/*
70 * Enter all inodes for a rename transaction into a sorted array. 45 * Enter all inodes for a rename transaction into a sorted array.
71 */ 46 */
72STATIC void 47STATIC void
@@ -205,19 +180,6 @@ xfs_rename(
205 xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); 180 xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL);
206 181
207 /* 182 /*
208 * If we are using project inheritance, we only allow renames
209 * into our tree when the project IDs are the same; else the
210 * tree quota mechanism would be circumvented.
211 */
212 if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
213 (target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
214 error = XFS_ERROR(EXDEV);
215 xfs_rename_unlock4(inodes, XFS_ILOCK_EXCL);
216 xfs_trans_cancel(tp, cancel_flags);
217 goto std_return;
218 }
219
220 /*
221 * Join all the inodes to the transaction. From this point on, 183 * Join all the inodes to the transaction. From this point on,
222 * we can rely on either trans_commit or trans_cancel to unlock 184 * we can rely on either trans_commit or trans_cancel to unlock
223 * them. Note that we need to add a vnode reference to the 185 * them. Note that we need to add a vnode reference to the
@@ -242,6 +204,17 @@ xfs_rename(
242 } 204 }
243 205
244 /* 206 /*
207 * If we are using project inheritance, we only allow renames
208 * into our tree when the project IDs are the same; else the
209 * tree quota mechanism would be circumvented.
210 */
211 if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
212 (target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
213 error = XFS_ERROR(EXDEV);
214 goto error_return;
215 }
216
217 /*
245 * Set up the target. 218 * Set up the target.
246 */ 219 */
247 if (target_ip == NULL) { 220 if (target_ip == NULL) {
@@ -367,19 +340,11 @@ xfs_rename(
367 &first_block, &free_list, spaceres); 340 &first_block, &free_list, spaceres);
368 if (error) 341 if (error)
369 goto abort_return; 342 goto abort_return;
370 xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
371 343
372 /* 344 xfs_ichgtime(src_dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
373 * Update the generation counts on all the directory inodes
374 * that we're modifying.
375 */
376 src_dp->i_gen++;
377 xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE); 345 xfs_trans_log_inode(tp, src_dp, XFS_ILOG_CORE);
378 346 if (new_parent)
379 if (new_parent) {
380 target_dp->i_gen++;
381 xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); 347 xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
382 }
383 348
384 /* 349 /*
385 * If this is a synchronous mount, make sure that the 350 * If this is a synchronous mount, make sure that the