Re: [PATCH v2 0/8] Support Clang context analysis for ext2
From: Jan Kara
Date: Thu Sep 03 2026 - 07:14:05 EST
On Thu 03-09-26 12:34:34, Marco Elver wrote:
> On Thu, 3 Sept 2026 at 09:28, Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
> > fs/ext2/super.c:1149:3: error: calling function 'ext2_rsv_window_add' requires holding spinlock 'EXT2_SB(sb).s_rsv_window_lock' exclusively [-Werror,-Wthread-safety-precise]
> > 1149 | ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
> > | ^
> > fs/ext2/super.c:1149:3: note: found near match '_res->s_rsv_window_lock'
>
> sbi was just allocated, and EXT2_SB(sb) and sbi are pointing to the
> same object (unless I misread the code), but the compiler can't tell
> since aliases can't be tracked through non-local objects. So that
> scoped_guard could just become:
>
> scoped_guard(spinlock, &EXT2_SB(sb)->s_rsv_window_lock) {
> ...
>
> But I'll leave that to Jan and Tim.
Yes, at the beginning of ext4_fill_super() we do:
sbi = kzalloc_obj(*sbi);
...
sb->s_fs_info = sbi;
and EXT2_SB(sb) is just sb->s_fs_info. Are you saying that clang is not
able to infer that sb->s_fs_info and sbi are still pointing to the same
memory later in the function where we do scoped_guard()?
Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR