Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp871249pxk; Thu, 24 Sep 2020 23:16:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoN4fCbhxrUXBd4bBlUGhKTV2l4dDHLDgbhQi1xn/XYuDH8y7rfqGG7aJxMVkugmeoW+88 X-Received: by 2002:a50:f418:: with SMTP id r24mr2373776edm.295.1601014579456; Thu, 24 Sep 2020 23:16:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601014579; cv=none; d=google.com; s=arc-20160816; b=EPuY6WXZB21WGM0lOcbmOfpHRP6l5ADjpCkq9QjBJd63ImEL919EsNp93sHi/NCSxi sFYL9D0hqM+OJHBQq4VxsTfmDwg+rxg7RRq8F2x6CvRFHf13EIwB2RwFyH8OLLzOBrzB 4mPb2WGZTE3kTwVsmO3b3P4ZFG3XADfQmNYqsakRhwxS6eXlUIO0pMY3qlTwa2re8Mq1 5Fy2Cu5k/zzayYU39V+iEUoNoSI+fFHSPpb8JkB4rZ2OI5Re3DP272iNJMRij1Fw3TZQ HhR1y0c016qyRxkMSntZQe/NDukU9zucFVXOS/MDwQWt0VmqOGGBsfS50da740WCIbPT AO6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=be/0vLlE/LS0PZrj3/71lS5VwglJ0Fa9i+MMSb27bDU=; b=Xx1kRgiooHgRuznxbHAQTVFXhbLFDYEadisDFrA7gqd5BuGnSy1aaQB0LvvzhoxLC8 t4k6qfQY7ffn6nB6LdT47J9X1lRBQlojeKOnC5HKEXQACBnPRFYr4x3XRcPsVOIyBjy/ r1iHgcc/ZH0sd9H8I5nAFB0FTkLv70nDt74U2RH19M49H/rAUQxjnmy2UOTj8XKn7XzK NguHRKRNkHqzrg9X9fULnSSkT5fGsVgMPkXa63NiDsxSG/NC/6qIc0BdBeVjlG4VYR20 HLxGA2OHaWISUlw2+6x2eQo0E2zUVw3DqCw+h9WoHsBzR6I8+IgYCg1ysGR+uaDRZdTd H+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LHq28D0i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si1269814edt.207.2020.09.24.23.15.55; Thu, 24 Sep 2020 23:16:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LHq28D0i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727167AbgIYGOy (ORCPT + 99 others); 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-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-kernel@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; -- 1.9.1