Commit 14506127 authored by Adam Borowski's avatar Adam Borowski Committed by David Sterba

btrfs: fix a bogus warning when converting only data or metadata

If your filesystem has, eg, data:raid0 metadata:raid1, and you run "btrfs
balance -dconvert=raid1", the meta.target field will be uninitialized.
That's otherwise ok, as it's unused except for this warning.

Thus, let's use the existing set of raid levels for the comparison.

As a side effect, non-convert balances will now nag about data>metadata.
Signed-off-by: default avatarAdam Borowski <kilobyte@angband.pl>
Reviewed-by: default avatarLiu Bo <bo.li.liu@oracle.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent aeea4c10
...@@ -3755,6 +3755,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl, ...@@ -3755,6 +3755,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
struct btrfs_ioctl_balance_args *bargs) struct btrfs_ioctl_balance_args *bargs)
{ {
struct btrfs_fs_info *fs_info = bctl->fs_info; struct btrfs_fs_info *fs_info = bctl->fs_info;
u64 meta_target, data_target;
u64 allowed; u64 allowed;
int mixed = 0; int mixed = 0;
int ret; int ret;
...@@ -3851,11 +3852,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl, ...@@ -3851,11 +3852,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
} }
} while (read_seqretry(&fs_info->profiles_lock, seq)); } while (read_seqretry(&fs_info->profiles_lock, seq));
if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) < /* if we're not converting, the target field is uninitialized */
btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) { meta_target = (bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT) ?
bctl->meta.target : fs_info->avail_metadata_alloc_bits;
data_target = (bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT) ?
bctl->data.target : fs_info->avail_data_alloc_bits;
if (btrfs_get_num_tolerated_disk_barrier_failures(meta_target) <
btrfs_get_num_tolerated_disk_barrier_failures(data_target)) {
btrfs_warn(fs_info, btrfs_warn(fs_info,
"metadata profile 0x%llx has lower redundancy than data profile 0x%llx", "metadata profile 0x%llx has lower redundancy than data profile 0x%llx",
bctl->meta.target, bctl->data.target); meta_target, data_target);
} }
if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment