btrfs: change wait_dev_flush() return type to bool
authorAnand Jain <anand.jain@oracle.com>
Mon, 27 Mar 2023 09:53:09 +0000 (17:53 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 17 Apr 2023 16:01:20 +0000 (18:01 +0200)
The flush error code is maintained in btrfs_device::last_flush_error, so
there is no point in returning it in wait_dev_flush() when it is not being
used. Instead, we can return a boolean value.

Note that even though btrfs_device::last_flush_error may not be used, we
will keep it for now.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c

index bd0e2c595fd66e55090ef9dd69af6a033a8af992..fb4f88faeacec3a69ec32c90eb94f0a623af980b 100644 (file)
@@ -4116,13 +4116,14 @@ static void write_dev_flush(struct btrfs_device *device)
 
 /*
  * If the flush bio has been submitted by write_dev_flush, wait for it.
+ * Return true for any error, and false otherwise.
  */
-static blk_status_t wait_dev_flush(struct btrfs_device *device)
+static bool wait_dev_flush(struct btrfs_device *device)
 {
        struct bio *bio = &device->flush_bio;
 
        if (!test_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state))
-               return BLK_STS_OK;
+               return false;
 
        clear_bit(BTRFS_DEV_STATE_FLUSH_SENT, &device->dev_state);
        wait_for_completion_io(&device->flush_wait);
@@ -4130,9 +4131,10 @@ static blk_status_t wait_dev_flush(struct btrfs_device *device)
        if (bio->bi_status) {
                device->last_flush_error = bio->bi_status;
                btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_FLUSH_ERRS);
+               return true;
        }
 
-       return bio->bi_status;
+       return false;
 }
 
 /*
@@ -4144,7 +4146,6 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
        struct list_head *head;
        struct btrfs_device *dev;
        int errors_wait = 0;
-       blk_status_t ret;
 
        lockdep_assert_held(&info->fs_devices->device_list_mutex);
        /* send down all the barriers */
@@ -4173,8 +4174,7 @@ static int barrier_all_devices(struct btrfs_fs_info *info)
                    !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))
                        continue;
 
-               ret = wait_dev_flush(dev);
-               if (ret)
+               if (wait_dev_flush(dev))
                        errors_wait++;
        }