Re: [PATCH 8/8] btrfs: sysfs: Add bdi link to the fsid dir

David Sterba
2020-07-02T13:36:37Z

On Thu, Jul 02, 2020 at 09:25:30AM -0400, Josef Bacik wrote:
> On 7/2/20 8:23 AM, Nikolay Borisov wrote:
> > Since BTRFS uses a private bdi it makes sense to create a link to this
> > bdi under /sys/fs/btrfs/<UUID>/bdi. This allows size of read ahead to
> > be controlled. Without this patch it's not possible to uniquely identify
> > which bdi pertains to which btrfs filesystem in the fase of multiple
> > btrfs filesystem.
> >
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>
> Was confused why we needed to make sure the link existed before removing it,
> since other things sysfs is smart enough to figure out. Apparently it has a
> WARN_ON() if the parent isn't initialized, so the check is necessary, albeit
> annoying.

There must be a better way, this is just too weird. We can check if
objects have been initialized by peeking to kobject::state_initialized
and we use that already for fsid_kobj in __btrfs_sysfs_remove_fsid or
btrfs_sysfs_feature_update.