Commit 2f753f67 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

[XFS] some more rename cleanups

SGI Modid: 2.5.x-xfs:slinx:135919a3
parent 9ba118f5
...@@ -72,14 +72,13 @@ int xfs_rename_skip, xfs_rename_nskip; ...@@ -72,14 +72,13 @@ int xfs_rename_skip, xfs_rename_nskip;
* We are renaming dp1/name1 to dp2/name2. * We are renaming dp1/name1 to dp2/name2.
* *
* Return ENOENT if dp1 does not exist, other lookup errors, or 0 for success. * Return ENOENT if dp1 does not exist, other lookup errors, or 0 for success.
* Return EAGAIN if the caller needs to try again.
*/ */
STATIC int STATIC int
xfs_lock_for_rename( xfs_lock_for_rename(
xfs_inode_t *dp1, /* old (source) directory inode */ xfs_inode_t *dp1, /* old (source) directory inode */
xfs_inode_t *dp2, /* new (target) directory inode */ xfs_inode_t *dp2, /* new (target) directory inode */
vname_t *dentry1, /* old entry name */ vname_t *vname1,/* old entry name */
vname_t *dentry2, /* new entry name */ vname_t *vname2,/* new entry name */
xfs_inode_t **ipp1, /* inode of old entry */ xfs_inode_t **ipp1, /* inode of old entry */
xfs_inode_t **ipp2, /* inode of new entry, if it xfs_inode_t **ipp2, /* inode of new entry, if it
already exists, NULL otherwise. */ already exists, NULL otherwise. */
...@@ -102,7 +101,7 @@ xfs_lock_for_rename( ...@@ -102,7 +101,7 @@ xfs_lock_for_rename(
* to see if we still have the right inodes, directories, etc. * to see if we still have the right inodes, directories, etc.
*/ */
lock_mode = xfs_ilock_map_shared(dp1); lock_mode = xfs_ilock_map_shared(dp1);
error = xfs_get_dir_entry(dentry1, &ip1); error = xfs_get_dir_entry(vname1, &ip1);
if (error) { if (error) {
xfs_iunlock_map_shared(dp1, lock_mode); xfs_iunlock_map_shared(dp1, lock_mode);
return error; return error;
...@@ -123,7 +122,7 @@ xfs_lock_for_rename( ...@@ -123,7 +122,7 @@ xfs_lock_for_rename(
} }
error = xfs_dir_lookup_int(XFS_ITOBHV(dp2), lock_mode, error = xfs_dir_lookup_int(XFS_ITOBHV(dp2), lock_mode,
dentry2, &inum2, &ip2); vname2, &inum2, &ip2);
if (error == ENOENT) { /* target does not need to exist. */ if (error == ENOENT) { /* target does not need to exist. */
inum2 = 0; inum2 = 0;
} else if (error) { } else if (error) {
...@@ -213,20 +212,15 @@ xfs_lock_for_rename( ...@@ -213,20 +212,15 @@ xfs_lock_for_rename(
int rename_which_error_return = 0; int rename_which_error_return = 0;
#ifdef DEBUG
int xfs_rename_agains;
int xfs_renames;
#endif
/* /*
* xfs_rename * xfs_rename
*/ */
int int
xfs_rename( xfs_rename(
bhv_desc_t *src_dir_bdp, bhv_desc_t *src_dir_bdp,
vname_t *src_dentry, vname_t *src_vname,
vnode_t *target_dir_vp, vnode_t *target_dir_vp,
vname_t *target_dentry, vname_t *target_vname,
cred_t *credp) cred_t *credp)
{ {
xfs_trans_t *tp; xfs_trans_t *tp;
...@@ -246,15 +240,11 @@ xfs_rename( ...@@ -246,15 +240,11 @@ xfs_rename(
int spaceres; int spaceres;
int target_link_zero = 0; int target_link_zero = 0;
int num_inodes; int num_inodes;
char *src_name = VNAME(src_dentry); char *src_name = VNAME(src_vname);
char *target_name = VNAME(target_dentry); char *target_name = VNAME(target_vname);
int src_namelen; int src_namelen = VNAMELEN(src_vname);
int target_namelen; int target_namelen = VNAMELEN(target_vname);
#ifdef DEBUG
int retries;
xfs_renames++;
#endif
src_dir_vp = BHV_TO_VNODE(src_dir_bdp); src_dir_vp = BHV_TO_VNODE(src_dir_bdp);
vn_trace_entry(src_dir_vp, "xfs_rename", (inst_t *)__return_address); vn_trace_entry(src_dir_vp, "xfs_rename", (inst_t *)__return_address);
vn_trace_entry(target_dir_vp, "xfs_rename", (inst_t *)__return_address); vn_trace_entry(target_dir_vp, "xfs_rename", (inst_t *)__return_address);
...@@ -268,10 +258,10 @@ xfs_rename( ...@@ -268,10 +258,10 @@ xfs_rename(
if (target_dir_bdp == NULL) { if (target_dir_bdp == NULL) {
return XFS_ERROR(EXDEV); return XFS_ERROR(EXDEV);
} }
src_namelen = VNAMELEN(src_dentry);
target_namelen = VNAMELEN(target_dentry);
src_dp = XFS_BHVTOI(src_dir_bdp); src_dp = XFS_BHVTOI(src_dir_bdp);
target_dp = XFS_BHVTOI(target_dir_bdp); target_dp = XFS_BHVTOI(target_dir_bdp);
if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_RENAME) || if (DM_EVENT_ENABLED(src_dir_vp->v_vfsp, src_dp, DM_EVENT_RENAME) ||
DM_EVENT_ENABLED(target_dir_vp->v_vfsp, DM_EVENT_ENABLED(target_dir_vp->v_vfsp,
target_dp, DM_EVENT_RENAME)) { target_dp, DM_EVENT_RENAME)) {
...@@ -286,9 +276,6 @@ xfs_rename( ...@@ -286,9 +276,6 @@ xfs_rename(
} }
/* Return through std_return after this point. */ /* Return through std_return after this point. */
#ifdef DEBUG
retries = 0;
#endif
/* /*
* Lock all the participating inodes. Depending upon whether * Lock all the participating inodes. Depending upon whether
* the target_name exists in the target directory, and * the target_name exists in the target directory, and
...@@ -298,15 +285,9 @@ xfs_rename( ...@@ -298,15 +285,9 @@ xfs_rename(
* does not exist in the source directory. * does not exist in the source directory.
*/ */
tp = NULL; tp = NULL;
do { error = xfs_lock_for_rename(src_dp, target_dp, src_vname,
error = xfs_lock_for_rename(src_dp, target_dp, src_dentry, target_vname, &src_ip, &target_ip, inodes,
target_dentry, &src_ip, &target_ip, inodes,
&num_inodes); &num_inodes);
#ifdef DEBUG
if (error == EAGAIN)
xfs_rename_agains++;
#endif
} while (error == EAGAIN);
if (error) { if (error) {
rename_which_error_return = __LINE__; rename_which_error_return = __LINE__;
......
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