From patchwork Thu Dec 17 01:11:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11978879 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 EF259C4361B for ; Thu, 17 Dec 2020 01:12:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 30FAC22D05 for ; Thu, 17 Dec 2020 01:12:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30FAC22D05 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 3BC286B0036; Wed, 16 Dec 2020 20:12:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3439B6B005D; Wed, 16 Dec 2020 20:12:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20BB46B0068; Wed, 16 Dec 2020 20:12:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 080F36B0036 for ; Wed, 16 Dec 2020 20:12:12 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C38813632 for ; Thu, 17 Dec 2020 01:12:11 +0000 (UTC) X-FDA: 77600998062.16.shoes50_060a1e927430 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id A5D34100E690B for ; Thu, 17 Dec 2020 01:12:11 +0000 (UTC) X-HE-Tag: shoes50_060a1e927430 X-Filterd-Recvd-Size: 5960 Received: from mail-vk1-f177.google.com (mail-vk1-f177.google.com [209.85.221.177]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Dec 2020 01:12:11 +0000 (UTC) Received: by mail-vk1-f177.google.com with SMTP id a6so699728vkb.8 for ; Wed, 16 Dec 2020 17:12:11 -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=YmOnO3qjJFdw5qVil3tlbg5ItfTfI0GfT3/CX7O2nwg=; b=Lz1I9mhbPRe0AdEYaDsAYNeuJZtXudbhCvODGCuFk/k+r2nAFsGR8YOBZliy224d2M u4WQUXEjhdpKQhk/wVameqvT7hAN+kUZ32tQs7fjMm1odUgG+BdBwLLsH2IIoN2XBo8f 9f36iraWi8Zt72D2uHv169v8ib6B7Bf4LtZ7KjB/P0u6h33WXiwSu2H9L4qaq5KNWX00 6AXp8Ke4EziyMxwtEw0/2zfPotFOnF0NyOoAbb+Z8q43OfZ+ub4AFZu7F/+BdgoedtvZ oxHBW6wq/lLzGzFDrW13cmw4qui+UaAB6Hn9jLm9ncYsyFo5CVfrDj52r0iQamMzbz87 a6+w== 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=YmOnO3qjJFdw5qVil3tlbg5ItfTfI0GfT3/CX7O2nwg=; b=EKn0z0afQjCfbsx4Ourr8LoML5FbgG5rwgQAxHOR/VHJOKDYWBkWKUa8e/2UVF0aJu hxVBIm4MVHlXwxETF9eb/UVQrLB861b7eSzi/+8SBRJD5/06Hl3b8VW85KA8HucSeKhm Ky7+TY5C+KCKu0scXrirZWfDP5lk1f4teCdf0qg1efGT+CC6Kk1h38DbAZtx0RKzOFtz 77qj6G27D3cxbxVNp1qtdeVZQsZUNpQ0T7Fam4GM0qbDeCVIHZAfK83P9JO98ONgwAGP LDDIQvcZ6ZeWgAVcC/vmwS3aaOL3vM1biNG44H43TyzglcV8wmhWaGf5K4eUhpI0vxFT 3WcQ== X-Gm-Message-State: AOAM530PLOestE9oyImUQwko4pnAdQL2rKHjHWMqCugsnOKsK/NuoMWL LcsNvVyIHv8YhiXBKu5+f8o= X-Google-Smtp-Source: ABdhPJwy0uTxmy5IZQfU7PF4u9B7yvz4bIGO/p5RVqbI6VwSx+pY2Dfn72dOIjRDpGS6eH747V9Djw== X-Received: by 2002:a1f:2ecd:: with SMTP id u196mr36256109vku.19.1608167530611; Wed, 16 Dec 2020 17:12:10 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id i63sm2900760uad.4.2020.12.16.17.12.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 17:12:09 -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 v13 0/4] xfs: avoid transaction reservation recursion Date: Thu, 17 Dec 2020 09:11:53 +0800 Message-Id: <20201217011157.92549-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 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 reusing 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 v13: - move xfs_trans_context_swap() into patch #3 and set NOFS to the old transaction v12: Per Darrick's suggestion, - add the check before calling xfs_trans_context_clear() in xfs_trans_context_free(). - move t_pflags into xfs_trans_context_swap() v11: - add the warning at the callsite of xfs_trans_context_active() - improve the commit log of patch #2 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 | 26 ++++++++++++-------------- fs/xfs/xfs_trans.h | 37 +++++++++++++++++++++++++++++++++++++ include/linux/sched/mm.h | 23 +++++++++++++++++++++++ mm/vmscan.c | 16 +--------------- 8 files changed, 100 insertions(+), 48 deletions(-)