From: Huang Jianan <huangjianan@oppo.com>
To: fuse-devel@lists.sourceforge.net, miklos@szeredi.hu
Cc: guoweichao@oppo.com, zhangshiming@oppo.com,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [fuse-devel] [PATCH] fuse: avoid deadlock when write fuse inode
Date: Sun, 7 Feb 2021 09:47:35 +0800 [thread overview]
Message-ID: <888b7732-abb3-3025-6e91-0d5cb5675efd@oppo.com> (raw)
In-Reply-To: <ced84fb1-0dc1-a18f-0e61-556cd9e28003@oppo.com>
friendly ping ... 😁
On 2021/2/2 12:11, Huang Jianan via fuse-devel wrote:
> Hi all,
>
>
> This patch works well in our product, but I am not sure this is the
> correct
>
> way to solve this problem. I think that the inode->i_count shouldn't be
>
> zero after iput is executed in dentry_unlink_inode, then the inode won't
>
> be writeback. But i haven't found where iget is missing.
>
>
> Thanks,
>
> Jianan
>
> On 2021/2/2 12:08, Huang Jianan wrote:
>> We found the following deadlock situations in low memory scenarios:
>> Thread A Thread B
>> - __writeback_single_inode
>> - fuse_write_inode
>> - fuse_simple_request
>> - __fuse_request_send
>> - request_wait_answer
>> - fuse_dev_splice_read
>> - fuse_copy_fill
>> - __alloc_pages_direct_reclaim
>> - do_shrink_slab
>> - super_cache_scan
>> - shrink_dentry_list
>> - dentry_unlink_inode
>> - iput_final
>> - inode_wait_for_writeback
>>
>> The request and inode processed by Thread A and B are the same, which
>> causes a deadlock. To avoid this, we remove the __GFP_FS flag when
>> allocating memory in fuse_copy_fill, so there will be no memory
>> reclaimation in super_cache_scan.
>>
>> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
>> Signed-off-by: Guo Weichao <guoweichao@oppo.com>
>> ---
>> fs/fuse/dev.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
>> index 588f8d1240aa..e580b9d04c25 100644
>> --- a/fs/fuse/dev.c
>> +++ b/fs/fuse/dev.c
>> @@ -721,7 +721,7 @@ static int fuse_copy_fill(struct fuse_copy_state
>> *cs)
>> if (cs->nr_segs >= cs->pipe->max_usage)
>> return -EIO;
>> - page = alloc_page(GFP_HIGHUSER);
>> + page = alloc_page(GFP_HIGHUSER & ~__GFP_FS);
>> if (!page)
>> return -ENOMEM;
>
>
next prev parent reply other threads:[~2021-02-07 1:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 4:08 [PATCH] fuse: avoid deadlock when write fuse inode Huang Jianan
2021-02-02 4:11 ` Huang Jianan
2021-02-07 1:47 ` Huang Jianan [this message]
2021-03-24 15:28 ` [fuse-devel] " Miklos Szeredi
2022-03-10 11:10 ` Rokudo Yan
2022-04-25 13:15 ` Miklos Szeredi
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=888b7732-abb3-3025-6e91-0d5cb5675efd@oppo.com \
--to=huangjianan@oppo.com \
--cc=fuse-devel@lists.sourceforge.net \
--cc=guoweichao@oppo.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=zhangshiming@oppo.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;
as well as URLs for NNTP newsgroup(s).