From patchwork Fri Sep 25 06:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jing xia X-Patchwork-Id: 11799069 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08A831668 for ; Fri, 25 Sep 2020 06:14:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7EB622211 for ; Fri, 25 Sep 2020 06:14:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LHq28D0i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727110AbgIYGOy (ORCPT ); Fri, 25 Sep 2020 02:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbgIYGOy (ORCPT ); Fri, 25 Sep 2020 02:14:54 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138A1C0613CE; Thu, 24 Sep 2020 23:14:54 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id md22so895912pjb.0; Thu, 24 Sep 2020 23:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=be/0vLlE/LS0PZrj3/71lS5VwglJ0Fa9i+MMSb27bDU=; b=LHq28D0ipR6Og8vtGCYU4htehUf8oB02IwWqD2jMOkfRMS+N6TRfP27j6UvHyT5ur2 WmdwrshEN3B/owH2TkGGrqfz55FA4LJHQw2+fRm3VFcFibRXziEIiQCSlJkiFO9KXd27 aaM5hckTvo8hMF5MsHZahYHK85OzPSHphvvusxirCHSYC4rscnRI9IcFYjYu9jtYlyME 75UwQkDIQmS4GuDQw3TUXCw5bs1TU4CFr7oD2rlazyvdurMjV2Z4xTCPTpI/8GFw0vVv Ap6dd8eP+Ek7O8pawjp9VhuGSZKK06iZrWNiWA3DCVVeT393J5uJP/bYGFXsL+xJV4kf bO4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=be/0vLlE/LS0PZrj3/71lS5VwglJ0Fa9i+MMSb27bDU=; b=AhtUEwTllaQrF3e4kqzVVXcJJeVqkHEV23qQ43aaus1DRUpwjHanRmdzrjRR9y7q1u AFv3uRA8kTuvKIo0A/W/xxNPqbAK0uuEtYDpgdfif+qCSXkjqH/G+iFO06mFXgkZO6Fx FJ5YS0RkNPKvkfwUuoFPgYRygWFgOMLS9SWlJaX7QqmPfwncats/3icm+gC0jj77fwH/ IjKZ3MWkaRCSABu/a4A4UpLhbYBGQGiCq1aaXQ7DStANeVUfqsN1GBksb447zonI5FZT 6amYSK4Tb3Qm4Lc2uqCt+Pgv82vySInt2CQkj9SLESOZklfviShg5EOLzc/3p8vt2HoW +Ttg== X-Gm-Message-State: AOAM533MS4hgt7CeVyni8OBZNk1Uad3KD/2kMYLMSo0JvBLuAAXL5Y0X kij6/Bzj0FbFHx7zrrQH22tZ70A2puE= X-Google-Smtp-Source: ABdhPJx5KiNzPFIOfN1JZsXV8xiNPiD5FTfGDU9MJy5nhKixEnFTss0O2XdO0ChIOyUP1fUGjIsSNA== X-Received: by 2002:a17:90a:ec05:: with SMTP id l5mr1284962pjy.172.1601014493578; Thu, 24 Sep 2020 23:14:53 -0700 (PDT) Received: from bj08259pcu.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id f4sm1102759pgk.19.2020.09.24.23.14.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2020 23:14:53 -0700 (PDT) From: jing.xia.mail@gmail.com To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, chunyan.zhang@unisoc.com, orson.zhai@unisoc.com, Jing Xia Subject: [PATCH] fuse: avoid deadlock by clearing __GFP_FS Date: Fri, 25 Sep 2020 14:14:31 +0800 Message-Id: <1601014471-3126-1-git-send-email-jing.xia.mail@gmail.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Jing Xia Writeback thread and fuse block each other. Writeback thread waits fuse's reply with inode's I_SYNC being held.Fuse enters the slowpath of memory allocation when handle the request and has to wait the inode's I_SYNC is cleared. writeback's backtrace --------------------- PID: 6197 TASK: ed130780 CPU: 3 COMMAND: "kworker/u8:7" #0 [] (__schedule) from [] #1 [] (schedule) from [] #2 [] (__fuse_request_send) from [] #3 [] (fuse_simple_request) from [] #4 [] (fuse_flush_times) from [] #5 [] (fuse_write_inode) from [] #6 [] (__writeback_single_inode) from [] #7 [] (writeback_sb_inodes) from [] #8 [] (__writeback_inodes_wb) from [] #9 [] (wb_writeback) from [] #10 [] (wb_workfn) from [] #11 [] (process_one_work) from [] #12 [] (worker_thread) from [] #13 [] (kthread) from [] fuse's backtrace --------------------- PID: 4412 TASK: c4b47800 CPU: 3 COMMAND: "Thread-9" #0 [] (__schedule) from [] #1 [] (schedule) from [] #2 [] (bit_wait) from [] #3 [] (__wait_on_bit) from [] #4 [] (__inode_wait_for_writeback) from [] #5 [] (inode_wait_for_writeback) from [] #6 [] (evict) from [] #7 [] (__dentry_kill) from [] #8 [] (shrink_dentry_list) from [] #9 [] (prune_dcache_sb) from [] #10 [] (super_cache_scan) from [] #11 [] (shrink_slab) from [] #12 [] (shrink_node) from [] #13 [] (do_try_to_free_pages) from [] #14 [] (try_to_free_pages) from [] #15 [] (__alloc_pages_nodemask) from [] #16 [] (fuse_copy_fill) from [] #17 [] (fuse_copy_one) from [] #18 [] (fuse_dev_do_read) from [] #19 [] (fuse_dev_splice_read) from [] #20 [] (sys_splice) from [] This patch clears __GFP_FS flag when fuse alloctes pages to avoid deadlock,as super_cache_scan will directly return SHRINK_STOP when __GFP_FS is not set. Signed-off-by: Jing Xia --- 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 02b3c36..165c416 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -708,7 +708,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;