Commit 2175dd95 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Lachlan McIlroy

[XFS] simplify projid check in xfs_rename

Check for the project ID after attaching all inodes to the transaction.
That way the unlock in the error case is done by the transaction subsystem,
which guaratees that is uses the right flags (which was wrong from day one
of this check), and avoids having special code unlocking an array of inodes
with potential duplicates.  Attaching the inode first is the method used
by xfs_rename and the other namespace methods all other error that require
multiple locked inodes.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
parent 15ac08a8
...@@ -41,31 +41,6 @@ ...@@ -41,31 +41,6 @@
#include "xfs_vnodeops.h" #include "xfs_vnodeops.h"
/*
* Given an array of up to 4 inode pointers, unlock the pointed to inodes.
* If there are fewer than 4 entries in the array, the empty entries will
* be at the end and will have NULL pointers in them.
*/
STATIC void
xfs_rename_unlock4(
xfs_inode_t **i_tab,
uint lock_mode)
{
int i;
xfs_iunlock(i_tab[0], lock_mode);
for (i = 1; i < 4; i++) {
if (i_tab[i] == NULL)
break;
/*
* Watch out for duplicate entries in the table.
*/
if (i_tab[i] != i_tab[i-1])
xfs_iunlock(i_tab[i], lock_mode);
}
}
/* /*
* Enter all inodes for a rename transaction into a sorted array. * Enter all inodes for a rename transaction into a sorted array.
*/ */
...@@ -204,19 +179,6 @@ xfs_rename( ...@@ -204,19 +179,6 @@ xfs_rename(
*/ */
xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL); xfs_lock_inodes(inodes, num_inodes, XFS_ILOCK_EXCL);
/*
* If we are using project inheritance, we only allow renames
* into our tree when the project IDs are the same; else the
* tree quota mechanism would be circumvented.
*/
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
error = XFS_ERROR(EXDEV);
xfs_rename_unlock4(inodes, XFS_ILOCK_EXCL);
xfs_trans_cancel(tp, cancel_flags);
goto std_return;
}
/* /*
* Join all the inodes to the transaction. From this point on, * Join all the inodes to the transaction. From this point on,
* we can rely on either trans_commit or trans_cancel to unlock * we can rely on either trans_commit or trans_cancel to unlock
...@@ -241,6 +203,17 @@ xfs_rename( ...@@ -241,6 +203,17 @@ xfs_rename(
xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL);
} }
/*
* If we are using project inheritance, we only allow renames
* into our tree when the project IDs are the same; else the
* tree quota mechanism would be circumvented.
*/
if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(target_dp->i_d.di_projid != src_ip->i_d.di_projid))) {
error = XFS_ERROR(EXDEV);
goto error_return;
}
/* /*
* Set up the target. * Set up the target.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment