Re: [PATCH] bcachefs: Fix sysfs warning in fstests generic/730,731

Christoph Hellwig
2024-10-14T06:10:23Z

On Sat, Oct 12, 2024 at 02:42:39PM -0400, Kent Overstreet wrote:
> sysfs warns if we're removing a symlink from a directory that's no
> longer in sysfs; this is triggered by fstests generic/730, which
> simulates hot removal of a block device.
>
> This patch is however not a correct fix, since checking
> kobj->state_in_sysfs on a kobj owned by another subsystem is racy.
>
> A better fix would be to add the appropriate check to
> sysfs_remove_link() - and sysfs_create_link() as well.

The proper fix is to not link to random other subsystems with
object lifetimes you can't know. I'm not sure why you think adding
this link was ever allowed.