Re: [PATCH RFC v2 03/18] super: take lock after last reference count
Jan Kara <[email protected]> Mon, 22 Jun 2026 15:50:10 +0200
| Newsgroups | org.ozlabs.lists.linux-erofs,org.kernel.vger.linux-block,org.kernel.vger.linux-btrfs,org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel,org.kernel.vger.linux-xfs |
|---|---|
| Message-ID | <p22dytpj26jz72sqohiqrhkacrc4r5wt7soanows744el5jzqb@3236bcjzmilk> |
On Tue 16-06-26 16:08:19, Christian Brauner wrote: > __put_super() required the caller to hold sb_lock, so put_super() > wrapped it. The per-device superblock table introduced later drops its > passive references from contexts that do not hold sb_lock, so make > put_super() self-locking: drop the count first and take sb_lock only for > the final list_del. > > With the count now dropped outside sb_lock a superblock can briefly sit > on @super_blocks with s_passive == 0 before it is unlinked, so the list > walkers (__iterate_supers(), iterate_supers_type(), user_get_super()) > switch to refcount_inc_not_zero() and skip it. > > Signed-off-by: Christian Brauner (Amutable) <[email protected]> Looks good, just one style nit below. Feel free to add: Reviewed-by: Jan Kara <[email protected]> > -static void __put_super(struct super_block *s) > +void put_super(struct super_block *s) > { > if (refcount_dec_and_test(&s->s_passive)) { > + I'd delete this empty line. > + spin_lock(&sb_lock); > list_del_init(&s->s_list); > + spin_unlock(&sb_lock); > + Honza -- Jan Kara <[email protected]> SUSE Labs, CR