Re: [PATCH 1/2] btrfs: init device stats for seed devices

Anand Jain
2020-09-21T23:54:09Z

On 19/9/20 4:44 am, Josef Bacik wrote:
> We recently started recording device stats across the fleet, and noticed
> a large increase in messages such as this
>
> BTRFS warning (device dm-0): get dev_stats failed, not yet valid
>
> on our tiers that use seed devices for their root devices. This is
> because we do not initialize the device stats for any seed devices if we
> have a sprout device and mount using that sprout device. The basic
> steps for reproducing are
>
> mkfs seed device
> mount seed device
> fill seed device
> umount seed device
> btrfstune -S 1 seed device
> mount seed device
> btrfs device add -f sprout device /mnt/wherever
> umount /mnt/wherever
> mount sprout device /mnt/wherever
> btrfs device stats /mnt/wherever
>
> This will fail with the above message in dmesg.
>
> Fix this by iterating over the fs_devices->seed if they exist in
> btrfs_init_dev_stats. This fixed the problem and properly reports the
> stats for both devices.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand