On Mon, Mar 31, 2025 at 12:07:12PM +0200, Jan Kara wrote: > On Sat 29-03-25 09:42:18, Christian Brauner wrote: > > Use a common iterator for all callbacks. We could go for something even > > more elaborate (advance step-by-step similar to iov_iter) but I really > > don't think this is warranted. > > > > Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> > > Looks good, one nit below. With that fixed feel free to add: > > Reviewed-by: Jan Kara <jack@xxxxxxx> > > > +#define invalid_super list_entry_is_head > > Why do you have this invalid_super define? I find it rather confusing in > the loop below and list_entry_is_head() would be much more > understandable... Fair, I just wanted a shorter name but I'll change it to list_entry_is_head() and push it out. > > Honza > > > + > > +static void __iterate_supers(void (*f)(struct super_block *, void *), void *arg, > > + enum super_iter_flags_t flags) > > { > > struct super_block *sb, *p = NULL; > > + bool excl = flags & SUPER_ITER_EXCL; > > > > - spin_lock(&sb_lock); > > - list_for_each_entry(sb, &super_blocks, s_list) { > > - bool locked; > > + guard(spinlock)(&sb_lock); > > > > + for (sb = first_super(flags); !invalid_super(sb, &super_blocks, s_list); > > + sb = next_super(sb, flags)) { > > if (super_flags(sb, SB_DYING)) > > continue; > > sb->s_count++; > > spin_unlock(&sb_lock); > > > > - locked = super_lock(sb, excl); > > - if (locked) { > > + if (flags & SUPER_ITER_UNLOCKED) { > > + f(sb, arg); > > + } else if (super_lock(sb, excl)) { > > f(sb, arg); > > super_unlock(sb, excl); > > } > -- > Jan Kara <jack@xxxxxxxx> > SUSE Labs, CR