From patchwork Tue Dec 8 02:15:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11957425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0485C433FE for ; Tue, 8 Dec 2020 02:16:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 50FC8239ED for ; Tue, 8 Dec 2020 02:16:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50FC8239ED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 791FE8D0002; Mon, 7 Dec 2020 21:16:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 742498D0001; Mon, 7 Dec 2020 21:16:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 632008D0002; Mon, 7 Dec 2020 21:16:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id 4AAD28D0001 for ; Mon, 7 Dec 2020 21:16:13 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 15F1A362B for ; Tue, 8 Dec 2020 02:16:13 +0000 (UTC) X-FDA: 77568500226.23.care80_530f1f7273e3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id EE0BB37604 for ; Tue, 8 Dec 2020 02:16:12 +0000 (UTC) X-HE-Tag: care80_530f1f7273e3 X-Filterd-Recvd-Size: 5733 Received: from mail-vk1-f193.google.com (mail-vk1-f193.google.com [209.85.221.193]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Dec 2020 02:16:12 +0000 (UTC) Received: by mail-vk1-f193.google.com with SMTP id i62so3608630vkb.7 for ; Mon, 07 Dec 2020 18:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=N4iknFTA7A8PYDmVPmJNoru7g6pRjx8JJZWZP7DeZ3U=; b=XUDaGfRRpcXdW6Wmu+Uis/2d7Qqzhi0QVe8sjhUzIfAfAgzzpOqoSPXYuh6ie4tBa3 VtCJWYdU/xnR+qdJOl64Rm3eGMA6/Q2hCK0AquXPoOkq2w1zHYaONVbt/cK2VXh/kFPE sTE7O1k+GpwjUuUKqIXcYgVAMMNKNDPGtQGxlRLhb1FecMADFJTpp73Gl0id/ZbFyD0L WEfuaLlL66qv5PZKIlA955rJxWWLej2vxj3fTH6EkKt1KFnLb+uGp0/prYTLyWULnzGk UmP+N7vU0Au5XZ1164/6XUkE/NddvsyigFd9TXXpKI++oTEE5sd110Osjalzg9hZW+uU 33Uw== 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:mime-version :content-transfer-encoding; bh=N4iknFTA7A8PYDmVPmJNoru7g6pRjx8JJZWZP7DeZ3U=; b=mYI7Oz1Uh9ThetMIAPVtKVj1L/rKz1b2CuMFSZ8KSEfJhWV0xmTv89tFReTh9w6mhB +G6jOb8aHGcXe3uaKJrmpo7y9u8+gfKlxorL8uZ+IkVCH5rebj3X1vQSi2RGZWcMx6Od SJFWZ+q8+tBBoqAsnw050EPnq2b7l7HC3TkNPn2W8ayZ3Lrm0NCVEpN6rEYYdbOBlOnX 2+vDL7XpkiQBwwJoK6C9NuWlqx/ROInjrb/P52Fi5Rta7zFUDjqX0OgHjPmRQkr0szlI DGTwGLu2o2Jmcl9u64oFhsRk218jqyaea0L/4WxVwcNc6eS5DTxp13v6uuRMG4DdPYa9 y9wQ== X-Gm-Message-State: AOAM533wbrABE+SbUeRfsx5BqiGJrR4npqNn1W0Y0MNT2J0gz7YnVl24 qZN3zVGJzQW7TYQXOoVunEU= X-Google-Smtp-Source: ABdhPJx3PMfgbCqCB6rPTd5DamJ2UeJDaVGUaq3shuEg3TEJZiaBkppoCISMrKaL7MYLdiGJgHIYYA== X-Received: by 2002:a1f:3411:: with SMTP id b17mr14936109vka.7.1607393771916; Mon, 07 Dec 2020 18:16:11 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id o192sm1936000vko.19.2020.12.07.18.16.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 18:16:11 -0800 (PST) From: Yafang Shao To: darrick.wong@oracle.com, willy@infradead.org, david@fromorbit.com, hch@infradead.org, mhocko@kernel.org, akpm@linux-foundation.org, dhowells@redhat.com, jlayton@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH v10 0/4] xfs: avoid transaction reservation recursion Date: Tue, 8 Dec 2020 10:15:39 +0800 Message-Id: <20201208021543.76501-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: PF_FSTRANS which is used to avoid transaction reservation recursion, is dropped since commit 9070733b4efa ("xfs: abstract PF_FSTRANS to PF_MEMALLOC_NOFS") and commit 7dea19f9ee63 ("mm: introduce memalloc_nofs_{save,restore} API"), and replaced by PF_MEMALLOC_NOFS which means to avoid filesystem reclaim recursion. As these two flags have different meanings, we'd better reintroduce PF_FSTRANS back. To avoid wasting the space of PF_* flags in task_struct, we can reuse the current->journal_info to do that, per Willy. As the check of transaction reservation recursion is used by XFS only, we can move the check into xfs_vm_writepage(s), per Dave. Patch #1 and #2 are to use the memalloc_nofs_{save,restore} API, which is introduced in commit 7dea19f9ee63 ("mm: introduce memalloc_nofs_{save,restore} API"), instead of using PF_MEMALLOC_NOFS directly in XFS. Patch #1 is picked form Willy's patchset "Overhaul memalloc_no*"[1] Patch #3 is the refactor of xfs_trans context, which is activated when xfs_trans is allocated and deactivated when xfs_trans is freed. Patch #4 is the implementation of reussing current->journal_info to avoid transaction reservation recursion. No obvious error occurred after running xfstests. [1]. https://lore.kernel.org/linux-mm/20200625113122.7540-1-willy@infradead.org v10: - refactor the code, per Dave. v9: - rebase it on xfs tree. - Darrick fixed an error occurred in xfs/141 - run xfstests, and no obvious error occurred. v8: - check xfs_trans_context_active() in xfs_vm_writepage(s), per Dave. v7: - check fstrans recursion for XFS only, by introducing a new member in struct writeback_control. v6: - add Michal's ack and comment in patch #1. v5: - pick one of Willy's patch - introduce four new helpers, per Dave v4: - retitle from "xfs: introduce task->in_fstrans for transaction reservation recursion protection" - reuse current->journal_info, per Willy Matthew Wilcox (Oracle) (1): mm: Add become_kswapd and restore_kswapd Yafang Shao (3): xfs: use memalloc_nofs_{save,restore} in xfs transaction xfs: refactor the usage around xfs_trans_context_{set,clear} xfs: use current->journal_info to avoid transaction reservation recursion fs/iomap/buffered-io.c | 7 ------- fs/xfs/libxfs/xfs_btree.c | 14 ++++++++------ fs/xfs/xfs_aops.c | 21 +++++++++++++++++++-- fs/xfs/xfs_linux.h | 4 ---- fs/xfs/xfs_trans.c | 24 +++++++++++------------- fs/xfs/xfs_trans.h | 37 +++++++++++++++++++++++++++++++++++++ include/linux/sched/mm.h | 23 +++++++++++++++++++++++ mm/vmscan.c | 16 +--------------- 8 files changed, 99 insertions(+), 47 deletions(-)