From: Yihao Wu <wuyihao@linux.alibaba.com>
To: Chuck Lever <chuck.lever@oracle.com>,
Trond Myklebust <trondmy@hammerspace.com>
Cc: Bruce Fields <bfields@fieldses.org>,
"neilb@suse.com" <neilb@suse.com>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] nfsd: fix race between cache_clean and cache_purge
Date: Wed, 25 Mar 2020 14:37:12 +0800 [thread overview]
Message-ID: <5372f88d-efb7-25a3-789f-53bfa7bb6f26@linux.alibaba.com> (raw)
In-Reply-To: <CCFA2CA8-150C-432C-B939-9085B791FE74@oracle.com>
On 2020/3/25 1:46 AM, Chuck Lever wrote:
>>>> ---
>>>> net/sunrpc/cache.c | 3 +++
>>>> 1 file changed, 3 insertions(+)
>>>>
>>>> diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
>>>> index bd843a81afa0..3e523eefc47f 100644
>>>> --- a/net/sunrpc/cache.c
>>>> +++ b/net/sunrpc/cache.c
>>>> @@ -524,9 +524,11 @@ void cache_purge(struct cache_detail *detail)
>>>> struct hlist_node *tmp = NULL;
>>>> int i = 0;
>>>>
>>>> + spin_lock(&cache_list_lock);
>>>> spin_lock(&detail->hash_lock);
>>>> if (!detail->entries) {
>>>> spin_unlock(&detail->hash_lock);
>>>> + spin_unlock(&cache_list_lock);
>>>> return;
>>>> }
>>>>
>>>> @@ -541,6 +543,7 @@ void cache_purge(struct cache_detail *detail)
>>>> }
>>>> }
>>>> spin_unlock(&detail->hash_lock);
>>>> + spin_unlock(&cache_list_lock);
>>>> }
>>>> EXPORT_SYMBOL_GPL(cache_purge);
>>
>> Hmm... Shouldn't this patch be dropping cache_list_lock() when we call
>> sunrpc_end_cache_remove_entry()? The latter does call both
>> cache_revisit_request() and cache_put(), and while they do not
>> explicitly call anything that holds cache_list_lock, some of those cd-
>>> cache_put callbacks do look as if there is potential for deadlock.
> I see svc_export_put calling dput, eventually, which might_sleep().
Wow that's a little strange. If svc_export_put->dput might_sleep, why can we
spin_lock(&detail->hash_lock); in cache_purge in the first place?
And I agree with Trond those cd->cache_put callbacks are dangerous. I will look
into them today.
But if we dropping cache_list_lock when we call sunrpc_end_cache_remove_entry,
cache_put is not protected, and this patch won't work anymore, right?
Thanks,
Yihao Wu
next prev parent reply other threads:[~2020-03-25 6:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 9:49 [PATCH] nfsd: fix race between cache_clean and cache_purge Yihao Wu
2020-03-24 13:38 ` Chuck Lever
2020-03-24 14:33 ` Bruce Fields
2020-03-24 14:35 ` Chuck Lever
2020-03-24 15:24 ` Trond Myklebust
2020-03-24 17:46 ` Chuck Lever
2020-03-25 6:37 ` Yihao Wu [this message]
2020-03-25 14:24 ` Chuck Lever
2020-03-25 15:14 ` Yihao Wu
2020-03-24 14:18 ` Chuck Lever
2020-03-24 14:28 ` Yihao Wu
2020-03-24 23:07 ` NeilBrown
2020-04-04 13:53 ` Yihao Wu
2020-03-25 1:01 ` Sasha Levin
2020-03-25 14:13 ` Chuck Lever
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=5372f88d-efb7-25a3-789f-53bfa7bb6f26@linux.alibaba.com \
--to=wuyihao@linux.alibaba.com \
--cc=bfields@fieldses.org \
--cc=chuck.lever@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.com \
--cc=trondmy@hammerspace.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