* [PATCH] btrfs: fix a bogus warning when converting only data or metadata
@ 2017-03-07 5:42 Adam Borowski
2017-03-07 20:34 ` Liu Bo
0 siblings, 1 reply; 6+ messages in thread
From: Adam Borowski @ 2017-03-07 5:42 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs; +Cc: Adam Borowski
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: Adam Borowski <kilobyte@angband.pl>
---
To reproduce:
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb
mkfs.btrfs ra rb # defaults to -draid0 -mraid1
losetup -f ra
losetup -f rb
mount /dev/loop0 /mnt/vol1
btrfs balance start -dconvert=raid1 /mnt/vol1
fs/btrfs/volumes.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3645af2749f8..c016db81ba43 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3846,6 +3846,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
}
} while (read_seqretry(&fs_info->profiles_lock, seq));
+ /* if we're not converting, the target field is uninitialized */
+ if (!(bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT))
+ bctl->meta.target = fs_info->avail_metadata_alloc_bits;
+ if (!(bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT))
+ bctl->data.target = fs_info->avail_data_alloc_bits;
if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
btrfs_warn(fs_info,
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] btrfs: fix a bogus warning when converting only data or metadata
2017-03-07 5:42 [PATCH] btrfs: fix a bogus warning when converting only data or metadata Adam Borowski
@ 2017-03-07 20:34 ` Liu Bo
2017-03-07 22:34 ` [PATCH v2] " Adam Borowski
0 siblings, 1 reply; 6+ messages in thread
From: Liu Bo @ 2017-03-07 20:34 UTC (permalink / raw)
To: Adam Borowski; +Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs
On Tue, Mar 07, 2017 at 06:42:51AM +0100, Adam Borowski wrote:
> 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: Adam Borowski <kilobyte@angband.pl>
> ---
> To reproduce:
> dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra
> dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb
> mkfs.btrfs ra rb # defaults to -draid0 -mraid1
> losetup -f ra
> losetup -f rb
> mount /dev/loop0 /mnt/vol1
> btrfs balance start -dconvert=raid1 /mnt/vol1
>
> fs/btrfs/volumes.c | 5 +++++
> 1 file changed, 5 insertions(+)
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 3645af2749f8..c016db81ba43 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -3846,6 +3846,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
> }
> } while (read_seqretry(&fs_info->profiles_lock, seq));
>
> + /* if we're not converting, the target field is uninitialized */
> + if (!(bctl->meta.flags & BTRFS_BALANCE_ARGS_CONVERT))
> + bctl->meta.target = fs_info->avail_metadata_alloc_bits;
> + if (!(bctl->data.flags & BTRFS_BALANCE_ARGS_CONVERT))
> + bctl->data.target = fs_info->avail_data_alloc_bits;
This looks good, but this also brings another side effect, @bctl would
also be kept in balance_item which will be used to resume balance in
case of crash, so it may see a different bctl->meta.target.
So would you please use local varibles for meta.target and data.target?
Thanks,
-liubo
> if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
> btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
> btrfs_warn(fs_info,
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] btrfs: fix a bogus warning when converting only data or metadata
2017-03-07 20:34 ` Liu Bo
@ 2017-03-07 22:34 ` Adam Borowski
2017-03-08 1:27 ` Liu Bo
2017-03-09 13:43 ` David Sterba
0 siblings, 2 replies; 6+ messages in thread
From: Adam Borowski @ 2017-03-07 22:34 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, Liu Bo; +Cc: Adam Borowski
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: Adam Borowski <kilobyte@angband.pl>
---
To reproduce:
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb
mkfs.btrfs ra rb # defaults to -draid0 -mraid1
losetup -f ra
losetup -f rb
mount /dev/loop0 /mnt/vol1
btrfs balance start -dconvert=raid1 /mnt/vol1
On Tue, Mar 07, 2017 at 12:34:07PM -0800, Liu Bo wrote:
> This looks good, but this also brings another side effect, @bctl would
> also be kept in balance_item which will be used to resume balance in
> case of crash, so it may see a different bctl->meta.target.
>
> So would you please use local varibles for meta.target and data.target?
Okay.
I'm not sure why storing a bogus value that came from userspace and was
uninitialized there (0 in normal use) would be better, but here we go:
v2 doesn't overwrite what we got anymore.
Unrelated: I wonder if the profiles in the warning message shouldn't be
printk'ed as words (akin to ebce0e01), but we don't have a function to do
that, have we?
Meow!
fs/btrfs/volumes.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3645af2749f8..987f395ddec5 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3750,6 +3750,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
struct btrfs_ioctl_balance_args *bargs)
{
struct btrfs_fs_info *fs_info = bctl->fs_info;
+ __u64 meta_target, data_target;
u64 allowed;
int mixed = 0;
int ret;
@@ -3846,11 +3847,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
}
} while (read_seqretry(&fs_info->profiles_lock, seq));
- if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
- btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
+ /* if we're not converting, the target field is uninitialized */
+ 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,
"metadata profile 0x%llx has lower redundancy than data profile 0x%llx",
- bctl->meta.target, bctl->data.target);
+ meta_target, data_target);
}
ret = insert_balance_item(fs_info, bctl);
--
2.11.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] btrfs: fix a bogus warning when converting only data or metadata
2017-03-07 22:34 ` [PATCH v2] " Adam Borowski
@ 2017-03-08 1:27 ` Liu Bo
2017-03-09 13:43 ` David Sterba
1 sibling, 0 replies; 6+ messages in thread
From: Liu Bo @ 2017-03-08 1:27 UTC (permalink / raw)
To: Adam Borowski; +Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs
On Tue, Mar 07, 2017 at 11:34:44PM +0100, Adam Borowski wrote:
> 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: Adam Borowski <kilobyte@angband.pl>
> ---
> To reproduce:
> dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra
> dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb
> mkfs.btrfs ra rb # defaults to -draid0 -mraid1
> losetup -f ra
> losetup -f rb
> mount /dev/loop0 /mnt/vol1
> btrfs balance start -dconvert=raid1 /mnt/vol1
>
>
> On Tue, Mar 07, 2017 at 12:34:07PM -0800, Liu Bo wrote:
> > This looks good, but this also brings another side effect, @bctl would
> > also be kept in balance_item which will be used to resume balance in
> > case of crash, so it may see a different bctl->meta.target.
> >
> > So would you please use local varibles for meta.target and data.target?
>
> Okay.
>
> I'm not sure why storing a bogus value that came from userspace and was
> uninitialized there (0 in normal use) would be better, but here we go:
> v2 doesn't overwrite what we got anymore.
>
> Unrelated: I wonder if the profiles in the warning message shouldn't be
> printk'ed as words (akin to ebce0e01), but we don't have a function to do
> that, have we?
>
We don't have it in kernel, but in progs I believe.
For this patch,
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Thanks,
-liubo
>
> Meow!
>
> fs/btrfs/volumes.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 3645af2749f8..987f395ddec5 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -3750,6 +3750,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
> struct btrfs_ioctl_balance_args *bargs)
> {
> struct btrfs_fs_info *fs_info = bctl->fs_info;
> + __u64 meta_target, data_target;
> u64 allowed;
> int mixed = 0;
> int ret;
> @@ -3846,11 +3847,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
> }
> } while (read_seqretry(&fs_info->profiles_lock, seq));
>
> - if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
> - btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
> + /* if we're not converting, the target field is uninitialized */
> + 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,
> "metadata profile 0x%llx has lower redundancy than data profile 0x%llx",
> - bctl->meta.target, bctl->data.target);
> + meta_target, data_target);
> }
>
> ret = insert_balance_item(fs_info, bctl);
> --
> 2.11.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] btrfs: fix a bogus warning when converting only data or metadata
2017-03-07 22:34 ` [PATCH v2] " Adam Borowski
2017-03-08 1:27 ` Liu Bo
@ 2017-03-09 13:43 ` David Sterba
2017-03-09 21:56 ` Adam Borowski
1 sibling, 1 reply; 6+ messages in thread
From: David Sterba @ 2017-03-09 13:43 UTC (permalink / raw)
To: Adam Borowski; +Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, Liu Bo
On Tue, Mar 07, 2017 at 11:34:44PM +0100, Adam Borowski wrote:
> On Tue, Mar 07, 2017 at 12:34:07PM -0800, Liu Bo wrote:
> > This looks good, but this also brings another side effect, @bctl would
> > also be kept in balance_item which will be used to resume balance in
> > case of crash, so it may see a different bctl->meta.target.
> >
> > So would you please use local varibles for meta.target and data.target?
>
> Okay.
>
> I'm not sure why storing a bogus value that came from userspace and was
> uninitialized there (0 in normal use) would be better, but here we go:
> v2 doesn't overwrite what we got anymore.
>
> Unrelated: I wonder if the profiles in the warning message shouldn't be
> printk'ed as words (akin to ebce0e01), but we don't have a function to do
> that, have we?
Printing human readable strings would be better, you can copy the
missing functions from progs as Lui pointed out.
> @@ -3750,6 +3750,7 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
> struct btrfs_ioctl_balance_args *bargs)
> {
> struct btrfs_fs_info *fs_info = bctl->fs_info;
> + __u64 meta_target, data_target;
Changed to u64, the __u64 is for kernel/userspace interfaces.
> u64 allowed;
> int mixed = 0;
> int ret;
> @@ -3846,11 +3847,16 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
> }
> } while (read_seqretry(&fs_info->profiles_lock, seq));
>
> - if (btrfs_get_num_tolerated_disk_barrier_failures(bctl->meta.target) <
> - btrfs_get_num_tolerated_disk_barrier_failures(bctl->data.target)) {
> + /* if we're not converting, the target field is uninitialized */
> + 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,
> "metadata profile 0x%llx has lower redundancy than data profile 0x%llx",
> - bctl->meta.target, bctl->data.target);
> + meta_target, data_target);
> }
The patch does not apply to current master, there's
3861 if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) {
3862 fs_info->num_tolerated_disk_barrier_failures = min(
3863 btrfs_calc_num_tolerated_disk_barrier_failures(fs_info),
3864 btrfs_get_num_tolerated_disk_barrier_failures(
3865 bctl->sys.target));
3866 }
3867
followed by the line below, I'll merge that manually but slightly wonder
which branch you have used as a base. No big deal though, I'll add the
patch to the queue. Thanks.
> ret = insert_balance_item(fs_info, bctl);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] btrfs: fix a bogus warning when converting only data or metadata
2017-03-09 13:43 ` David Sterba
@ 2017-03-09 21:56 ` Adam Borowski
0 siblings, 0 replies; 6+ messages in thread
From: Adam Borowski @ 2017-03-09 21:56 UTC (permalink / raw)
To: David Sterba, linux-btrfs
On Thu, Mar 09, 2017 at 02:43:27PM +0100, David Sterba wrote:
> The patch does not apply to current master, there's
>
> 3861 if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) {
> 3862 fs_info->num_tolerated_disk_barrier_failures = min(
> 3863 btrfs_calc_num_tolerated_disk_barrier_failures(fs_info),
> 3864 btrfs_get_num_tolerated_disk_barrier_failures(
> 3865 bctl->sys.target));
> 3866 }
> 3867
>
> followed by the line below, I'll merge that manually but slightly wonder
> which branch you have used as a base. No big deal though, I'll add the
> patch to the queue. Thanks.
>
> > ret = insert_balance_item(fs_info, bctl);
I had Qu's chunk counting patchset in my tree (and some irrelevant stuff,
like tty patches). But this means there'll be a minor conflict between the
two once you get around to merging Qu's stuff.
It's obvious how they interact; the bogus warning happens with and without
chunk counting.
--
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄⠀⠀⠀⠀ preimage for double rot13!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-09 22:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07 5:42 [PATCH] btrfs: fix a bogus warning when converting only data or metadata Adam Borowski
2017-03-07 20:34 ` Liu Bo
2017-03-07 22:34 ` [PATCH v2] " Adam Borowski
2017-03-08 1:27 ` Liu Bo
2017-03-09 13:43 ` David Sterba
2017-03-09 21:56 ` Adam Borowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).