From: Shan Hai <shan.hai@oracle.com>
To: Jia-Ju Bai <baijiaju1990@163.com>, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: xfs: Fix a lock-twice and sleep-in-atomic bug in xfs_iget
Date: Mon, 5 Jun 2017 16:32:48 +0800 [thread overview]
Message-ID: <43a9b80f-fd7d-2df3-f726-207742c7924f@oracle.com> (raw)
In-Reply-To: <1496650649-2296-1-git-send-email-baijiaju1990@163.com>
On 2017年06月05日 16:17, Jia-Ju Bai wrote:
> The driver may sleep under a read rcu lock, and function call path is:
> xfs_iget (acquire the lock by rcu_read_lock)
> "goto out_error_or_again" after xfs_iget_cache_hit
> delay
> schedule_timeout_uninterruptible --> may sleep
> Meanwhile, the rcu_read_lock will be called twice in this situation.
>
> To fix it, the lock is released before "goto".
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
> ---
> fs/xfs/xfs_icache.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index f61c84f8..c2a4722 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -600,8 +600,10 @@ struct xfs_inode *
>
> if (ip) {
> error = xfs_iget_cache_hit(pag, ip, ino, flags, lock_flags);
> - if (error)
> + if (error) {
> + rcu_read_unlock();
Seems you are going to double unlock by doing this, since it is unlocked
in the xfs_iget_cache_hit.
Thanks
Shan Hai
> goto out_error_or_again;
> + }
> } else {
> rcu_read_unlock();
> XFS_STATS_INC(mp, xs_ig_missed);
next prev parent reply other threads:[~2017-06-05 8:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-05 8:17 [PATCH] fs: xfs: Fix a lock-twice and sleep-in-atomic bug in xfs_iget Jia-Ju Bai
2017-06-05 8:32 ` Shan Hai [this message]
2017-06-05 8:56 ` Jia-Ju Bai
2017-06-08 5:55 ` [lkp-robot] [fs] 8ba626f5b2: BUG:scheduling_while_atomic kernel test robot
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=43a9b80f-fd7d-2df3-f726-207742c7924f@oracle.com \
--to=shan.hai@oracle.com \
--cc=baijiaju1990@163.com \
--cc=darrick.wong@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).