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. Signed-off-by: Timothy Day --- fs/ext2/xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index e55d16abf422f..e5ed27f2ae733 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -826,8 +826,10 @@ ext2_xattr_delete_inode(struct inode *inode) * here to avoid false-positive warning from lockdep about reclaim * circular dependency. */ - if (WARN_ON_ONCE(!down_write_trylock(&EXT2_I(inode)->xattr_sem))) + if (!down_write_trylock(&EXT2_I(inode)->xattr_sem)) { + WARN_ON_ONCE(1); return; + } if (!EXT2_I(inode)->i_file_acl) goto cleanup; -- 2.39.5