Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95000
b: refs/heads/master
c: 1ac74e0
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Apr 29, 2008
1 parent 3e6d9f5 commit d5e6196
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 66 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cfa853e47df4fbee441ac0ac3fb592f076233145
refs/heads/master: 1ac74e01df959e3e91baded7c83399372af945a2
75 changes: 10 additions & 65 deletions trunk/fs/xfs/xfs_rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ xfs_rename(
int cancel_flags;
int committed;
xfs_inode_t *inodes[4];
int target_ip_dropped = 0; /* dropped target_ip link? */
int spaceres;
int target_link_zero = 0;
int num_inodes;

xfs_itrace_entry(src_dp);
Expand Down Expand Up @@ -174,10 +172,6 @@ xfs_rename(
xfs_sort_for_rename(src_dp, target_dp, src_ip, target_ip,
inodes, &num_inodes);

IHOLD(src_ip);
if (target_ip)
IHOLD(target_ip);

XFS_BMAP_INIT(&free_list, &first_block);
tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
Expand All @@ -191,15 +185,15 @@ xfs_rename(
}
if (error) {
xfs_trans_cancel(tp, 0);
goto rele_return;
goto std_return;
}

/*
* Attach the dquots to the inodes
*/
if ((error = XFS_QM_DQVOPRENAME(mp, inodes))) {
xfs_trans_cancel(tp, cancel_flags);
goto rele_return;
goto std_return;
}

/*
Expand All @@ -220,7 +214,7 @@ xfs_rename(
error = XFS_ERROR(EXDEV);
xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
xfs_trans_cancel(tp, cancel_flags);
goto rele_return;
goto std_return;
}

/*
Expand All @@ -233,17 +227,17 @@ xfs_rename(
*/
IHOLD(src_dp);
xfs_trans_ijoin(tp, src_dp, XFS_ILOCK_EXCL);

if (new_parent) {
IHOLD(target_dp);
xfs_trans_ijoin(tp, target_dp, XFS_ILOCK_EXCL);
}
if ((src_ip != src_dp) && (src_ip != target_dp)) {
xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL);
}
if ((target_ip != NULL) &&
(target_ip != src_ip) &&
(target_ip != src_dp) &&
(target_ip != target_dp)) {

IHOLD(src_ip);
xfs_trans_ijoin(tp, src_ip, XFS_ILOCK_EXCL);

if (target_ip) {
IHOLD(target_ip);
xfs_trans_ijoin(tp, target_ip, XFS_ILOCK_EXCL);
}

Expand Down Expand Up @@ -317,7 +311,6 @@ xfs_rename(
error = xfs_droplink(tp, target_ip);
if (error)
goto abort_return;
target_ip_dropped = 1;

if (src_is_directory) {
/*
Expand All @@ -327,10 +320,6 @@ xfs_rename(
if (error)
goto abort_return;
}

/* Do this test while we still hold the locks */
target_link_zero = (target_ip)->i_d.di_nlink==0;

} /* target_ip != NULL */

/*
Expand Down Expand Up @@ -396,15 +385,6 @@ xfs_rename(
xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
}

/*
* If there was a target inode, take an extra reference on
* it here so that it doesn't go to xfs_inactive() from
* within the commit.
*/
if (target_ip != NULL) {
IHOLD(target_ip);
}

/*
* If this is a synchronous mount, make sure that the
* rename transaction goes to disk before returning to
Expand All @@ -414,30 +394,11 @@ xfs_rename(
xfs_trans_set_sync(tp);
}

/*
* Take refs. for vop_link_removed calls below. No need to worry
* about directory refs. because the caller holds them.
*
* Do holds before the xfs_bmap_finish since it might rele them down
* to zero.
*/

if (target_ip_dropped)
IHOLD(target_ip);
IHOLD(src_ip);

error = xfs_bmap_finish(&tp, &free_list, &committed);
if (error) {
xfs_bmap_cancel(&free_list);
xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES |
XFS_TRANS_ABORT));
if (target_ip != NULL) {
IRELE(target_ip);
}
if (target_ip_dropped) {
IRELE(target_ip);
}
IRELE(src_ip);
goto std_return;
}

Expand All @@ -446,15 +407,6 @@ xfs_rename(
* the vnode references.
*/
error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
if (target_ip != NULL)
IRELE(target_ip);
/*
* Let interposed file systems know about removed links.
*/
if (target_ip_dropped)
IRELE(target_ip);

IRELE(src_ip);

/* Fall through to std_return with error = 0 or errno from
* xfs_trans_commit */
Expand All @@ -476,11 +428,4 @@ xfs_rename(
xfs_bmap_cancel(&free_list);
xfs_trans_cancel(tp, cancel_flags);
goto std_return;

rele_return:
IRELE(src_ip);
if (target_ip != NULL) {
IRELE(target_ip);
}
goto std_return;
}

0 comments on commit d5e6196

Please sign in to comment.