Re: Re: [PATCH v2 0/2] btrfs: delay mounted sysfs attributes until mount is ready

"Jiacheng Xu" <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Great! Please let me know if the patch is finally merged.

Thanks,
Jiacheng

> -----原始邮件-----
> 发件人: "Qu Wenruo" <[email protected]>
> 发送时间:2026-08-22 12:57:14 (星期六)
> 收件人: "Jiacheng Xu" <[email protected]>
> 抄送: [email protected], [email protected]
> 主题: Re: [PATCH v2 0/2] btrfs: delay mounted sysfs attributes until mount is ready
> 
> 
> 
> 在 2026/8/22 13:11, Jiacheng Xu 写道:
> > Here is a potential fix following Wenruo's idea.
> > 
> > btrfs_sysfs_add_mounted() currently publishes the writable label and
> > feature attributes before the transaction kthread is created. A concurrent
> > sysfs write can therefore dereference a NULL transaction_kthread in
> > wake_up_process().
> > 
> > This series follows the suggested lifecycle: create only the required
> > subdirectories during early mount, publish the fsid attributes after mount
> > initialization, and remove them before the kthreads are stopped. The
> > feature attributes are included because their store callback has the same
> > transaction_kthread dependency as the label callback.
> > 
> > Patch 1 factors the fsid attribute handling into dedicated helpers. Patch 2
> > moves their publication and removal to the safe mount and unmount stages.
> > On unmount the cleaner is parked before attribute removal so it cannot
> > recreate the feature group through sysfs_update_group(). Both patches are
> > required for stable backports.
> > 
> > The resulting fs/btrfs/sysfs.o and fs/btrfs/disk-io.o were build-tested.
> > 
> > Changes in v2:
> > - Delay creation of both the root and feature attributes until mount setup
> >    is complete.
> 
> You don't need to bother feature attributes for now, there is already a 
> patch addressing it by completely removing the write support for feature 
> attributes:
> 
> https://lore.kernel.org/linux-btrfs/8a598d76555b5944d34bb08fa8dbeea28fc05db9.1787307129.git.wqu@suse.com/
> 
> Considering it's only extended_iref, removing it should be much simpler.
> Until that is determined, you only need to bother the label one.
> 
> 
> Furthermore, among all the attr files in the fsid directory, there is 
> only label that is writable, it would make more sense to split 
> btrfs_attrs into two parts, one for those read-only members, and one for 
> the only writebale label one.
> 
> Otherwise the series looks much better.
> 
> 
> > - Remove those attributes while their kthread dependencies are still
> >    valid.
> > - Split helper extraction from the lifecycle fix for stable backports.
> > 
> > Jiacheng Xu (2):
> >    btrfs: sysfs: factor out mounted fsid attribute helpers
> >    btrfs: delay mounted fsid attributes until the fs is ready
> > 
> >   fs/btrfs/disk-io.c | 18 ++++++++++++++++-
> >   fs/btrfs/sysfs.c   | 50 ++++++++++++++++++++++++++++++----------------
> >   fs/btrfs/sysfs.h   |  2 ++
> >   3 files changed, 52 insertions(+), 18 deletions(-)
> > 
> > base-commit: 0f23d56f17fdfc7db69d51f64c8b91bbab947aa9
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.