summaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2015-03-25 04:06:07 +0100
committerDave Chinner <david@fromorbit.com>2015-03-25 04:06:07 +0100
commit310606b0c7e385e9dd3533d168413ad2c579d961 (patch)
tree094077666f362daea3179cd75b5bbd9e5060ae7e /fs/xfs
parentxfs: cleanup xfs_rename error handling (diff)
downloadlinux-310606b0c7e385e9dd3533d168413ad2c579d961.tar.xz
linux-310606b0c7e385e9dd3533d168413ad2c579d961.zip
xfs: factor out xfs_finish_rename()
Rather than use a jump label for the final transaction commit in the rename, factor it into a simple helper function and call it appropriately. This slightly reduces the spaghetti nature of xfs_rename. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_inode.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 426dbf7d094a..c3fe00cb19e4 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2650,6 +2650,31 @@ xfs_sort_for_rename(
}
}
+static int
+xfs_finish_rename(
+ struct xfs_trans *tp,
+ struct xfs_bmap_free *free_list)
+{
+ int committed = 0;
+ int error;
+
+ /*
+ * If this is a synchronous mount, make sure that the rename transaction
+ * goes to disk before returning to the user.
+ */
+ if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
+ xfs_trans_set_sync(tp);
+
+ 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);
+ return error;
+ }
+
+ return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
+}
+
/*
* xfs_cross_rename()
*
@@ -2789,7 +2814,6 @@ xfs_rename(
xfs_bmap_free_t free_list;
xfs_fsblock_t first_block;
int cancel_flags = 0;
- int committed;
xfs_inode_t *inodes[__XFS_SORT_INODES];
int num_inodes = __XFS_SORT_INODES;
int spaceres;
@@ -2862,7 +2886,7 @@ xfs_rename(
&free_list, &first_block, spaceres);
if (error)
goto out_trans_abort;
- goto finish_rename;
+ return xfs_finish_rename(tp, &free_list);
}
/*
@@ -3004,25 +3028,7 @@ xfs_rename(
if (new_parent)
xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE);
-finish_rename:
- /*
- * If this is a synchronous mount, make sure that the
- * rename transaction goes to disk before returning to
- * the user.
- */
- if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) {
- xfs_trans_set_sync(tp);
- }
-
- error = xfs_bmap_finish(&tp, &free_list, &committed);
- if (error)
- goto out_trans_abort;
-
- /*
- * trans_commit will unlock src_ip, target_ip & decrement
- * the vnode references.
- */
- return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
+ return xfs_finish_rename(tp, &free_list);
out_trans_abort:
cancel_flags |= XFS_TRANS_ABORT;