btrfs: Move error handling of btrfs_start_dirty_block_groups closer to call site
authorNikolay Borisov <nborisov@suse.com>
Fri, 9 Feb 2018 09:30:18 +0000 (11:30 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 26 Mar 2018 13:09:36 +0000 (15:09 +0200)
Even though btrfs_start_dirty_block_groups is fairly in the beginning of
btrfs_commit_transaction outside of the critical section defined by the
transaction states it can only be run by a single comitter. In other
words it defines its own critical section thanks to the
BTRFS_TRANS_DIRTY_BG run flag and ro_block_group_mutex. However, its
error handling is outside of this critical section which is a bit
counter-intuitive. So move the error handling righ after the function is
executed and let the sole runner of dirty block groups handle the return
value. No functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/transaction.c

index ca2d91163af9755c51a49b88959250935b786946..665438542b96549cf28489bb422b9ec7432c3bbe 100644 (file)
@@ -2013,12 +2013,13 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
                        run_it = 1;
                mutex_unlock(&fs_info->ro_block_group_mutex);
 
-               if (run_it)
+               if (run_it) {
                        ret = btrfs_start_dirty_block_groups(trans);
-       }
-       if (ret) {
-               btrfs_end_transaction(trans);
-               return ret;
+                       if (ret) {
+                               btrfs_end_transaction(trans);
+                               return ret;
+                       }
+               }
        }
 
        spin_lock(&fs_info->trans_lock);