diff options
author | Jan Kara <jack@suse.cz> | 2020-02-24 12:52:17 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2020-02-26 13:14:27 +0100 |
commit | bc36dfffd5f3f19edcf85954d93eb0bc45875c37 (patch) | |
tree | 725b67fb30346bf312326d501eefbfff53a29c98 /fs/ext2 | |
parent | f8788d86ab28f61f7b46eb6be375f8a726783636 (diff) | |
download | linux-bc36dfffd5f3f19edcf85954d93eb0bc45875c37.tar.gz |
ext2: Silence lockdep warning about reclaim under xattr_sem
Lockdep complains about a chain:
sb_internal#2 --> &ei->xattr_sem#2 --> fs_reclaim
and shrink_dentry_list -> ext2_evict_inode -> ext2_xattr_delete_inode ->
down_write(ei->xattr_sem) creating a locking cycle in the reclaim path.
This is however a false positive because when we are in
ext2_evict_inode() we are the only holder of the inode reference and
nobody else should touch xattr_sem of that inode. So we cannot ever
block on acquiring the xattr_sem in the reclaim path.
Silence the lockdep warning by using down_write_trylock() in
ext2_xattr_delete_inode() to not create false locking dependency.
Reported-by: "J. R. Okajima" <hooanon05g@gmail.com>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/xattr.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 0456bc990b5e..9ad07c7ef0b3 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -790,7 +790,15 @@ ext2_xattr_delete_inode(struct inode *inode) struct buffer_head *bh = NULL; struct ext2_sb_info *sbi = EXT2_SB(inode->i_sb); - down_write(&EXT2_I(inode)->xattr_sem); + /* + * We are the only ones holding inode reference. The xattr_sem should + * better be unlocked! We could as well just not acquire xattr_sem at + * all but this makes the code more futureproof. OTOH we need trylock + * here to avoid false-positive warning from lockdep about reclaim + * circular dependency. + */ + if (WARN_ON_ONCE(!down_write_trylock(&EXT2_I(inode)->xattr_sem))) + return; if (!EXT2_I(inode)->i_file_acl) goto cleanup; |