diff options
author | Dave Chinner <dchinner@redhat.com> | 2015-03-24 23:06:07 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-03-24 23:06:07 -0400 |
commit | 310606b0c7e385e9dd3533d168413ad2c579d961 (patch) | |
tree | 094077666f362daea3179cd75b5bbd9e5060ae7e /fs/xfs | |
parent | 445883e8133975fe8d555610c70c1c4c501f0bf8 (diff) |
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.c | 48 |
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( | |||
2650 | } | 2650 | } |
2651 | } | 2651 | } |
2652 | 2652 | ||
2653 | static int | ||
2654 | xfs_finish_rename( | ||
2655 | struct xfs_trans *tp, | ||
2656 | struct xfs_bmap_free *free_list) | ||
2657 | { | ||
2658 | int committed = 0; | ||
2659 | int error; | ||
2660 | |||
2661 | /* | ||
2662 | * If this is a synchronous mount, make sure that the rename transaction | ||
2663 | * goes to disk before returning to the user. | ||
2664 | */ | ||
2665 | if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) | ||
2666 | xfs_trans_set_sync(tp); | ||
2667 | |||
2668 | error = xfs_bmap_finish(&tp, free_list, &committed); | ||
2669 | if (error) { | ||
2670 | xfs_bmap_cancel(free_list); | ||
2671 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); | ||
2672 | return error; | ||
2673 | } | ||
2674 | |||
2675 | return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | ||
2676 | } | ||
2677 | |||
2653 | /* | 2678 | /* |
2654 | * xfs_cross_rename() | 2679 | * xfs_cross_rename() |
2655 | * | 2680 | * |
@@ -2789,7 +2814,6 @@ xfs_rename( | |||
2789 | xfs_bmap_free_t free_list; | 2814 | xfs_bmap_free_t free_list; |
2790 | xfs_fsblock_t first_block; | 2815 | xfs_fsblock_t first_block; |
2791 | int cancel_flags = 0; | 2816 | int cancel_flags = 0; |
2792 | int committed; | ||
2793 | xfs_inode_t *inodes[__XFS_SORT_INODES]; | 2817 | xfs_inode_t *inodes[__XFS_SORT_INODES]; |
2794 | int num_inodes = __XFS_SORT_INODES; | 2818 | int num_inodes = __XFS_SORT_INODES; |
2795 | int spaceres; | 2819 | int spaceres; |
@@ -2862,7 +2886,7 @@ xfs_rename( | |||
2862 | &free_list, &first_block, spaceres); | 2886 | &free_list, &first_block, spaceres); |
2863 | if (error) | 2887 | if (error) |
2864 | goto out_trans_abort; | 2888 | goto out_trans_abort; |
2865 | goto finish_rename; | 2889 | return xfs_finish_rename(tp, &free_list); |
2866 | } | 2890 | } |
2867 | 2891 | ||
2868 | /* | 2892 | /* |
@@ -3004,25 +3028,7 @@ xfs_rename( | |||
3004 | if (new_parent) | 3028 | if (new_parent) |
3005 | xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); | 3029 | xfs_trans_log_inode(tp, target_dp, XFS_ILOG_CORE); |
3006 | 3030 | ||
3007 | finish_rename: | 3031 | return xfs_finish_rename(tp, &free_list); |
3008 | /* | ||
3009 | * If this is a synchronous mount, make sure that the | ||
3010 | * rename transaction goes to disk before returning to | ||
3011 | * the user. | ||
3012 | */ | ||
3013 | if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) { | ||
3014 | xfs_trans_set_sync(tp); | ||
3015 | } | ||
3016 | |||
3017 | error = xfs_bmap_finish(&tp, &free_list, &committed); | ||
3018 | if (error) | ||
3019 | goto out_trans_abort; | ||
3020 | |||
3021 | /* | ||
3022 | * trans_commit will unlock src_ip, target_ip & decrement | ||
3023 | * the vnode references. | ||
3024 | */ | ||
3025 | return xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); | ||
3026 | 3032 | ||
3027 | out_trans_abort: | 3033 | out_trans_abort: |
3028 | cancel_flags |= XFS_TRANS_ABORT; | 3034 | cancel_flags |= XFS_TRANS_ABORT; |