From: Jan Kara <jack@suse.cz>
To: Ritesh Harjani <riteshh@linux.ibm.com>
Cc: Jan Kara <jack@suse.cz>,
linux-ext4@vger.kernel.org,
"J. R. Okajima" <hooanon05g@gmail.com>
Subject: Re: [PATCH v2] ext2: Silence lockdep warning about reclaim under xattr_sem
Date: Wed, 26 Feb 2020 13:16:49 +0100 [thread overview]
Message-ID: <20200226121649.GK10728@quack2.suse.cz> (raw)
In-Reply-To: <20200226113219.16F065205A@d06av21.portsmouth.uk.ibm.com>
On Wed 26-02-20 17:02:18, Ritesh Harjani wrote:
>
>
> On 2/25/20 5:38 PM, Jan Kara wrote:
> > 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>
> > Signed-off-by: Jan Kara <jack@suse.cz>
>
> Agreed with evict() will only be called when it's the last reference going
> down and so we won't be blocked on xattr_sem.
> Thanks for clearly explaining the problem in the cover letter.
>
> Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Thanks for review! I've now pushed the patch to my tree.
Honza
>
>
> > ---
> > fs/ext2/xattr.c | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > Changes since v1:
> > - changed WARN_ON to WARN_ON_ONCE
> >
> > 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;
> >
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-02-26 12:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-25 12:08 [PATCH v2] ext2: Silence lockdep warning about reclaim under xattr_sem Jan Kara
2020-02-26 11:32 ` Ritesh Harjani
2020-02-26 12:16 ` Jan Kara [this message]
2020-04-06 5:36 ` J. R. Okajima
2020-04-06 10:21 ` Jan Kara
2020-04-06 11:50 ` J. R. Okajima
2020-04-07 5:22 ` J. R. Okajima
2020-04-07 10:38 ` Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200226121649.GK10728@quack2.suse.cz \
--to=jack@suse.cz \
--cc=hooanon05g@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=riteshh@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox