Re: [PATCH v1 2/9] ext2: mark s_next_generation as guarded by s_next_gen_lock

From: Timothy Day

Date: Thu Jul 16 2026 - 22:05:09 EST


On Sun, 12 Jul 2026 12:56:03 -0400, Timothy Day wrote:
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 3999f8f3b156e..8c7f3772917bb 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -1125,9 +1125,11 @@ static int ext2_fill_super(struct super_block *sb, struct fs_context *fc)
> goto failed_mount2;
> }
> sbi->s_gdb_count = db_count;
> - sbi->s_next_generation = get_random_u32();
> spin_lock_init(&sbi->s_next_gen_lock);

If I change this to guard(spinlock_init)(&sbi->s_next_gen_lock), I should
be able to avoid the context_unsafe() line right after this. I'll fix
that in the next revision. There may be some other places in the series
where I can make the same fix.

>
> + /* concurrent access is not possible before the mount completes */
> + context_unsafe(sbi->s_next_generation = get_random_u32());
> +
> /* per filesystem reservation list head & lock */
> spin_lock_init(&sbi->s_rsv_window_lock);
> sbi->s_rsv_window_root = RB_ROOT;
> --
> 2.39.5

Tim Day