Re: [PATCH RFC v2 03/18] super: take lock after last reference count
From: Jan Kara
Date: Mon Jun 22 2026 - 09:53:11 EST
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) <brauner@xxxxxxxxxx>
Looks good, just one style nit below. Feel free to add:
Reviewed-by: Jan Kara <jack@xxxxxxx>
> -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 <jack@xxxxxxxx>
SUSE Labs, CR