btrfs: Allow barrier_all_devices to do chunk level device check
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Tue, 27 Jun 2017 09:28:40 +0000 (17:28 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 16 Aug 2017 14:12:02 +0000 (16:12 +0200)
The last user of num_tolerated_disk_barrier_failures is
barrier_all_devices().
But it can be easily changed to the new per-chunk degradable check
framework.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c

index 78fc7f5..552098e 100644 (file)
@@ -3519,20 +3519,10 @@ static blk_status_t wait_dev_flush(struct btrfs_device *device)
        return bio->bi_status;
 }
 
-static int check_barrier_error(struct btrfs_fs_devices *fsdevs)
+static int check_barrier_error(struct btrfs_fs_info *fs_info)
 {
-       int dev_flush_error = 0;
-       struct btrfs_device *dev;
-
-       list_for_each_entry_rcu(dev, &fsdevs->devices, dev_list) {
-               if (!dev->bdev || dev->last_flush_error)
-                       dev_flush_error++;
-       }
-
-       if (dev_flush_error >
-           fsdevs->fs_info->num_tolerated_disk_barrier_failures)
+       if (!btrfs_check_rw_degradable(fs_info))
                return -EIO;
-
        return 0;
 }
 
@@ -3587,7 +3577,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
                 * to arrive at the volume status. So error checking
                 * is being pushed to a separate loop.
                 */
-               return check_barrier_error(info->fs_devices);
+               return check_barrier_error(info);
        }
        return 0;
 }