Re: [PATCH v1 1/9] ext2: fix ext2_xattr_delete_inode() context analysis warning
From: Theodore Tso
Date: Mon Jul 13 2026 - 10:35:24 EST
On Sun, Jul 12, 2026 at 12:56:02PM -0500, Timothy Day wrote:
> Clang reports the following warning when context analysis is enabled:
>
> 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)))
> | ^
>
> When WARN_ON_ONCE() wraps down_write_trylock(), it adds an unlikely()
> annotation which hides the conditional acquire annotation from Clang's
> context analysis. This triggers a false positive. Pull the trylock out
> of the macro to silence this warning.
Does this mean that using Clang's context analysis means that we can't
use unlikely()? That seems.... unfortunate. Is there any other way
we can fix the false positive? Even disabling unlikely() if and only
if Clang context analysis is enabled might be a better choice, since
we don't necessarily need to build with context analysis enabled when
building a production kernel.
- Ted