Merge tag 'sunxi-fixes-for-3.10' of git://github.com/mripard/linux into fixes
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / super.c
index c3254c995fc880c7d6dcbc06d1cbfb24dd4e2c09..f0857e092a3cb1af485604850052440579a1bbf1 100644 (file)
@@ -161,10 +161,9 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
        }
 
        /* Don't go through full error handling during mount */
-       if (sb->s_flags & MS_BORN) {
-               save_error_info(fs_info);
+       save_error_info(fs_info);
+       if (sb->s_flags & MS_BORN)
                btrfs_handle_error(fs_info);
-       }
 }
 
 static const char * const logtypes[] = {
@@ -867,7 +866,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
                return 0;
        }
 
-       btrfs_wait_ordered_extents(root, 0);
+       btrfs_wait_ordered_extents(root, 1);
 
        trans = btrfs_attach_transaction_barrier(root);
        if (IS_ERR(trans)) {
@@ -1192,11 +1191,14 @@ static void btrfs_resize_thread_pool(struct btrfs_fs_info *fs_info,
                              new_pool_size);
 }
 
-static inline void btrfs_remount_prepare(struct btrfs_fs_info *fs_info,
-                                        unsigned long old_opts, int flags)
+static inline void btrfs_remount_prepare(struct btrfs_fs_info *fs_info)
 {
        set_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
+}
 
+static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
+                                      unsigned long old_opts, int flags)
+{
        if (btrfs_raw_test_opt(old_opts, AUTO_DEFRAG) &&
            (!btrfs_raw_test_opt(fs_info->mount_opt, AUTO_DEFRAG) ||
             (flags & MS_RDONLY))) {
@@ -1237,7 +1239,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
        unsigned int old_metadata_ratio = fs_info->metadata_ratio;
        int ret;
 
-       btrfs_remount_prepare(fs_info, old_opts, *flags);
+       btrfs_remount_prepare(fs_info);
 
        ret = btrfs_parse_options(root, data);
        if (ret) {
@@ -1245,6 +1247,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
                goto restore;
        }
 
+       btrfs_remount_begin(fs_info, old_opts, *flags);
        btrfs_resize_thread_pool(fs_info,
                fs_info->thread_pool_size, old_thread_pool_size);
 
@@ -1260,6 +1263,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 
                btrfs_dev_replace_suspend_for_unmount(fs_info);
                btrfs_scrub_cancel(fs_info);
+               btrfs_pause_balance(fs_info);
 
                ret = btrfs_commit_super(root);
                if (ret)