Re: [PATCH v1 1/9] ext2: fix ext2_xattr_delete_inode() context analysis warning

From: Marco Elver

Date: Tue Jul 14 2026 - 18:53:19 EST


On Wed, 15 Jul 2026 at 00:08, Marco Elver <elver@xxxxxxxxxx> wrote:
>
> On Tue, 14 Jul 2026 at 23:14, Timothy Day
> <timday@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Tue, 14 Jul 2026 00:56:56 +0200, Marco Elver wrote:
> > > Relatively certain statement expressions were once again the problem -
> > > this should fix it: https://github.com/llvm/llvm-project/pull/209330
> > >
> > > I haven't had time to test the Clang fix on fs/ext2/xattr.c with
> > > context analysis enabled (please do so if you already build Clang
> > > yourself, otherwise I might get to it in ~week).
> >
> > The fix wasn't enough. The commit message on patch 1/9 omitted another
> > warning. On vanilla Clang 23, I see:
> >
> > linux/fs/ext2/xattr.c:829:6: error: rw_semaphore 'EXT2_I().xattr_sem' is \
> > not held on every path through here [-Werror,-Wthread-safety-analysis]
> > 829 | if (WARN_ON_ONCE(!down_write_trylock(&EXT2_I(inode)->xattr_sem)))
> > | ^
> >
> > and:
> >
> > linux/fs/ext2/xattr.c:860:2: error: releasing rw_semaphore \
> > 'EXT2_I().xattr_sem' that was not held [-Werror,-Wthread-safety-analysis]
> > 860 | up_write(&EXT2_I(inode)->xattr_sem);
> > | ^
> >
> > If I apply your patch, it resolves the second warning but not the first.
> > I tried to generate a fix [1]. That branch has both your patch and my
> > fix applied. Those two changes combined fix both warnings. My fix
> > tries to add some special casing for tracking contexts acquired by
> > trylocks. It works, but I'm not very confident on the correctness.
>
> Nice, thanks. I'll have a look, but it appears right. Need to get my
> PR merged first (need approval), then please feel free to send yours
> with me as reviewer/approver.

My Clang PR was merged. Can you rebase and send your Clang fix and add
me as a reviewer? Please add a more elaborate commit description,
because it's a little more intrusive and the problem and your solution
is less obvious.

Thanks,
-- Marco