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

Timothy Day <[email protected]>
Newsgroups org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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
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.