From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E4AFC47258 for ; Mon, 15 Jan 2024 23:01:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F4296B0071; Mon, 15 Jan 2024 18:01:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 997166B0075; Mon, 15 Jan 2024 18:01:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EA046B0072; Mon, 15 Jan 2024 18:01:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6E9686B006E for ; Mon, 15 Jan 2024 18:01:22 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 246CB4095D for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) X-FDA: 81683068404.06.F4DE0CC Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf16.hostedemail.com (Postfix) with ESMTP id 267F218001E for ; Mon, 15 Jan 2024 23:01:19 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=K8ec4pHT; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf16.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705359680; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yIE/laHa1vtqRcUgCHUsUwlwdeFPdNrUjJJgWMWqUtM=; b=d1twdsvgMgamLKJyDlkeLSHqTFmarrhAqvuWHGsMFCCzo6oTyL5muJTCCDY5peZGrxi/hm 0jB6aVYPM2491TMGVibZcElAMdPGxtrUooCjwCvjLGPCL4t/H1Q1njfEQKySH/Dog3mQh/ /6XCcBOTcpOLdyRvBu24V8r9xbmGB6U= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=K8ec4pHT; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf16.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359680; a=rsa-sha256; cv=none; b=O+wdmprw4Aexjs9Pi3x186MZN7lPCIgynr644pmLKZppfrAjaMvtrM2XagASRc7KgCIM2+ IaWRNU++eZwgkWuhNrMGUc3jRXUhvZbpACuHeo4fbweCysz8nnlT/8IUrro6WMFkMYJyoR PfRm3c+Llfj0eJKg6ytr6g3mTHYED0s= Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-28e35a7432cso1308742a91.1 for ; Mon, 15 Jan 2024 15:01:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359679; x=1705964479; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yIE/laHa1vtqRcUgCHUsUwlwdeFPdNrUjJJgWMWqUtM=; b=K8ec4pHTAvd4Y/3PtpkYn6TNQtJIL9A1uimRv0zcFTv70DqXRwPsh0iOHjABlI/YG+ MtrE+icLSgmeDugjXzY5jcscjVU7oY6Mt+uMVFeN+cCH52X0JgUE82UlItB1B4mlqBmp 9Odkts4s7X3NVW4fNMjZ7LRo1413hTE97siFQZvUFfgV/BMXYtrYd5bHWo7Dl7pbc25x YIGwWxWoVdV1sb2ndbo0S1is16Yx0fjYGUMCg1Hwz8JDHYbPNhRTIYrkrfzPmz3HOLtb 9CnrRI9Nme40LvHjLz8BVHeuPrv2htnHBKC6M9/E0PWKcgeHyStsGL1PyUMvk1bsijdI JO3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359679; x=1705964479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yIE/laHa1vtqRcUgCHUsUwlwdeFPdNrUjJJgWMWqUtM=; b=voLrM+nDkxaRT15t3RdHnOFgv/z2r8RgYKqdhy4X2Pl+10TLpNVH0licNluOeNV3AB JHOy4iaOsvK/xTqphLIXqjiUMwwTZHYPH7BVMNAhSNKP1ftWHxdOIxAMR33SQ7FWTtod F4wLwtDnP0ZCaqtdLbtmEvtn+6PRkD14gT77GlNUsl/IXHdUwsjWabbtSFFXAJ2B4Jqa JhpGcImG/ozvXtO+H/Ta3ujmFF9mbfsUciCUlqttv4Unow1f5DC6t5ilMMe2uqJ++okY R/QhJWs19CqHMWIkFMLomJCHnQWXjmyu09uf7rYM1mQYIAne8K6FsMWTWgrv27mSMjGR EPzA== X-Gm-Message-State: AOJu0Yyci24zUwrxC+unIFG1ZcfL/ODVs7GrUCW2tcF3FqK5QggxBu4k bOrA7AksX8NGqX18wIUzx9DZg0ZDc83a5g== X-Google-Smtp-Source: AGHT+IGiVRblViwM/5At1Ouc6xOrw46C9ZIpYeondQKnQtgKXwfrihweFsqQ2ayKBTUncTlIU/4GWw== X-Received: by 2002:a17:90b:30cb:b0:28d:34e5:38f4 with SMTP id hi11-20020a17090b30cb00b0028d34e538f4mr9124403pjb.43.1705359678991; Mon, 15 Jan 2024 15:01:18 -0800 (PST) Received: from dread.disaster.area (pa49-180-249-6.pa.nsw.optusnet.com.au. [49.180.249.6]) by smtp.gmail.com with ESMTPSA id t16-20020a170902e85000b001d3d8c04331sm8099180plg.64.2024.01.15.15.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 15:01:18 -0800 (PST) Received: from [192.168.253.23] (helo=devoid.disaster.area) by dread.disaster.area with esmtp (Exim 4.96) (envelope-from ) id 1rPVxE-00AtKN-0r; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8g1-36lB; Tue, 16 Jan 2024 10:01:15 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Cc: willy@infradead.org, linux-mm@kvack.org Subject: [PATCH 09/12] xfs: place intent recovery under NOFS allocation context Date: Tue, 16 Jan 2024 09:59:47 +1100 Message-ID: <20240115230113.4080105-10-david@fromorbit.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115230113.4080105-1-david@fromorbit.com> References: <20240115230113.4080105-1-david@fromorbit.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: icao5nsfd3qgkw6hxz6jpbxqkzojbz3d X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 267F218001E X-HE-Tag: 1705359679-449520 X-HE-Meta: U2FsdGVkX18ujDFtpJHRjAYNe9hqv2WfBRBajS0tPr1k5WmJsJ0CFgQgUDkq1SmdjzXhyuyguqtRGHA333ebsfFiUcgM7c8y9qGnLmMTUG7no/AaNXPz//6buT8cAeh3ZLEcXXC5ylNCFhbvdCVQ/8oV8Jg6si54LUlZwVMYDQ4KrLvyMeoOFcpvCalJB2paOGx6bro9CJfsxLIgqqYtWbfm52FVxCkNwVYF9u/d/OU/rjpct74ADJbQB4NWlHS+7vSC2NfVLoY13+u+rSFa6ZUR2A0WgMO0nZNy5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IimE+OrRpRbzgma1f+j0JcIWvxdN7bR7FzAaKDC+auA0aiRv2/nWRw3a0i6W5HQ== 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: List-Subscribe: List-Unsubscribe: From: Dave Chinner When recovery starts processing intents, all of the initial intent allocations are done outside of transaction contexts. That means they need to specifically use GFP_NOFS as we do not want memory reclaim to attempt to run direct reclaim of filesystem objects while we have lots of objects added into deferred operations. Rather than use GFP_NOFS for these specific allocations, just place the entire intent recovery process under NOFS context and we can then just use GFP_KERNEL for these allocations. Signed-off-by: Dave Chinner --- fs/xfs/xfs_attr_item.c | 2 +- fs/xfs/xfs_bmap_item.c | 3 ++- fs/xfs/xfs_log_recover.c | 18 ++++++++++++++---- fs/xfs/xfs_refcount_item.c | 2 +- fs/xfs/xfs_rmap_item.c | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 0bf25a2ba3b6..e14e229fc712 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -513,7 +513,7 @@ xfs_attri_recover_work( return ERR_PTR(error); attr = kzalloc(sizeof(struct xfs_attr_intent) + - sizeof(struct xfs_da_args), GFP_NOFS | __GFP_NOFAIL); + sizeof(struct xfs_da_args), GFP_KERNEL | __GFP_NOFAIL); args = (struct xfs_da_args *)(attr + 1); attr->xattri_da_args = args; diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 029a6a8d0efd..e3c58090e976 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -445,7 +445,8 @@ xfs_bui_recover_work( if (error) return ERR_PTR(error); - bi = kmem_cache_zalloc(xfs_bmap_intent_cache, GFP_NOFS | __GFP_NOFAIL); + bi = kmem_cache_zalloc(xfs_bmap_intent_cache, + GFP_KERNEL | __GFP_NOFAIL); bi->bi_whichfork = (map->me_flags & XFS_BMAP_EXTENT_ATTR_FORK) ? XFS_ATTR_FORK : XFS_DATA_FORK; bi->bi_type = map->me_flags & XFS_BMAP_EXTENT_TYPE_MASK; diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index e9ed43a833af..8c1d260bb9e1 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -3443,12 +3443,19 @@ xlog_recover( * part of recovery so that the root and real-time bitmap inodes can be read in * from disk in between the two stages. This is necessary so that we can free * space in the real-time portion of the file system. + * + * We run this whole process under GFP_NOFS allocation context. We do a + * combination of non-transactional and transactional work, yet we really don't + * want to recurse into the filesystem from direct reclaim during any of this + * processing. This allows all the recovery code run here not to care about the + * memory allocation context it is running in. */ int xlog_recover_finish( struct xlog *log) { - int error; + unsigned int nofs_flags = memalloc_nofs_save(); + int error; error = xlog_recover_process_intents(log); if (error) { @@ -3462,7 +3469,7 @@ xlog_recover_finish( xlog_recover_cancel_intents(log); xfs_alert(log->l_mp, "Failed to recover intents"); xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); - return error; + goto out_error; } /* @@ -3483,7 +3490,7 @@ xlog_recover_finish( if (error < 0) { xfs_alert(log->l_mp, "Failed to clear log incompat features on recovery"); - return error; + goto out_error; } } @@ -3508,9 +3515,12 @@ xlog_recover_finish( * and AIL. */ xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR); + goto out_error; } - return 0; +out_error: + memalloc_nofs_restore(nofs_flags); + return error; } void diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index d850b9685f7f..14919b33e4fe 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -425,7 +425,7 @@ xfs_cui_recover_work( struct xfs_refcount_intent *ri; ri = kmem_cache_alloc(xfs_refcount_intent_cache, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK; ri->ri_startblock = pmap->pe_startblock; ri->ri_blockcount = pmap->pe_len; diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index a40b92ac81e8..e473124e29cc 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -455,7 +455,7 @@ xfs_rui_recover_work( { struct xfs_rmap_intent *ri; - ri = kmem_cache_alloc(xfs_rmap_intent_cache, GFP_NOFS | __GFP_NOFAIL); + ri = kmem_cache_alloc(xfs_rmap_intent_cache, GFP_KERNEL | __GFP_NOFAIL); switch (map->me_flags & XFS_RMAP_EXTENT_TYPE_MASK) { case XFS_RMAP_EXTENT_MAP: -- 2.43.0