]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
btrfs: add assertions where number of devices could go below 0
authorAnand Jain <anand.jain@oracle.com>
Fri, 10 Aug 2018 05:53:20 +0000 (13:53 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 15 Oct 2018 15:23:26 +0000 (17:23 +0200)
In preparation to add helper function to deduce the num_devices with
replace running, use assert instead of BUG_ON or WARN_ON. The number of
devices would not normally drop to 0 due to other checks so the assert
is sufficient.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog, adjust the assert condition ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index f4405e430da6e003306e1a4d471731e1a13c9230..3946fe951b60ce4bd85b96c86b08d1c5e7e57636 100644 (file)
@@ -1868,7 +1868,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
        num_devices = fs_devices->num_devices;
        btrfs_dev_replace_read_lock(&fs_info->dev_replace);
        if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) {
-               WARN_ON(num_devices < 1);
+               ASSERT(num_devices > 1);
                num_devices--;
        }
        btrfs_dev_replace_read_unlock(&fs_info->dev_replace);
@@ -3743,7 +3743,7 @@ int btrfs_balance(struct btrfs_fs_info *fs_info,
        num_devices = fs_info->fs_devices->num_devices;
        btrfs_dev_replace_read_lock(&fs_info->dev_replace);
        if (btrfs_dev_replace_is_ongoing(&fs_info->dev_replace)) {
-               BUG_ON(num_devices < 1);
+               ASSERT(num_devices > 1);
                num_devices--;
        }
        btrfs_dev_replace_read_unlock(&fs_info->dev_replace);