From patchwork Mon Jan 15 22:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520261 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 5C031C47258 for ; Mon, 15 Jan 2024 23:01:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BE096B0080; Mon, 15 Jan 2024 18:01:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EEEF26B0081; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A14AD6B0085; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 756716B0082 for ; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3FA52C01F5 for ; Mon, 15 Jan 2024 23:01:25 +0000 (UTC) X-FDA: 81683068530.22.73FCC57 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by imf18.hostedemail.com (Postfix) with ESMTP id 3E43C1C0004 for ; Mon, 15 Jan 2024 23:01:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=Q6lswdMP; spf=pass (imf18.hostedemail.com: domain of david@fromorbit.com designates 209.85.160.48 as permitted sender) smtp.mailfrom=david@fromorbit.com; dmarc=pass (policy=quarantine) header.from=fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705359683; 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=SV9QjzfGsvQbo1gkDdrlKefSvyf8EjT8FJkpSDYyly0=; b=we5jilZwLhRwX8f0HR/7fVWRf1/hMhxcph1zRID4au7lUwEadQ+mAgsCm3mEGQtXpdzOEu zWMAvRQf2cuBlr0k4uPvNSGkHQIzRQw+6LEBBzFi/29RIBuj3QfyUbaGsX9RrkCIGPGH5B ulCCb1dawHlZHsh7UQJ5j1c8/hQYdqA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359683; a=rsa-sha256; cv=none; b=d1qc5KOKlOZCDAwzYZ9dfpMhdVtLNRRQMDEolBnO9fgvIc5MSXcaHiuPjjxKSAPtCJI+DI mO7EaWewgV9Le8y+jO1F+ftvMIjRWA+m18n3iCFyglTz6ytN7LRLdZdzTQzbsXY6jG4gg6 CzarRFz6380P9VzTz2gJA8vMalfeCKY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=Q6lswdMP; spf=pass (imf18.hostedemail.com: domain of david@fromorbit.com designates 209.85.160.48 as permitted sender) smtp.mailfrom=david@fromorbit.com; dmarc=pass (policy=quarantine) header.from=fromorbit.com Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-2045bedb806so8465349fac.3 for ; Mon, 15 Jan 2024 15:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359682; x=1705964482; 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=SV9QjzfGsvQbo1gkDdrlKefSvyf8EjT8FJkpSDYyly0=; b=Q6lswdMPBvMQaHebJ/FaQT504Mh0kM7i3dcegx0KrA7/LmwglOFFwHANMaTw+H3qP/ 6hcCjRSWshrI7Y+hMeSSyeh6Gc6BbSTBFlQA5qEOlXUE5c6Oe0+1uwt6cbXbuPF6j2E4 cNe8/BmeJUXKGKOjqfC6YjqkHa1KAc/H0FkBzCVVgZFrmbVn8PImMPjm8y9lMgNLEqMk EVID1F/Kk6NnorBfWP1+K5U446TKFHf5MmBDM26TEEIVqeptu/fLZuXXGkY3np9+Zj3f IUVE80Sfj9V8zwSPossUo1bFvrydN9w9T2Ep0FtulBRbHc4/Ij3LiMYh00VrQsencFUV NjGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359682; x=1705964482; 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=SV9QjzfGsvQbo1gkDdrlKefSvyf8EjT8FJkpSDYyly0=; b=eUGfhmK8aO8MJsquZ8IHk6RKm1HExcIHIWidL6Dc2czee27DHP/lc1xWORbPVhU2lW LUnwROXAzCRTlcNbvds3SN/Fx+E9sggazHHxLB2gfuaxq/irEcc0IvZR7TYraAbAIA8A P6CxWYkzQJnlxPG8dS5h+D7zhhGrMoAtzb7TrUPxwoqJZh/caddSHWVMNvMvzP8vB/QM GH3oVcwWRC4UskoUPIFVWtUxRID4/GbV2MPej1DpziZ2i6Gx/MSB7SSygoIqEYBsHesF o+YhxfBKSE/Cyu80j/BtnH+XmCIiK3OhmhuKlu0l7mhRzf14GkQ+ntkWP6j1RQDjXJj0 U+7Q== X-Gm-Message-State: AOJu0Yw3M/8+Mff1IJ243e+8aXeMGgREteeBcTi9ezhfDPLu24g/cfq7 taeNatjl12HCjtb0l07hH5UxRr7++wQUbg== X-Google-Smtp-Source: AGHT+IH5YyQYuAbS6UC7fILc/Ang/MLpCQ2O5Fowtke05VgEuDlesHyvrDLX7ibqM9BNUcYWC4ee+g== X-Received: by 2002:a05:6871:514:b0:205:ffca:b185 with SMTP id s20-20020a056871051400b00205ffcab185mr10532971oal.42.1705359682310; Mon, 15 Jan 2024 15:01:22 -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 p26-20020a635b1a000000b005cdb499acd0sm8808054pgb.42.2024.01.15.15.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 15:01:19 -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-00AtJs-02; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8d1-1yWD; 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 01/12] xfs: convert kmem_zalloc() to kzalloc() Date: Tue, 16 Jan 2024 09:59:39 +1100 Message-ID: <20240115230113.4080105-2-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 X-Rspamd-Queue-Id: 3E43C1C0004 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: fqpoetuynhfndsr913ibzoej6u44on4s X-HE-Tag: 1705359683-710665 X-HE-Meta: U2FsdGVkX1/7TwCC5xaTm3qxAgMJsSUJB+csQgd0nW0SGExWantyw7Y4O9TBKBSJo5y/DNFeDWH1wH8KpzSzYvw75Sh9E4sgUIyUzwWsH6WN5B01Kry4IoJVVddC6Ia76c7q/rX9hfUrPWC3naQ9N4dxZjnCOhY9J5+XsY51KJmuEIq2Ucmtw3D+fegOgIO6/1+STtwMNg7PuHMjjkySv90xNIOcJaTbEHJ1pDuEj++XfH88xsoiVbH92xBLz3SrOXj55wJRPJy6vcabqUxsqgxowtAUmFm4qNHcKwxoP4cK+rbOf5h1Scp2S6pX6yAX+aZcRPaKYFIWOJ20epVO/lO+iwecmmaSr9d8bfw5IDuoAq9PBi+bZfgdoXlxGrO9Pd+gDurziwdaZIAOda0t42nZScIn9tVT74CuNxQmoWiwoViRE6MHjYZmzlK4gu1MOw2wRlSacmPmma8uKoVwltuhHMBvXx386gJ+6x5Id0Dm+oHIVgVEYUtM/qYXMvCMPwitG6cbIMu2wewSanWv5YngupSSXb6X7oP6QmzrCa9rkOmb2zolW/P5qqjAsoxUTjEvRiCn8qvsYOvwNBgzoELVcB9asQwHnl7yfAMtZf5Vsr9VP8El2mMgD1Xuu0xtwewO1hzOcAbhFJuOXAYPhuqe2XQ2u6PPGmcJc4UqjmopCZPID2rGfxBzfOXWMQK+V06MCnTbfhR/KrRWUAVFXTskLz0WX8g+kChpsw/qpZZzTirRAhmuxfpVQsjqcgBMHfIElAhCvAW1Kjj39LTm+AfzL03+5i3sgXFklGug87Bp072TFmBHqOltS59ojojw8SLQTycgoGaLFT6h4/vv0mNYUeIOYqMCPO2G3jiSnMT7Gj39rk/39o2qS7r1fDXID6sOltJPSKJ0nxP6pWWiY6CkUWsCu3PzQVhehi5Evs00f3c2Vmam/yplZmmIP3mrh/3zwcAwQRF/A8oLbJD tDSMJ5xo vLyKZ8Us7AiLhtD9ncZKQy66dysuehATPHg6tM5kxQLL+3AEsPIh8cwQ4TE9Wfg2Znvm4qj4c17QrocfAhieRsEDYueNX68xUBqlzd7NpHSWp3YxcWz+I8ucOaW04EsorNYiEasa57nEvia3gaOfQqym/ULWBE29x2a7361Bxu5fX1t/4EZZ6/rMotbJlR8i1CxAa4gavs9rzQ5A7S9+Y0QcqP4NMzLukH/kRQJmu7Zf+IhNodc4Ya7hNT903Ojd2781JmyBhR+OUFb9Qok6UxMA0ckJSZs//akU1dCs/2Us6FOcCiXUYCz7IKe1OIEdwTOSV6fQCh/qeJqgpzXdVU1t1ozzRbiglg0RddpqsCs4gNClNg3zTJJXrIDTMESpfX7okLCxjgNYLrAy/hva14FhZ58Lntw3I7mlUGsHwxO70+eF3ZcZZBdOlyPo9Q0/Mmr+67A5gJAAupAtt8MTNsKSMsDEZWMAQbVF/MEW2zoGIST5ey0l0B26gP8UkR1joVOBh6RWTB+sQa5KIO7bRWrZFqA== 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 There's no reason to keep the kmem_zalloc() around anymore, it's just a thin wrapper around kmalloc(), so lets get rid of it. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/kmem.h | 7 ------- fs/xfs/libxfs/xfs_ag.c | 2 +- fs/xfs/libxfs/xfs_attr_leaf.c | 3 ++- fs/xfs/libxfs/xfs_btree_staging.c | 2 +- fs/xfs/libxfs/xfs_da_btree.c | 5 +++-- fs/xfs/libxfs/xfs_defer.c | 2 +- fs/xfs/libxfs/xfs_dir2.c | 18 +++++++++--------- fs/xfs/libxfs/xfs_iext_tree.c | 12 ++++++++---- fs/xfs/xfs_attr_item.c | 4 ++-- fs/xfs/xfs_buf.c | 6 +++--- fs/xfs/xfs_buf_item.c | 4 ++-- fs/xfs/xfs_error.c | 4 ++-- fs/xfs/xfs_extent_busy.c | 3 ++- fs/xfs/xfs_itable.c | 8 ++++---- fs/xfs/xfs_iwalk.c | 3 ++- fs/xfs/xfs_log.c | 5 +++-- fs/xfs/xfs_log_cil.c | 4 ++-- fs/xfs/xfs_log_recover.c | 10 +++++----- fs/xfs/xfs_mru_cache.c | 7 ++++--- fs/xfs/xfs_qm.c | 3 ++- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 3 ++- fs/xfs/xfs_trans_ail.c | 3 ++- 23 files changed, 64 insertions(+), 58 deletions(-) diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h index b987dc2c6851..bce31182c9e8 100644 --- a/fs/xfs/kmem.h +++ b/fs/xfs/kmem.h @@ -62,13 +62,6 @@ static inline void kmem_free(const void *ptr) kvfree(ptr); } - -static inline void * -kmem_zalloc(size_t size, xfs_km_flags_t flags) -{ - return kmem_alloc(size, flags | KM_ZERO); -} - /* * Zone interfaces */ diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 39d9525270b7..96a6bfd58931 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -381,7 +381,7 @@ xfs_initialize_perag( continue; } - pag = kmem_zalloc(sizeof(*pag), KM_MAYFAIL); + pag = kzalloc(sizeof(*pag), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!pag) { error = -ENOMEM; goto out_unwind_new_pags; diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 6374bf107242..ab4223bf51ee 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -2250,7 +2250,8 @@ xfs_attr3_leaf_unbalance( struct xfs_attr_leafblock *tmp_leaf; struct xfs_attr3_icleaf_hdr tmphdr; - tmp_leaf = kmem_zalloc(state->args->geo->blksize, 0); + tmp_leaf = kzalloc(state->args->geo->blksize, + GFP_KERNEL | __GFP_NOFAIL); /* * Copy the header into the temp leaf so that all the stuff diff --git a/fs/xfs/libxfs/xfs_btree_staging.c b/fs/xfs/libxfs/xfs_btree_staging.c index e276eba87cb1..eff29425fd76 100644 --- a/fs/xfs/libxfs/xfs_btree_staging.c +++ b/fs/xfs/libxfs/xfs_btree_staging.c @@ -406,7 +406,7 @@ xfs_btree_bload_prep_block( /* Allocate a new incore btree root block. */ new_size = bbl->iroot_size(cur, level, nr_this_block, priv); - ifp->if_broot = kmem_zalloc(new_size, 0); + ifp->if_broot = kzalloc(new_size, GFP_KERNEL); ifp->if_broot_bytes = (int)new_size; /* Initialize it and send it out. */ diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 5457188bb4de..73aae6543906 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2518,7 +2518,7 @@ xfs_dabuf_map( int error = 0, nirecs, i; if (nfsb > 1) - irecs = kmem_zalloc(sizeof(irec) * nfsb, KM_NOFS); + irecs = kzalloc(sizeof(irec) * nfsb, GFP_NOFS | __GFP_NOFAIL); nirecs = nfsb; error = xfs_bmapi_read(dp, bno, nfsb, irecs, &nirecs, @@ -2531,7 +2531,8 @@ xfs_dabuf_map( * larger one that needs to be free by the caller. */ if (nirecs > 1) { - map = kmem_zalloc(nirecs * sizeof(struct xfs_buf_map), KM_NOFS); + map = kzalloc(nirecs * sizeof(struct xfs_buf_map), + GFP_NOFS | __GFP_NOFAIL); if (!map) { error = -ENOMEM; goto out_free_irecs; diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 66a17910d021..07d318b1f807 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -979,7 +979,7 @@ xfs_defer_ops_capture( return ERR_PTR(error); /* Create an object to capture the defer ops. */ - dfc = kmem_zalloc(sizeof(*dfc), KM_NOFS); + dfc = kzalloc(sizeof(*dfc), GFP_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&dfc->dfc_list); INIT_LIST_HEAD(&dfc->dfc_dfops); diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index a76673281514..54915a302e96 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -104,10 +104,10 @@ xfs_da_mount( ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT); ASSERT(xfs_dir2_dirblock_bytes(&mp->m_sb) <= XFS_MAX_BLOCKSIZE); - mp->m_dir_geo = kmem_zalloc(sizeof(struct xfs_da_geometry), - KM_MAYFAIL); - mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry), - KM_MAYFAIL); + mp->m_dir_geo = kzalloc(sizeof(struct xfs_da_geometry), + GFP_KERNEL | __GFP_RETRY_MAYFAIL); + mp->m_attr_geo = kzalloc(sizeof(struct xfs_da_geometry), + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!mp->m_dir_geo || !mp->m_attr_geo) { kmem_free(mp->m_dir_geo); kmem_free(mp->m_attr_geo); @@ -236,7 +236,7 @@ xfs_dir_init( if (error) return error; - args = kmem_zalloc(sizeof(*args), KM_NOFS); + args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -273,7 +273,7 @@ xfs_dir_createname( XFS_STATS_INC(dp->i_mount, xs_dir_create); } - args = kmem_zalloc(sizeof(*args), KM_NOFS); + args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -372,7 +372,7 @@ xfs_dir_lookup( * lockdep Doing this avoids having to add a bunch of lockdep class * annotations into the reclaim path for the ilock. */ - args = kmem_zalloc(sizeof(*args), KM_NOFS); + args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len; @@ -441,7 +441,7 @@ xfs_dir_removename( ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); XFS_STATS_INC(dp->i_mount, xs_dir_remove); - args = kmem_zalloc(sizeof(*args), KM_NOFS); + args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -502,7 +502,7 @@ xfs_dir_replace( if (rval) return rval; - args = kmem_zalloc(sizeof(*args), KM_NOFS); + args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); if (!args) return -ENOMEM; diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c index f4e6b200cdf8..4522f3c7a23f 100644 --- a/fs/xfs/libxfs/xfs_iext_tree.c +++ b/fs/xfs/libxfs/xfs_iext_tree.c @@ -398,7 +398,8 @@ static void xfs_iext_grow( struct xfs_ifork *ifp) { - struct xfs_iext_node *node = kmem_zalloc(NODE_SIZE, KM_NOFS); + struct xfs_iext_node *node = kzalloc(NODE_SIZE, + GFP_NOFS | __GFP_NOFAIL); int i; if (ifp->if_height == 1) { @@ -454,7 +455,8 @@ xfs_iext_split_node( int *nr_entries) { struct xfs_iext_node *node = *nodep; - struct xfs_iext_node *new = kmem_zalloc(NODE_SIZE, KM_NOFS); + struct xfs_iext_node *new = kzalloc(NODE_SIZE, + GFP_NOFS | __GFP_NOFAIL); const int nr_move = KEYS_PER_NODE / 2; int nr_keep = nr_move + (KEYS_PER_NODE & 1); int i = 0; @@ -542,7 +544,8 @@ xfs_iext_split_leaf( int *nr_entries) { struct xfs_iext_leaf *leaf = cur->leaf; - struct xfs_iext_leaf *new = kmem_zalloc(NODE_SIZE, KM_NOFS); + struct xfs_iext_leaf *new = kzalloc(NODE_SIZE, + GFP_NOFS | __GFP_NOFAIL); const int nr_move = RECS_PER_LEAF / 2; int nr_keep = nr_move + (RECS_PER_LEAF & 1); int i; @@ -583,7 +586,8 @@ xfs_iext_alloc_root( { ASSERT(ifp->if_bytes == 0); - ifp->if_data = kmem_zalloc(sizeof(struct xfs_iext_rec), KM_NOFS); + ifp->if_data = kzalloc(sizeof(struct xfs_iext_rec), + GFP_NOFS | __GFP_NOFAIL); ifp->if_height = 1; /* now that we have a node step into it */ diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 9e02111bd890..2e454a0d6f19 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -512,8 +512,8 @@ xfs_attri_recover_work( if (error) return ERR_PTR(error); - attr = kmem_zalloc(sizeof(struct xfs_attr_intent) + - sizeof(struct xfs_da_args), KM_NOFS); + attr = kzalloc(sizeof(struct xfs_attr_intent) + + sizeof(struct xfs_da_args), GFP_NOFS | __GFP_NOFAIL); args = (struct xfs_da_args *)(attr + 1); attr->xattri_da_args = args; diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index ec4bd7a24d88..710ea4c97122 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -189,8 +189,8 @@ xfs_buf_get_maps( return 0; } - bp->b_maps = kmem_zalloc(map_count * sizeof(struct xfs_buf_map), - KM_NOFS); + bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map), + GFP_NOFS | __GFP_NOFAIL); if (!bp->b_maps) return -ENOMEM; return 0; @@ -2002,7 +2002,7 @@ xfs_alloc_buftarg( #if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE) ops = &xfs_dax_holder_operations; #endif - btp = kmem_zalloc(sizeof(*btp), KM_NOFS); + btp = kzalloc(sizeof(*btp), GFP_NOFS | __GFP_NOFAIL); btp->bt_mount = mp; btp->bt_bdev_handle = bdev_handle; diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 023d4e0385dd..ec93d34188c8 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -805,8 +805,8 @@ xfs_buf_item_get_format( return; } - bip->bli_formats = kmem_zalloc(count * sizeof(struct xfs_buf_log_format), - 0); + bip->bli_formats = kzalloc(count * sizeof(struct xfs_buf_log_format), + GFP_KERNEL | __GFP_NOFAIL); } STATIC void diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index b2cbbba3e15a..456520d60cd0 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -240,8 +240,8 @@ xfs_errortag_init( { int ret; - mp->m_errortag = kmem_zalloc(sizeof(unsigned int) * XFS_ERRTAG_MAX, - KM_MAYFAIL); + mp->m_errortag = kzalloc(sizeof(unsigned int) * XFS_ERRTAG_MAX, + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!mp->m_errortag) return -ENOMEM; diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c index 2ccde32c9a9e..b90c3dd43e03 100644 --- a/fs/xfs/xfs_extent_busy.c +++ b/fs/xfs/xfs_extent_busy.c @@ -32,7 +32,8 @@ xfs_extent_busy_insert_list( struct rb_node **rbp; struct rb_node *parent = NULL; - new = kmem_zalloc(sizeof(struct xfs_extent_busy), 0); + new = kzalloc(sizeof(struct xfs_extent_busy), + GFP_KERNEL | __GFP_NOFAIL); new->agno = pag->pag_agno; new->bno = bno; new->length = len; diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 14462614fcc8..14211174267a 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -197,8 +197,8 @@ xfs_bulkstat_one( ASSERT(breq->icount == 1); - bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat), - KM_MAYFAIL); + bc.buf = kzalloc(sizeof(struct xfs_bulkstat), + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!bc.buf) return -ENOMEM; @@ -289,8 +289,8 @@ xfs_bulkstat( if (xfs_bulkstat_already_done(breq->mp, breq->startino)) return 0; - bc.buf = kmem_zalloc(sizeof(struct xfs_bulkstat), - KM_MAYFAIL); + bc.buf = kzalloc(sizeof(struct xfs_bulkstat), + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!bc.buf) return -ENOMEM; diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index b3275e8d47b6..8dbb7c054b28 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -663,7 +663,8 @@ xfs_iwalk_threaded( if (xfs_pwork_ctl_want_abort(&pctl)) break; - iwag = kmem_zalloc(sizeof(struct xfs_iwalk_ag), 0); + iwag = kzalloc(sizeof(struct xfs_iwalk_ag), + GFP_KERNEL | __GFP_NOFAIL); iwag->mp = mp; /* diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a1650fc81382..d38cfaadc726 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -1528,7 +1528,7 @@ xlog_alloc_log( int error = -ENOMEM; uint log2_size = 0; - log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); + log = kzalloc(sizeof(struct xlog), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!log) { xfs_warn(mp, "Log allocation failed: No memory!"); goto out; @@ -1605,7 +1605,8 @@ xlog_alloc_log( size_t bvec_size = howmany(log->l_iclog_size, PAGE_SIZE) * sizeof(struct bio_vec); - iclog = kmem_zalloc(sizeof(*iclog) + bvec_size, KM_MAYFAIL); + iclog = kzalloc(sizeof(*iclog) + bvec_size, + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!iclog) goto out_free_iclog; diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 67a99d94701e..3c705f22b0ab 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -100,7 +100,7 @@ xlog_cil_ctx_alloc(void) { struct xfs_cil_ctx *ctx; - ctx = kmem_zalloc(sizeof(*ctx), KM_NOFS); + ctx = kzalloc(sizeof(*ctx), GFP_NOFS | __GFP_NOFAIL); INIT_LIST_HEAD(&ctx->committing); INIT_LIST_HEAD(&ctx->busy_extents.extent_list); INIT_LIST_HEAD(&ctx->log_items); @@ -1747,7 +1747,7 @@ xlog_cil_init( struct xlog_cil_pcp *cilpcp; int cpu; - cil = kmem_zalloc(sizeof(*cil), KM_MAYFAIL); + cil = kzalloc(sizeof(*cil), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!cil) return -ENOMEM; /* diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 1251c81e55f9..4a27ecdbb546 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2057,7 +2057,8 @@ xlog_recover_add_item( { struct xlog_recover_item *item; - item = kmem_zalloc(sizeof(struct xlog_recover_item), 0); + item = kzalloc(sizeof(struct xlog_recover_item), + GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&item->ri_list); list_add_tail(&item->ri_list, head); } @@ -2187,9 +2188,8 @@ xlog_recover_add_to_trans( } item->ri_total = in_f->ilf_size; - item->ri_buf = - kmem_zalloc(item->ri_total * sizeof(xfs_log_iovec_t), - 0); + item->ri_buf = kzalloc(item->ri_total * sizeof(xfs_log_iovec_t), + GFP_KERNEL | __GFP_NOFAIL); } if (item->ri_total <= item->ri_cnt) { @@ -2332,7 +2332,7 @@ xlog_recover_ophdr_to_trans( * This is a new transaction so allocate a new recovery container to * hold the recovery ops that will follow. */ - trans = kmem_zalloc(sizeof(struct xlog_recover), 0); + trans = kzalloc(sizeof(struct xlog_recover), GFP_KERNEL | __GFP_NOFAIL); trans->r_log_tid = tid; trans->r_lsn = be64_to_cpu(rhead->h_lsn); INIT_LIST_HEAD(&trans->r_itemq); diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c index f85e3b07ab44..feae3115617b 100644 --- a/fs/xfs/xfs_mru_cache.c +++ b/fs/xfs/xfs_mru_cache.c @@ -333,13 +333,14 @@ xfs_mru_cache_create( if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count)) return -EINVAL; - if (!(mru = kmem_zalloc(sizeof(*mru), 0))) + mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL); + if (!mru) return -ENOMEM; /* An extra list is needed to avoid reaping up to a grp_time early. */ mru->grp_count = grp_count + 1; - mru->lists = kmem_zalloc(mru->grp_count * sizeof(*mru->lists), 0); - + mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists), + GFP_KERNEL | __GFP_NOFAIL); if (!mru->lists) { err = -ENOMEM; goto exit; diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 94a7932ac570..b9d11376c88a 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -628,7 +628,8 @@ xfs_qm_init_quotainfo( ASSERT(XFS_IS_QUOTA_ON(mp)); - qinf = mp->m_quotainfo = kmem_zalloc(sizeof(struct xfs_quotainfo), 0); + qinf = mp->m_quotainfo = kzalloc(sizeof(struct xfs_quotainfo), + GFP_KERNEL | __GFP_NOFAIL); error = list_lru_init(&qinf->qi_lru); if (error) diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 20ad8086da60..78d0cda60abf 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -143,8 +143,8 @@ xfs_cui_init( ASSERT(nextents > 0); if (nextents > XFS_CUI_MAX_FAST_EXTENTS) - cuip = kmem_zalloc(xfs_cui_log_item_sizeof(nextents), - 0); + cuip = kzalloc(xfs_cui_log_item_sizeof(nextents), + GFP_KERNEL | __GFP_NOFAIL); else cuip = kmem_cache_zalloc(xfs_cui_cache, GFP_KERNEL | __GFP_NOFAIL); diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 79ad0087aeca..31a921fc34b2 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -142,7 +142,8 @@ xfs_rui_init( ASSERT(nextents > 0); if (nextents > XFS_RUI_MAX_FAST_EXTENTS) - ruip = kmem_zalloc(xfs_rui_log_item_sizeof(nextents), 0); + ruip = kzalloc(xfs_rui_log_item_sizeof(nextents), + GFP_KERNEL | __GFP_NOFAIL); else ruip = kmem_cache_zalloc(xfs_rui_cache, GFP_KERNEL | __GFP_NOFAIL); diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 1098452e7f95..5f206cdb40ff 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c @@ -901,7 +901,8 @@ xfs_trans_ail_init( { struct xfs_ail *ailp; - ailp = kmem_zalloc(sizeof(struct xfs_ail), KM_MAYFAIL); + ailp = kzalloc(sizeof(struct xfs_ail), + GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!ailp) return -ENOMEM; From patchwork Mon Jan 15 22:59:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520255 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 D96EFC4707B for ; Mon, 15 Jan 2024 23:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713436B0072; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 68F906B007D; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 440C06B0074; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2F66F6B0075 for ; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ED9961204AA for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) X-FDA: 81683068404.23.2DD9ACF Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf02.hostedemail.com (Postfix) with ESMTP id DAC6680002 for ; Mon, 15 Jan 2024 23:01:19 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=RPc0Smlo; spf=pass (imf02.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=david@fromorbit.com; dmarc=pass (policy=quarantine) header.from=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=PWbtG64sD6BzeK2zveN6cjdFiuTvAXGzco6ErPoMl4w=; b=wWcEujG3WZFDAbQfcltfKbArmKwhUFZTBdYY9/q/2LRvtiNAmiF9U701N3OyHLbwdrD/b0 Iwm/bRLbiR6/UzH/6kHlGv5HoRPSf4icLMellbx9oSXS22wIfdGAyxb7HSRGOx52nGG1JN OIjDCT0gE/pbXrBpDzaF5XrfN/WvQ/Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359680; a=rsa-sha256; cv=none; b=t1gbY3Y80GQio4+3cQHnrIFjX2X2dyv29mEctGpcnjnkNcV073q+B2qbzV7/KVE/EVhZA/ BxEAeN0p2sGj6yK8EAgx5R+7tnBshofdzsgTSZTEONoNth/tJPn1sHTLRRCWObNrNHSKcX tm2nKZbxOeFt5zINL0srA1ZBFzcrP90= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=RPc0Smlo; spf=pass (imf02.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=david@fromorbit.com; dmarc=pass (policy=quarantine) header.from=fromorbit.com Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-28db4f860easo3511769a91.3 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=1705359678; x=1705964478; 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=PWbtG64sD6BzeK2zveN6cjdFiuTvAXGzco6ErPoMl4w=; b=RPc0Smloril/KNpQU/ES6ESylC/q2O1vIxb2ugPvRQ6AAJ+7GNfBYzgh9d/r78UXdx PXEhDTNXrEN+ZH3GPzH1t+0e3RouuMJ1vsSdL1vw7xnR/WFP2gxoTLrPxTxlmF/cXkds qF0EeEsUjFD/GC1LlZrsUgHUVVYCTaeex5wCLdhRXa3lMEqKIQToq6vN9FHglI+KFu8k nTTj0P3P0FnivGmzqcRfIte2dtQU7Ne0p3mK6F5jphs+I+D/baXNrtVKe3yhpnTOJc+1 q8TwEXXS9cGkUaPqXrePitRzW/1QZkSuoLdnroHAycI2lGV04RTTjx+f1OLgoBAOfZ+6 Fcrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359678; x=1705964478; 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=PWbtG64sD6BzeK2zveN6cjdFiuTvAXGzco6ErPoMl4w=; b=s8A5bsMn1fDZmcJw6PqA3cSWfsOQIE0BV8PoNe6HnSi9nfDw0VCxn09jvT/oodSOUU 5R90VFDTdboC6lN+50ySIcSzlH5fwpID+rvRA4gzB0KiYBG+1yKp3kznC8xaCm6/uZ5l geQ7800aXt7lxHWIa5emzf7oQ9e+2Mg+llr2xLbR2GT+Wh7NjNlbGgKSyPz6uai/i83z UorEKHr3Ai/usqRZMav3saOA0ZKu6I76UfEGiHPjqV/IqMQ73vl+fXAgOZD76LskNfIQ ElaaLlgqVcEJlk8EqekWFy5zKbkLENWa33aJzNmbDuaBzq1AEgEOKMNu1XMyFj3V52Bo ryVQ== X-Gm-Message-State: AOJu0YxH2lVVqLOfkej+ctBlFPLUCingQ23ykJJieO0bCNlmm3Vmq5qd kVBWgFXsPozwGU9t08WWPZ6C4DX/N8GQOg== X-Google-Smtp-Source: AGHT+IHzvuZoaCbm5eSl7ojpSx8vkAcqHRsJMQCe+3FzNo0z4XkzqCyZoYBxmeRqTLmj2IAwHX2Rug== X-Received: by 2002:a17:90a:fd0a:b0:28c:891a:48f8 with SMTP id cv10-20020a17090afd0a00b0028c891a48f8mr2722876pjb.17.1705359678611; 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 lf8-20020a170902fb4800b001d5b2967d00sm4882658plb.290.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-00AtJx-0B; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fX-2Ebw; 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 03/12] xfs: move kmem_to_page() Date: Tue, 16 Jan 2024 09:59:41 +1100 Message-ID: <20240115230113.4080105-4-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 X-Stat-Signature: 5a5mmmy6mrt5zxtk64xq7gtpfuz9tm9o X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: DAC6680002 X-Rspam-User: X-HE-Tag: 1705359679-345848 X-HE-Meta: U2FsdGVkX18hbYf6RcZAtKi9r2X9Ksqo9QGK9smfc8vI33oT3EfohmNYAkKV7mCH28qbPqi8u8fEKJqzLmUUjBjMM6K/LOqQ8l42W65L1oSp+p0KIgLsS3iH9nC/sIfyYfZoiimvyLrBJSkjhrjppALuMBwxam+jHI1J68eJlPw16FvhGq0/TvX1ElS3T0ynSZdpEDP6P6J0qTUnvlTlVpEWpD3zzNFyVsMacoSzWI9k7dcKR7RsOEoGryxBNgdb30GAJ8wKpUyCw0J7THPvp1Z7sK9QgB1HPuDz5SgtP31TUKxxalanaYDPFYcHWXdeEbIZ4xgOgFStn8Lb3W+DJ/XkZMXGhSt/kHw6JuNx6owXEuenzuTEClJlSHQfzK2l6e3HFTuFqVYC903vV/FBf2yKHYYFEedfGGvpmle5qigQTTCwdv0dLBw4G677iW61g1sTC8zz+6OywhoZS5wsK7yjycxL23L9jaEoE4Q9Pifm3E9wwKGfZOZtaEvIPX3rb3+aIxRCNBDO4F99F5HJXEl0+Ws2dkePtM/d5kPblYh9ujteYn/YevawqMfmgTcpbyxmbGnMc9mU9yebTKvJbJVcNe2KM3R0nCl7OiKa7qeT/Uj1Dhz24+CWRZtl0lwR9N68tA0cU8thFoMLu0orzB1+kLA1ILOXPNwvZo1HWoEFkPxFyBsuiZ8njpk6Pciuov4fuyS17OUXPTfPE3P0TQqO8R8JATt1hZgHcLFIMsIJfn8095EhbZO28gbJDPZsA/TNJ026sRg50L/1KBiVkRI5F1W0KwxjToFMpoXKpuhzQ235RBOk6WgDuzKOsebAknPK8xp1ZVdimMNYEbSONNQGWReR56sQ36s6AZSGB+zcx4EFb8QLlr4bif6r9GicqItlJxppjCHJO09rrjM8iGbdgkkZ0WVQHPBJuHNGEU0ObQNS+ktF2arjpYm8F2WrgTl/R1DBny39pXjx+YP H/SRuKnQ W4XUFB1QZMKTv2B2ugZbh4QBSJtAGKZZ8Vs/eOV3iqpnp0+6OYLRvUMAOWjbgrM97Js8ARWd1UdEmdKcUf0ieOrg92LA4whnvSAxlrbRuUsIbj/HgDGwClJylukPK2i7MPQvGjNJhdMtC1/95OAV+2lmwB/ZYkTUlEls1u/MmxBodfl/CD4Kw1evn4E+y9/KDaJ44iaWf2VVDGvW4HKuV4Y2jA5RV/onWAym9dGkaeiWSw+1BaK9kRBeZsD7zr0rsVNFnhLXXzbnRkHoG/mGVHy149K25e/8UFf9HpI+w57nTzYlhmRnlKf2PTIhByVpNy6MGn54InMh2Be9Q8q0Io784Y9EKKJUBgK+nzEJRWETNJf2sXrnA/RoUh9MbpXpMZMiPVN4kVoM5dh3VaHGBziGdPGoLw8Og1lqS11uZpwDwoYasxLf6nVMeTLbrVxGQXYV8ymtZkmDsKECq+EnvM5blhg3gW919KqimLGjfL28j5/Y= 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 Move it to the general xfs linux wrapper header file so we can prepare to remove kmem.h Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/kmem.h | 11 ----------- fs/xfs/xfs_linux.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h index 1343f1a6f99b..48e43f29f2a0 100644 --- a/fs/xfs/kmem.h +++ b/fs/xfs/kmem.h @@ -20,15 +20,4 @@ static inline void kmem_free(const void *ptr) kvfree(ptr); } -/* - * Zone interfaces - */ -static inline struct page * -kmem_to_page(void *addr) -{ - if (is_vmalloc_addr(addr)) - return vmalloc_to_page(addr); - return virt_to_page(addr); -} - #endif /* __XFS_SUPPORT_KMEM_H__ */ diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index d7873e0360f0..666618b463c9 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -269,4 +269,15 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count, # define PTR_FMT "%p" #endif +/* + * Helper for IO routines to grab backing pages from allocated kernel memory. + */ +static inline struct page * +kmem_to_page(void *addr) +{ + if (is_vmalloc_addr(addr)) + return vmalloc_to_page(addr); + return virt_to_page(addr); +} + #endif /* __XFS_LINUX__ */ From patchwork Mon Jan 15 22:59:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520254 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 D6EBFC4707B for ; Mon, 15 Jan 2024 23:01:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5061E6B0075; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B8256B0072; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32EF56B0078; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1C1546B0072 for ; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D826D1A08BF for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) X-FDA: 81683068404.25.9A87BF2 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf25.hostedemail.com (Postfix) with ESMTP id E58B9A0005 for ; Mon, 15 Jan 2024 23:01:20 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=C9T3bGtP; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf25.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.175 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359681; a=rsa-sha256; cv=none; b=b6rZfuKdCffFIy6WMVTsXQoK0yUoTRIhncmlpsqfv8SuoyqdPeNw+owiaWt8j8Iaa8NapR 92cSN4JCsQIEaD2WfjPaOIsxyVO3kfnykWRginoLtoOHJJcXzJsZoyUmI5HfOFAJpXz3IG ao7AsQZA9Wp2jm0rlI8PXxqq4UMAdOA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=C9T3bGtP; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf25.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.175 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=1705359681; 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=Y9TwWrvHaBvdVNybXoOWZa9DHgcrJ7OiMVTIbeklwyI=; b=6qyj+yb8viJiTbrpGL5OLBTQ5qZ1sU8s3X2dD3vLyYLz5AjzCLlpmOPurhtR3zuNjC2dI2 QrhAMHy5HYDN7VLC9q0jfRR+cPKLkDPblQ00nWR96hUvKKeULa/07VsGTq5rcuN6VAMem/ VAaQf1i2ijbTc4tjRc+oQEQIFsWPbAM= Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-53fa455cd94so3410181a12.2 for ; Mon, 15 Jan 2024 15:01:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359680; x=1705964480; 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=Y9TwWrvHaBvdVNybXoOWZa9DHgcrJ7OiMVTIbeklwyI=; b=C9T3bGtPlS/gXq7BgF9+u43qHk+JXC0Gbi+dtZja9Jk2EjWrosHn/ymxNnrX+QK0Al ePekyF+Zq4Np7CnItbxOQTnYvgCdXCMsKXxon8QL2HAUgo8DjmeMM/PilwxBiWxnxIsx GkGU4LeQA4HdnP/XU3q8M6Z3lg3MR4ozlm6j14CH2mVdsrZGiCj1+td3u6TUiAfH+dlN lAQvSQhSXKFbXhm5vzP1s4EVWplpUg4IHrw2A9rtcvwQOpL+x+nwiyZzJx6oSkO7gouz UoukOq3Rsub2U3SqdS211e5R/0F/YEQbhbc+RzfmlxYRQj9c2pNMvgA61ypHmHzs+mXE I3Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359680; x=1705964480; 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=Y9TwWrvHaBvdVNybXoOWZa9DHgcrJ7OiMVTIbeklwyI=; b=PTjmmXyKDCXu/oshAeCshUZ167f6fSNFm2IhMRBIzcpFTcTR4gQYDttzY6bFOh6C2M GE4HP5m1oo/ozduppagL74PWGzbDqEc8rFDeqG3RTNNCOPsqCCesz1rEfpufn6WaEXDY lIIol3PD8rMnW60g9/PlJdAdgpzMJResYGjIC98LhHYGDq+ZSFafRqlpFkl7y7QFqQgy BFgaFLIAFYsx+I4eIYhgVmhmuXmWqwvtJQ/yvYL1ITjXC042bPE2fk+K61Ch/iwXW2uP dRo1tC4/lENf4aDQPKP6BNOk8eyLRkSKh+3Upym6GsBERPBdX1PsPdhUOdQecFOO6klR T57w== X-Gm-Message-State: AOJu0YxmzJZZHGaG+U3SPUDBHIyz6k9EHdih6nkAg5ByF01doVZUiA/X GKDZJZEb036t0pO5mnFTOLUxYxT5VbgBPA== X-Google-Smtp-Source: AGHT+IFeCUfFT3a7WOWtHMkWlHPfZ9V+wnzrGrsnuvhU8qp6+MkImBCY8pcnBEb+N6k0lUKy7rtgLQ== X-Received: by 2002:a17:90b:1957:b0:28e:5b0c:74f6 with SMTP id nk23-20020a17090b195700b0028e5b0c74f6mr1007270pjb.34.1705359679764; Mon, 15 Jan 2024 15:01:19 -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 oh6-20020a17090b3a4600b0028cc9afaae9sm10360385pjb.34.2024.01.15.15.01.17 (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-00AtK0-0I; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fc-2Nuf; 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 04/12] xfs: convert kmem_free() for kvmalloc users to kvfree() Date: Tue, 16 Jan 2024 09:59:42 +1100 Message-ID: <20240115230113.4080105-5-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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E58B9A0005 X-Stat-Signature: nz7j45y6bmchik4msk48ncde7bxqb9r9 X-HE-Tag: 1705359680-990975 X-HE-Meta: U2FsdGVkX19n1tIEyT74BKgoQbD8tiva/35420QjpaPW/+OdNHk5yU6Ikcy6HZtenupTncmWeXxz5nKS6mK8vr8ltZQ1fRk1xAo3WcBgYHNAlBWUJvynvUqGJfXDAMHZvRFFk57nsHxp2dkPE0VYjC+f/xmkVR2keJIc89HPpvpNW4IGYhpYo5SRtUQWcv+Adcka+AmThUVa+tybbwmRIptvIQl0O07jReVI7B92Lk6j5F0WyGZnC2ts7BkVrEoAFuWd5mYVTdg2eGN070Ohcs85uy/8zsPdTZi3vFu81TNNUzzUmP7c5UDq6s1Daf4B61bcUCnmrkEddd5M58NhLsYbWP9gGiyhmsFnoZ0LdhYknmqDqQZzPP4VzmPllKlH+Ct/FvllPOI3JYc/uI/y6QTsF9VJNLGzyqWHZmB/IO4UwWBSxq951nX9ZJRXxOOTxVpEVJpvckO6bZdNQAx1SGtRq8v4oGKfcCNE89ykgr568idaPZemDDKXA2D3pr+R2YSVTru0RNHyjfbv6UqFdyhi0MYbagD1wCD1x17CDaTBF3RVMxiDno3YofaBNDbb1QfA17DCvySWsPT7n6IVTcwxlqmSCoKrioWLdEEQkVvjBtYYh3TIyHyhQzSeFaqgVkumG36OyZF0NoIKWejXLjH9UbgZbJGXL4513ZfqXMh0v56RtAALo/m0WjYS5MdCrbbFZFXkygDcurWv/oC6ij+wAKUbZKimK6slRTiflnS/cv7kYsJR01+zziuT1xMI8iXKB83BUz+spPQ/ch8q/D2Cod4UV5gG/ZQ4IJGmmbKRxodq9kCTPDocll3NSmXoQhvFtOmn1a0QlcPDZH0ORmXtTBpddjBD+1j6nBVLK4nmcDceaPU2n8ScM5CB5BhG8vV2HLqtQ2/n07AmDh3G/iW3WaRKl8cebJMhINubnjvYSQ5gL6ukCeuCRqgqR7dTGyXeySYga1VQildVEX/ hm+Rfmcn LnHtcoOwfEKI6Nv8UQ0r4xqPRUP66f0DPV1iIVgUGKYeYIXi93sBGcJ0qn1B4JhyZklgYjA4/zJMmLWr9pp+yJiUsiLFwFOv0nVx2TwXa8wpOmj23q3Ev1Rf8+GyA+6IRpUOwqn8e4g2vdunr/EvBmAAQj7aihD12KcG8EGgFCMCMEygxcZ8w3JZ2qG5e8UmPglYxw5DfYmk2k+CBlSekFJ7Q+Y7KmwRl0KrnaOy8A76y717IDP43unlrKpU84DlGYDCcVrO2CB5ymiPwyTDPTY/bIYN93BFpUv7zhUJfMae92uq0vManpes3QVoXJzZlYsjdo7cDNrkRwLDF4L3Z1xuYpoVWUIWM6toCXhSHOBktXj4jpxm9zo5Gdg2xXZyqGkipebOy4XyssxB6ihVOiyOyKsyC3xXCvy2P/qQhCXb3Gp35P9ZT6QRoCu+y0aPEaI6SS6geHlkpKYbDJie6ghmBEXOJe5a2+eyVkIBOeU/hmmU2NvnIyAIgJQ9GXDsVV7Pzvsf5Dhj9uvklOUgOl1U4dg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.005773, 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 Start getting rid of kmem_free() by converting all the cases where memory can come from vmalloc interfaces to calling kvfree() directly. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_acl.c | 4 ++-- fs/xfs/xfs_attr_item.c | 4 ++-- fs/xfs/xfs_bmap_item.c | 4 ++-- fs/xfs/xfs_buf_item.c | 2 +- fs/xfs/xfs_dquot.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_icreate_item.c | 2 +- fs/xfs/xfs_inode_item.c | 2 +- fs/xfs/xfs_ioctl.c | 2 +- fs/xfs/xfs_log.c | 4 ++-- fs/xfs/xfs_log_cil.c | 2 +- fs/xfs/xfs_log_recover.c | 42 +++++++++++++++++++------------------- fs/xfs/xfs_refcount_item.c | 4 ++-- fs/xfs/xfs_rmap_item.c | 4 ++-- fs/xfs/xfs_rtalloc.c | 6 +++--- 15 files changed, 44 insertions(+), 44 deletions(-) diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 6b840301817a..4bf69c9c088e 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c @@ -167,7 +167,7 @@ xfs_get_acl(struct inode *inode, int type, bool rcu) acl = ERR_PTR(error); } - kmem_free(args.value); + kvfree(args.value); return acl; } @@ -204,7 +204,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) } error = xfs_attr_change(&args); - kmem_free(args.value); + kvfree(args.value); /* * If the attribute didn't exist to start with that's fine. diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 2e454a0d6f19..f7ba80d575d4 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -108,7 +108,7 @@ STATIC void xfs_attri_item_free( struct xfs_attri_log_item *attrip) { - kmem_free(attrip->attri_item.li_lv_shadow); + kvfree(attrip->attri_item.li_lv_shadow); xfs_attri_log_nameval_put(attrip->attri_nameval); kmem_cache_free(xfs_attri_cache, attrip); } @@ -251,7 +251,7 @@ static inline struct xfs_attrd_log_item *ATTRD_ITEM(struct xfs_log_item *lip) STATIC void xfs_attrd_item_free(struct xfs_attrd_log_item *attrdp) { - kmem_free(attrdp->attrd_item.li_lv_shadow); + kvfree(attrdp->attrd_item.li_lv_shadow); kmem_cache_free(xfs_attrd_cache, attrdp); } diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c index 52fb8a148b7d..029a6a8d0efd 100644 --- a/fs/xfs/xfs_bmap_item.c +++ b/fs/xfs/xfs_bmap_item.c @@ -40,7 +40,7 @@ STATIC void xfs_bui_item_free( struct xfs_bui_log_item *buip) { - kmem_free(buip->bui_item.li_lv_shadow); + kvfree(buip->bui_item.li_lv_shadow); kmem_cache_free(xfs_bui_cache, buip); } @@ -201,7 +201,7 @@ xfs_bud_item_release( struct xfs_bud_log_item *budp = BUD_ITEM(lip); xfs_bui_release(budp->bud_buip); - kmem_free(budp->bud_item.li_lv_shadow); + kvfree(budp->bud_item.li_lv_shadow); kmem_cache_free(xfs_bud_cache, budp); } diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index ec93d34188c8..545040c6ae87 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -1044,7 +1044,7 @@ xfs_buf_item_free( struct xfs_buf_log_item *bip) { xfs_buf_item_free_format(bip); - kmem_free(bip->bli_item.li_lv_shadow); + kvfree(bip->bli_item.li_lv_shadow); kmem_cache_free(xfs_buf_item_cache, bip); } diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index a93ad76f23c5..17c82f5e783c 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -53,7 +53,7 @@ xfs_qm_dqdestroy( { ASSERT(list_empty(&dqp->q_lru)); - kmem_free(dqp->q_logitem.qli_item.li_lv_shadow); + kvfree(dqp->q_logitem.qli_item.li_lv_shadow); mutex_destroy(&dqp->q_qlock); XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot); diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 1d1185fca6a5..6062703a2723 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -40,7 +40,7 @@ STATIC void xfs_efi_item_free( struct xfs_efi_log_item *efip) { - kmem_free(efip->efi_item.li_lv_shadow); + kvfree(efip->efi_item.li_lv_shadow); if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS) kmem_free(efip); else @@ -229,7 +229,7 @@ static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip) STATIC void xfs_efd_item_free(struct xfs_efd_log_item *efdp) { - kmem_free(efdp->efd_item.li_lv_shadow); + kvfree(efdp->efd_item.li_lv_shadow); if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS) kmem_free(efdp); else diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c index b05314d48176..4345db501714 100644 --- a/fs/xfs/xfs_icreate_item.c +++ b/fs/xfs/xfs_icreate_item.c @@ -63,7 +63,7 @@ STATIC void xfs_icreate_item_release( struct xfs_log_item *lip) { - kmem_free(ICR_ITEM(lip)->ic_item.li_lv_shadow); + kvfree(ICR_ITEM(lip)->ic_item.li_lv_shadow); kmem_cache_free(xfs_icreate_cache, ICR_ITEM(lip)); } diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 0aee97ba0be8..bfbeafc8e120 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -856,7 +856,7 @@ xfs_inode_item_destroy( ASSERT(iip->ili_item.li_buf == NULL); ip->i_itemp = NULL; - kmem_free(iip->ili_item.li_lv_shadow); + kvfree(iip->ili_item.li_lv_shadow); kmem_cache_free(xfs_ili_cache, iip); } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index f02b6e558af5..45fb169bd819 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -493,7 +493,7 @@ xfs_attrmulti_attr_get( error = -EFAULT; out_kfree: - kmem_free(args.value); + kvfree(args.value); return error; } diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index d38cfaadc726..0009ffbec932 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -1662,7 +1662,7 @@ xlog_alloc_log( out_free_iclog: for (iclog = log->l_iclog; iclog; iclog = prev_iclog) { prev_iclog = iclog->ic_next; - kmem_free(iclog->ic_data); + kvfree(iclog->ic_data); kmem_free(iclog); if (prev_iclog == log->l_iclog) break; @@ -2119,7 +2119,7 @@ xlog_dealloc_log( iclog = log->l_iclog; for (i = 0; i < log->l_iclog_bufs; i++) { next_iclog = iclog->ic_next; - kmem_free(iclog->ic_data); + kvfree(iclog->ic_data); kmem_free(iclog); iclog = next_iclog; } diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 3c705f22b0ab..2c0512916cc9 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -339,7 +339,7 @@ xlog_cil_alloc_shadow_bufs( * the buffer, only the log vector header and the iovec * storage. */ - kmem_free(lip->li_lv_shadow); + kvfree(lip->li_lv_shadow); lv = xlog_kvmalloc(buf_size); memset(lv, 0, xlog_cil_iovec_space(niovecs)); diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index e3bd503edcab..295306ef6959 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -361,7 +361,7 @@ xlog_find_verify_cycle( *new_blk = -1; out: - kmem_free(buffer); + kvfree(buffer); return error; } @@ -477,7 +477,7 @@ xlog_find_verify_log_record( *last_blk = i; out: - kmem_free(buffer); + kvfree(buffer); return error; } @@ -731,7 +731,7 @@ xlog_find_head( goto out_free_buffer; } - kmem_free(buffer); + kvfree(buffer); if (head_blk == log_bbnum) *return_head_blk = 0; else @@ -745,7 +745,7 @@ xlog_find_head( return 0; out_free_buffer: - kmem_free(buffer); + kvfree(buffer); if (error) xfs_warn(log->l_mp, "failed to find log head"); return error; @@ -999,7 +999,7 @@ xlog_verify_tail( "Tail block (0x%llx) overwrite detected. Updated to 0x%llx", orig_tail, *tail_blk); out: - kmem_free(buffer); + kvfree(buffer); return error; } @@ -1046,7 +1046,7 @@ xlog_verify_head( error = xlog_rseek_logrec_hdr(log, *head_blk, *tail_blk, XLOG_MAX_ICLOGS, tmp_buffer, &tmp_rhead_blk, &tmp_rhead, &tmp_wrapped); - kmem_free(tmp_buffer); + kvfree(tmp_buffer); if (error < 0) return error; @@ -1365,7 +1365,7 @@ xlog_find_tail( error = xlog_clear_stale_blocks(log, tail_lsn); done: - kmem_free(buffer); + kvfree(buffer); if (error) xfs_warn(log->l_mp, "failed to locate log tail"); @@ -1399,6 +1399,7 @@ xlog_find_zeroed( xfs_daddr_t new_blk, last_blk, start_blk; xfs_daddr_t num_scan_bblks; int error, log_bbnum = log->l_logBBsize; + int ret = 1; *blk_no = 0; @@ -1413,8 +1414,7 @@ xlog_find_zeroed( first_cycle = xlog_get_cycle(offset); if (first_cycle == 0) { /* completely zeroed log */ *blk_no = 0; - kmem_free(buffer); - return 1; + goto out_free_buffer; } /* check partially zeroed log */ @@ -1424,8 +1424,8 @@ xlog_find_zeroed( last_cycle = xlog_get_cycle(offset); if (last_cycle != 0) { /* log completely written to */ - kmem_free(buffer); - return 0; + ret = 0; + goto out_free_buffer; } /* we have a partially zeroed log */ @@ -1471,10 +1471,10 @@ xlog_find_zeroed( *blk_no = last_blk; out_free_buffer: - kmem_free(buffer); + kvfree(buffer); if (error) return error; - return 1; + return ret; } /* @@ -1583,7 +1583,7 @@ xlog_write_log_records( } out_free_buffer: - kmem_free(buffer); + kvfree(buffer); return error; } @@ -2183,7 +2183,7 @@ xlog_recover_add_to_trans( "bad number of regions (%d) in inode log format", in_f->ilf_size); ASSERT(0); - kmem_free(ptr); + kvfree(ptr); return -EFSCORRUPTED; } @@ -2197,7 +2197,7 @@ xlog_recover_add_to_trans( "log item region count (%d) overflowed size (%d)", item->ri_cnt, item->ri_total); ASSERT(0); - kmem_free(ptr); + kvfree(ptr); return -EFSCORRUPTED; } @@ -2227,7 +2227,7 @@ xlog_recover_free_trans( /* Free the regions in the item. */ list_del(&item->ri_list); for (i = 0; i < item->ri_cnt; i++) - kmem_free(item->ri_buf[i].i_addr); + kvfree(item->ri_buf[i].i_addr); /* Free the item itself */ kmem_free(item->ri_buf); kmem_free(item); @@ -3024,7 +3024,7 @@ xlog_do_recovery_pass( hblks = xlog_logrec_hblks(log, rhead); if (hblks != 1) { - kmem_free(hbp); + kvfree(hbp); hbp = xlog_alloc_buffer(log, hblks); } } else { @@ -3038,7 +3038,7 @@ xlog_do_recovery_pass( return -ENOMEM; dbp = xlog_alloc_buffer(log, BTOBB(h_size)); if (!dbp) { - kmem_free(hbp); + kvfree(hbp); return -ENOMEM; } @@ -3199,9 +3199,9 @@ xlog_do_recovery_pass( } bread_err2: - kmem_free(dbp); + kvfree(dbp); bread_err1: - kmem_free(hbp); + kvfree(hbp); /* * Submit buffers that have been added from the last record processed, diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index 78d0cda60abf..a9b322e23cfb 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -36,7 +36,7 @@ STATIC void xfs_cui_item_free( struct xfs_cui_log_item *cuip) { - kmem_free(cuip->cui_item.li_lv_shadow); + kvfree(cuip->cui_item.li_lv_shadow); if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS) kmem_free(cuip); else @@ -207,7 +207,7 @@ xfs_cud_item_release( struct xfs_cud_log_item *cudp = CUD_ITEM(lip); xfs_cui_release(cudp->cud_cuip); - kmem_free(cudp->cud_item.li_lv_shadow); + kvfree(cudp->cud_item.li_lv_shadow); kmem_cache_free(xfs_cud_cache, cudp); } diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 31a921fc34b2..489ca8c0e1dc 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -36,7 +36,7 @@ STATIC void xfs_rui_item_free( struct xfs_rui_log_item *ruip) { - kmem_free(ruip->rui_item.li_lv_shadow); + kvfree(ruip->rui_item.li_lv_shadow); if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS) kmem_free(ruip); else @@ -206,7 +206,7 @@ xfs_rud_item_release( struct xfs_rud_log_item *rudp = RUD_ITEM(lip); xfs_rui_release(rudp->rud_ruip); - kmem_free(rudp->rud_item.li_lv_shadow); + kvfree(rudp->rud_item.li_lv_shadow); kmem_cache_free(xfs_rud_cache, rudp); } diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 8a8d6197203e..57ed9baaf156 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1059,10 +1059,10 @@ xfs_growfs_rt( */ if (rsum_cache != mp->m_rsum_cache) { if (error) { - kmem_free(mp->m_rsum_cache); + kvfree(mp->m_rsum_cache); mp->m_rsum_cache = rsum_cache; } else { - kmem_free(rsum_cache); + kvfree(rsum_cache); } } @@ -1233,7 +1233,7 @@ void xfs_rtunmount_inodes( struct xfs_mount *mp) { - kmem_free(mp->m_rsum_cache); + kvfree(mp->m_rsum_cache); if (mp->m_rbmip) xfs_irele(mp->m_rbmip); if (mp->m_rsumip) From patchwork Mon Jan 15 22:59:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520262 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 0E087C3DA79 for ; Mon, 15 Jan 2024 23:01:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E32C6B0088; Mon, 15 Jan 2024 18:01:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CBE26B0081; Mon, 15 Jan 2024 18:01:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA6BB6B0088; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AD6C46B0082 for ; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 84E9D1C11EE for ; Mon, 15 Jan 2024 23:01:25 +0000 (UTC) X-FDA: 81683068530.13.25B1D6E Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf28.hostedemail.com (Postfix) with ESMTP id 35D4DC001E for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=Q29jQ82u; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf28.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.180 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=1705359682; 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=sbrQKveFC+6/FmqjzdFkrdSyhzov4tlRlWVIss0ti3A=; b=dHftPqFRR6lE4P3PR2y1F4MdkEUsZO5oOk7KMmhmRgGYw31/xdZ2i+ftB4g6AjJVAksH0K 3olSnLF3STiiEtzEcXckJeOwW6qG7iLxVFDZ13OS1qyA67vqYsX653Mgz/M2Kaz3ddXmMG dshH2CFbI5cW/QYqxaWX9prifOHL5Oo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=Q29jQ82u; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf28.hostedemail.com: domain of david@fromorbit.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359682; a=rsa-sha256; cv=none; b=6i60+7YyMyb/WXjEh3TBup8jYtCZ65nUG4dsta7zTxwvrDPpqHmlTW/Z2VUOLBcKVfIOwb Qf7wYYE+xYfxG49gCkbYLIgPMVEzzwWnWsW0vOdXjjvEJL81T+p/RzYKuqlIVHdN6kExh4 +YvUqP1o7yEIIZuc1ew7p2eWIY4m9GI= Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so3080172a12.1 for ; Mon, 15 Jan 2024 15:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359681; x=1705964481; 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=sbrQKveFC+6/FmqjzdFkrdSyhzov4tlRlWVIss0ti3A=; b=Q29jQ82uuH2bnzdaZlD91FASmbj4d55PqTLkYRSWtd6LDtLz6iu3OyyvhG6J88IzvV oniCF4bBEjVqZ2N8lkCMljrOSymFIv7j9BCuqMC/v/3wEaiJGCxnFoV/N8qzjTSCewD2 Yig5lN/vNYArhG5EUQ8Es29rAuT8Y+3pPAW5hIaljX40gk0JGMViHfZ+SJ2dWKV0EiKf J7zjLwYN4YCVbWB450MJ6WuqGY2iVLuy8Iw+x533kvhb/Sq0hp0jE+ZMOX5P40jAM6t6 rkHXT25TqFpwKH7nt6rDBPCQg5TxhFLAGza024rzVMu7v0XS9zNvV/o/fUKL+KPk4hdU v7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359681; x=1705964481; 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=sbrQKveFC+6/FmqjzdFkrdSyhzov4tlRlWVIss0ti3A=; b=Yca/jq7Vz8uEXBd4VYAvci4mgTSHiMLzAhNKwFZhERfFDkEHPMfx7g9n0xNRtTwsqO ETy5F6oSJhhjihiu6SPv9i2f++HYBwOck3m7XQfGash4Lw69isV4s+/D0IkVAf5JbQHz z7xguEYpMWCCEBZBycqIPjh/CJJ0EYfCCMQZ4zHofcCz4v2VovWIkIa/BX+4VtWhGMbw JSNll3s8Vx7bdYI/G0PseaMBivu29XzddF2ScVKkZrrYVMO9PxLwiFervo5Z9LzGZRLK fRPK0W8ELVXLopeKXbMrf5Z//2GD5L9m9pB7xZJclmegOcAxZ5vVx0dYU8WFnLaAbYb4 r5cw== X-Gm-Message-State: AOJu0Yyj+lF/JV2qqetvW53n0A+rK7fb/JCx0FQbp9vJGWLktDH5u/Ba afq0o3xI7alzazNYeMpL86wG25R8Va5lRFD6+tmXKbIrMQI= X-Google-Smtp-Source: AGHT+IEnSpe81tY1uwtZGZRzXxWPJdaGaXxBuDF5rfQ8QBxqBqFSAibmSBEnW0sZzbyXp5F780lvSw== X-Received: by 2002:a17:90b:1982:b0:28e:16a2:85c with SMTP id mv2-20020a17090b198200b0028e16a2085cmr7039796pjb.12.1705359681002; Mon, 15 Jan 2024 15:01:21 -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 qj7-20020a17090b28c700b0028bcc2a47e9sm12704095pjb.38.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-00AtK4-0U; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fi-2X8i; 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 05/12] xfs: convert remaining kmem_free() to kfree() Date: Tue, 16 Jan 2024 09:59:43 +1100 Message-ID: <20240115230113.4080105-6-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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 35D4DC001E X-Stat-Signature: 5owwchsh9ebkkzzycpmizawfnt65ncqn X-Rspam-User: X-HE-Tag: 1705359682-468969 X-HE-Meta: U2FsdGVkX1/+DF2tjnUu83Doh7oAx7nh4fB0eblIV67wTFTzTqxW6e6zj7kh1gPR4Ym3qnX2Y4gbUJTLl5ybdzSAAXQKe4WjqgVzeE4ZDsY9QScZOlK1v5ytK+3NrXmceS0rCMGc9p7MSoaYbI8vOG7STzxuSatMNU9ZJkSDurQW9IzGpyjCFWJhhHhE2gvUilhykXgq6i7ZFFUsG8i6Y1x3LWAzFxrIcKtLabwHIsf+uM7jb+QyZRTGGdT57c+G3vSZRk/PNHc/lYdo6LaGgkwSfyPdcVOt8Jx6SvoV3xj6Ui0x9hAPUDOt9pNjJpIa/rUrCbX/1950t4wbz5MJKzIDiDzRjYR2UrmvKs8R9WoYss88IaU2/5hHR+wKvOiAIVEgsAQoIZ15fn3rU4AFKYy4XIItecpj0vphrRVCeDc3P7fAdB7SkMFX48Jjy5otcx0LqUO99Lc179QegBoK2EqDEiEHmdauICu/S6hBHYRMlq7lGek/PavBS/e9tI/14keLTxw5I7lFkVCT7sM0jySNpgb+yqCvAd+IFyEvn40je8rnyHr13z3uRRgirRTBnAe3tpI5lvnL7zngyH5HCgySHo/nmddqqy8My0Ux7iqrkMVVto35JH+MNw4U+fqZXSFu6cAzWpxCpb/lkp/iqlwe3aS0RMeC+WUcKdbLOWb0zZw6rOrwd12Pe06cAqpk9CjRfCa1KtPtjiIgEuCUCKxZcbn9PuJaYp+G2eLCMlJVyOWEhuYL11uPGE7dNERln3oEtwgFtfOVeRsh6Oly+sHIX45GhkaJ1BU+AMuFMaF4GZQ/IUDewRzx3Wh5VGD9kWF5ZJxKS+YgOyMKpWJiUZhGwkSZd6NZJls5ijMkKpJQJjDA6NsWEk8R5RlAKcRLflqUYmENe6g0C1WEOKK6d/K1ZX/2zEIPHJbipl2WyiZsxFD1XSTXbqexk38PYbi4oN7UIMAsA88yoEJ6MJP 6ChAH2i8 6v5ZBLPW+Q3TJlFHOhxVhvMUmvxkZM5wB2I2uXVyjFJJXLTzVTrUe4S74mqxKp6L+XbpZJL2lz9e+BvqBqOwPxgKhCvp6tkC3v4XSGWyBJU8PJtAHyI8RRMS0H1UiOdY6XKgB9Hxv+2XTI8seeAJamfKYytSn2d6yMy6RJcFhS5xtEka/+RKKy5YMrXSbPEwy7RAEevqoSfXOqjjJnqeS1pbNPU7CkI/Lm5xXtk/POzLzA8TD7EMJtF5OIg== 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 The remaining callers of kmem_free() are freeing heap memory, so we can convert them directly to kfree() and get rid of kmem_free() altogether. This conversion was done with: $ for f in `git grep -l kmem_free fs/xfs`; do > sed -i s/kmem_free/kfree/ $f > done $ Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/kmem.h | 23 ----------------------- fs/xfs/libxfs/xfs_ag.c | 6 +++--- fs/xfs/libxfs/xfs_attr_leaf.c | 8 ++++---- fs/xfs/libxfs/xfs_btree.c | 2 +- fs/xfs/libxfs/xfs_btree_staging.c | 4 ++-- fs/xfs/libxfs/xfs_da_btree.c | 10 +++++----- fs/xfs/libxfs/xfs_defer.c | 4 ++-- fs/xfs/libxfs/xfs_dir2.c | 18 +++++++++--------- fs/xfs/libxfs/xfs_dir2_block.c | 4 ++-- fs/xfs/libxfs/xfs_dir2_sf.c | 8 ++++---- fs/xfs/libxfs/xfs_iext_tree.c | 8 ++++---- fs/xfs/libxfs/xfs_inode_fork.c | 6 +++--- fs/xfs/scrub/cow_repair.c | 2 +- fs/xfs/xfs_attr_item.c | 2 +- fs/xfs/xfs_attr_list.c | 4 ++-- fs/xfs/xfs_buf.c | 12 ++++++------ fs/xfs/xfs_buf_item.c | 2 +- fs/xfs/xfs_buf_item_recover.c | 6 +++--- fs/xfs/xfs_discard.c | 2 +- fs/xfs/xfs_error.c | 4 ++-- fs/xfs/xfs_extent_busy.c | 2 +- fs/xfs/xfs_extfree_item.c | 4 ++-- fs/xfs/xfs_filestream.c | 4 ++-- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_inode_item_recover.c | 2 +- fs/xfs/xfs_ioctl.c | 6 +++--- fs/xfs/xfs_iops.c | 2 +- fs/xfs/xfs_itable.c | 4 ++-- fs/xfs/xfs_iwalk.c | 4 ++-- fs/xfs/xfs_linux.h | 3 +-- fs/xfs/xfs_log.c | 8 ++++---- fs/xfs/xfs_log_cil.c | 14 +++++++------- fs/xfs/xfs_log_recover.c | 6 +++--- fs/xfs/xfs_mount.c | 2 +- fs/xfs/xfs_mru_cache.c | 8 ++++---- fs/xfs/xfs_qm.c | 6 +++--- fs/xfs/xfs_refcount_item.c | 2 +- fs/xfs/xfs_rmap_item.c | 2 +- fs/xfs/xfs_rtalloc.c | 2 +- fs/xfs/xfs_super.c | 2 +- fs/xfs/xfs_trans_ail.c | 4 ++-- 41 files changed, 101 insertions(+), 125 deletions(-) delete mode 100644 fs/xfs/kmem.h diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h deleted file mode 100644 index 48e43f29f2a0..000000000000 --- a/fs/xfs/kmem.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2000-2005 Silicon Graphics, Inc. - * All Rights Reserved. - */ -#ifndef __XFS_SUPPORT_KMEM_H__ -#define __XFS_SUPPORT_KMEM_H__ - -#include -#include -#include -#include - -/* - * General memory allocation interfaces - */ - -static inline void kmem_free(const void *ptr) -{ - kvfree(ptr); -} - -#endif /* __XFS_SUPPORT_KMEM_H__ */ diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 96a6bfd58931..937ea48d5cc0 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -241,7 +241,7 @@ __xfs_free_perag( struct xfs_perag *pag = container_of(head, struct xfs_perag, rcu_head); ASSERT(!delayed_work_pending(&pag->pag_blockgc_work)); - kmem_free(pag); + kfree(pag); } /* @@ -353,7 +353,7 @@ xfs_free_unused_perag_range( break; xfs_buf_hash_destroy(pag); xfs_defer_drain_free(&pag->pag_intents_drain); - kmem_free(pag); + kfree(pag); } } @@ -453,7 +453,7 @@ xfs_initialize_perag( radix_tree_delete(&mp->m_perag_tree, index); spin_unlock(&mp->m_perag_lock); out_free_pag: - kmem_free(pag); + kfree(pag); out_unwind_new_pags: /* unwind any prior newly initialized pags */ xfs_free_unused_perag_range(mp, first_initialised, agcount); diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 033382cf514d..192d9938a231 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -923,7 +923,7 @@ xfs_attr_shortform_to_leaf( } error = 0; out: - kmem_free(tmpbuffer); + kfree(tmpbuffer); return error; } @@ -1124,7 +1124,7 @@ xfs_attr3_leaf_to_shortform( error = 0; out: - kmem_free(tmpbuffer); + kfree(tmpbuffer); return error; } @@ -1570,7 +1570,7 @@ xfs_attr3_leaf_compact( */ xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1); - kmem_free(tmpbuffer); + kfree(tmpbuffer); } /* @@ -2290,7 +2290,7 @@ xfs_attr3_leaf_unbalance( } memcpy(save_leaf, tmp_leaf, state->args->geo->blksize); savehdr = tmphdr; /* struct copy */ - kmem_free(tmp_leaf); + kfree(tmp_leaf); } xfs_attr3_leaf_hdr_to_disk(state->args->geo, save_leaf, &savehdr); diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index ea8d3659df20..1adfc35c99c9 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -451,7 +451,7 @@ xfs_btree_del_cursor( ASSERT(cur->bc_btnum != XFS_BTNUM_BMAP || cur->bc_ino.allocated == 0 || xfs_is_shutdown(cur->bc_mp) || error != 0); if (unlikely(cur->bc_flags & XFS_BTREE_STAGING)) - kmem_free(cur->bc_ops); + kfree(cur->bc_ops); if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS) && cur->bc_ag.pag) xfs_perag_put(cur->bc_ag.pag); kmem_cache_free(cur->bc_cache, cur); diff --git a/fs/xfs/libxfs/xfs_btree_staging.c b/fs/xfs/libxfs/xfs_btree_staging.c index 065e4a00a2f4..961f6b898f4b 100644 --- a/fs/xfs/libxfs/xfs_btree_staging.c +++ b/fs/xfs/libxfs/xfs_btree_staging.c @@ -171,7 +171,7 @@ xfs_btree_commit_afakeroot( trace_xfs_btree_commit_afakeroot(cur); - kmem_free((void *)cur->bc_ops); + kfree((void *)cur->bc_ops); cur->bc_ag.agbp = agbp; cur->bc_ops = ops; cur->bc_flags &= ~XFS_BTREE_STAGING; @@ -254,7 +254,7 @@ xfs_btree_commit_ifakeroot( trace_xfs_btree_commit_ifakeroot(cur); - kmem_free((void *)cur->bc_ops); + kfree((void *)cur->bc_ops); cur->bc_ino.ifake = NULL; cur->bc_ino.whichfork = whichfork; cur->bc_ops = ops; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 331b9251b185..3383b4525381 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2220,7 +2220,7 @@ xfs_da_grow_inode_int( out_free_map: if (mapp != &map) - kmem_free(mapp); + kfree(mapp); return error; } @@ -2559,7 +2559,7 @@ xfs_dabuf_map( *nmaps = nirecs; out_free_irecs: if (irecs != &irec) - kmem_free(irecs); + kfree(irecs); return error; invalid_mapping: @@ -2615,7 +2615,7 @@ xfs_da_get_buf( out_free: if (mapp != &map) - kmem_free(mapp); + kfree(mapp); return error; } @@ -2656,7 +2656,7 @@ xfs_da_read_buf( *bpp = bp; out_free: if (mapp != &map) - kmem_free(mapp); + kfree(mapp); return error; } @@ -2687,7 +2687,7 @@ xfs_da_reada_buf( out_free: if (mapp != &map) - kmem_free(mapp); + kfree(mapp); return error; } diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 07d318b1f807..75689c151a54 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -1038,7 +1038,7 @@ xfs_defer_ops_capture_abort( for (i = 0; i < dfc->dfc_held.dr_inos; i++) xfs_irele(dfc->dfc_held.dr_ip[i]); - kmem_free(dfc); + kfree(dfc); } /* @@ -1114,7 +1114,7 @@ xfs_defer_ops_continue( list_splice_init(&dfc->dfc_dfops, &tp->t_dfops); tp->t_flags |= dfc->dfc_tpflags; - kmem_free(dfc); + kfree(dfc); } /* Release the resources captured and continued during recovery. */ diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 370d67300455..e60aa8f8d0a7 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -109,8 +109,8 @@ xfs_da_mount( mp->m_attr_geo = kzalloc(sizeof(struct xfs_da_geometry), GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (!mp->m_dir_geo || !mp->m_attr_geo) { - kmem_free(mp->m_dir_geo); - kmem_free(mp->m_attr_geo); + kfree(mp->m_dir_geo); + kfree(mp->m_attr_geo); return -ENOMEM; } @@ -178,8 +178,8 @@ void xfs_da_unmount( struct xfs_mount *mp) { - kmem_free(mp->m_dir_geo); - kmem_free(mp->m_attr_geo); + kfree(mp->m_dir_geo); + kfree(mp->m_attr_geo); } /* @@ -244,7 +244,7 @@ xfs_dir_init( args->dp = dp; args->trans = tp; error = xfs_dir2_sf_create(args, pdp->i_ino); - kmem_free(args); + kfree(args); return error; } @@ -313,7 +313,7 @@ xfs_dir_createname( rval = xfs_dir2_node_addname(args); out_free: - kmem_free(args); + kfree(args); return rval; } @@ -419,7 +419,7 @@ xfs_dir_lookup( } out_free: xfs_iunlock(dp, lock_mode); - kmem_free(args); + kfree(args); return rval; } @@ -477,7 +477,7 @@ xfs_dir_removename( else rval = xfs_dir2_node_removename(args); out_free: - kmem_free(args); + kfree(args); return rval; } @@ -538,7 +538,7 @@ xfs_dir_replace( else rval = xfs_dir2_node_replace(args); out_free: - kmem_free(args); + kfree(args); return rval; } diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 506c65caaec5..fde46081a824 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c @@ -1253,7 +1253,7 @@ xfs_dir2_sf_to_block( sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep); } /* Done with the temporary buffer */ - kmem_free(sfp); + kfree(sfp); /* * Sort the leaf entries by hash value. */ @@ -1268,6 +1268,6 @@ xfs_dir2_sf_to_block( xfs_dir3_data_check(dp, bp); return 0; out_free: - kmem_free(sfp); + kfree(sfp); return error; } diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 7b1f41cff9e0..17a20384c8b7 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c @@ -350,7 +350,7 @@ xfs_dir2_block_to_sf( xfs_dir2_sf_check(args); out: xfs_trans_log_inode(args->trans, dp, logflags); - kmem_free(sfp); + kfree(sfp); return error; } @@ -576,7 +576,7 @@ xfs_dir2_sf_addname_hard( sfep = xfs_dir2_sf_nextentry(mp, sfp, sfep); memcpy(sfep, oldsfep, old_isize - nbytes); } - kmem_free(buf); + kfree(buf); dp->i_disk_size = new_isize; xfs_dir2_sf_check(args); } @@ -1190,7 +1190,7 @@ xfs_dir2_sf_toino4( /* * Clean up the inode. */ - kmem_free(buf); + kfree(buf); dp->i_disk_size = newsize; xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); } @@ -1262,7 +1262,7 @@ xfs_dir2_sf_toino8( /* * Clean up the inode. */ - kmem_free(buf); + kfree(buf); dp->i_disk_size = newsize; xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); } diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c index 4522f3c7a23f..16f18b08fe4c 100644 --- a/fs/xfs/libxfs/xfs_iext_tree.c +++ b/fs/xfs/libxfs/xfs_iext_tree.c @@ -747,7 +747,7 @@ xfs_iext_remove_node( again: ASSERT(node->ptrs[pos]); ASSERT(node->ptrs[pos] == victim); - kmem_free(victim); + kfree(victim); nr_entries = xfs_iext_node_nr_entries(node, pos) - 1; offset = node->keys[0]; @@ -793,7 +793,7 @@ xfs_iext_remove_node( ASSERT(node == ifp->if_data); ifp->if_data = node->ptrs[0]; ifp->if_height--; - kmem_free(node); + kfree(node); } } @@ -867,7 +867,7 @@ xfs_iext_free_last_leaf( struct xfs_ifork *ifp) { ifp->if_height--; - kmem_free(ifp->if_data); + kfree(ifp->if_data); ifp->if_data = NULL; } @@ -1048,7 +1048,7 @@ xfs_iext_destroy_node( } } - kmem_free(node); + kfree(node); } void diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index f3cf7f933e15..f6d5b86b608d 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -471,7 +471,7 @@ xfs_iroot_realloc( (int)new_size); memcpy(np, op, new_max * (uint)sizeof(xfs_fsblock_t)); } - kmem_free(ifp->if_broot); + kfree(ifp->if_broot); ifp->if_broot = new_broot; ifp->if_broot_bytes = (int)new_size; if (ifp->if_broot) @@ -525,13 +525,13 @@ xfs_idestroy_fork( struct xfs_ifork *ifp) { if (ifp->if_broot != NULL) { - kmem_free(ifp->if_broot); + kfree(ifp->if_broot); ifp->if_broot = NULL; } switch (ifp->if_format) { case XFS_DINODE_FMT_LOCAL: - kmem_free(ifp->if_data); + kfree(ifp->if_data); ifp->if_data = NULL; break; case XFS_DINODE_FMT_EXTENTS: diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c index 1e82c727af8e..4de3f0f40f48 100644 --- a/fs/xfs/scrub/cow_repair.c +++ b/fs/xfs/scrub/cow_repair.c @@ -609,6 +609,6 @@ xrep_bmap_cow( out_bitmap: xfsb_bitmap_destroy(&xc->old_cowfork_fsblocks); xoff_bitmap_destroy(&xc->bad_fileoffs); - kmem_free(xc); + kfree(xc); return error; } diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index f7ba80d575d4..2a142cefdc3d 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -386,7 +386,7 @@ xfs_attr_free_item( xfs_da_state_free(attr->xattri_da_state); xfs_attri_log_nameval_put(attr->xattri_nameval); if (attr->xattri_da_args->op_flags & XFS_DA_OP_RECOVERY) - kmem_free(attr); + kfree(attr); else kmem_cache_free(xfs_attr_intent_cache, attr); } diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 5f7a44d21cc9..0318d768520a 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -124,7 +124,7 @@ xfs_attr_shortform_list( XFS_ERRLEVEL_LOW, context->dp->i_mount, sfe, sizeof(*sfe)); - kmem_free(sbuf); + kfree(sbuf); return -EFSCORRUPTED; } @@ -188,7 +188,7 @@ xfs_attr_shortform_list( cursor->offset++; } out: - kmem_free(sbuf); + kfree(sbuf); return error; } diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index c348af806616..a09ffbbb0dda 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -204,7 +204,7 @@ xfs_buf_free_maps( struct xfs_buf *bp) { if (bp->b_maps != &bp->__b_map) { - kmem_free(bp->b_maps); + kfree(bp->b_maps); bp->b_maps = NULL; } } @@ -289,7 +289,7 @@ xfs_buf_free_pages( mm_account_reclaimed_pages(bp->b_page_count); if (bp->b_pages != bp->b_page_array) - kmem_free(bp->b_pages); + kfree(bp->b_pages); bp->b_pages = NULL; bp->b_flags &= ~_XBF_PAGES; } @@ -315,7 +315,7 @@ xfs_buf_free( if (bp->b_flags & _XBF_PAGES) xfs_buf_free_pages(bp); else if (bp->b_flags & _XBF_KMEM) - kmem_free(bp->b_addr); + kfree(bp->b_addr); call_rcu(&bp->b_rcu, xfs_buf_free_callback); } @@ -339,7 +339,7 @@ xfs_buf_alloc_kmem( if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) != ((unsigned long)bp->b_addr & PAGE_MASK)) { /* b_addr spans two pages - use alloc_page instead */ - kmem_free(bp->b_addr); + kfree(bp->b_addr); bp->b_addr = NULL; return -ENOMEM; } @@ -1953,7 +1953,7 @@ xfs_free_buftarg( if (btp->bt_bdev != btp->bt_mount->m_super->s_bdev) bdev_release(btp->bt_bdev_handle); - kmem_free(btp); + kfree(btp); } int @@ -2045,7 +2045,7 @@ xfs_alloc_buftarg( error_lru: list_lru_destroy(&btp->bt_lru); error_free: - kmem_free(btp); + kfree(btp); return NULL; } diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index 545040c6ae87..43031842341a 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c @@ -814,7 +814,7 @@ xfs_buf_item_free_format( struct xfs_buf_log_item *bip) { if (bip->bli_formats != &bip->__bli_format) { - kmem_free(bip->bli_formats); + kfree(bip->bli_formats); bip->bli_formats = NULL; } } diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c index 34776f4c05ac..09e893cf563c 100644 --- a/fs/xfs/xfs_buf_item_recover.c +++ b/fs/xfs/xfs_buf_item_recover.c @@ -129,7 +129,7 @@ xlog_put_buffer_cancelled( if (--bcp->bc_refcount == 0) { list_del(&bcp->bc_list); - kmem_free(bcp); + kfree(bcp); } return true; } @@ -1062,10 +1062,10 @@ xlog_free_buf_cancel_table( &log->l_buf_cancel_table[i], struct xfs_buf_cancel, bc_list))) { list_del(&bc->bc_list); - kmem_free(bc); + kfree(bc); } } - kmem_free(log->l_buf_cancel_table); + kfree(log->l_buf_cancel_table); log->l_buf_cancel_table = NULL; } diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index d5787991bb5b..8539f5c9a774 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c @@ -79,7 +79,7 @@ xfs_discard_endio_work( container_of(work, struct xfs_busy_extents, endio_work); xfs_extent_busy_clear(extents->mount, &extents->extent_list, false); - kmem_free(extents->owner); + kfree(extents->owner); } /* diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index 456520d60cd0..7ad0e92c6b5b 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c @@ -248,7 +248,7 @@ xfs_errortag_init( ret = xfs_sysfs_init(&mp->m_errortag_kobj, &xfs_errortag_ktype, &mp->m_kobj, "errortag"); if (ret) - kmem_free(mp->m_errortag); + kfree(mp->m_errortag); return ret; } @@ -257,7 +257,7 @@ xfs_errortag_del( struct xfs_mount *mp) { xfs_sysfs_del(&mp->m_errortag_kobj); - kmem_free(mp->m_errortag); + kfree(mp->m_errortag); } static bool diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c index b90c3dd43e03..56cfa1498571 100644 --- a/fs/xfs/xfs_extent_busy.c +++ b/fs/xfs/xfs_extent_busy.c @@ -531,7 +531,7 @@ xfs_extent_busy_clear_one( } list_del_init(&busyp->list); - kmem_free(busyp); + kfree(busyp); } static void diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index 6062703a2723..8c382f092332 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c @@ -42,7 +42,7 @@ xfs_efi_item_free( { kvfree(efip->efi_item.li_lv_shadow); if (efip->efi_format.efi_nextents > XFS_EFI_MAX_FAST_EXTENTS) - kmem_free(efip); + kfree(efip); else kmem_cache_free(xfs_efi_cache, efip); } @@ -231,7 +231,7 @@ xfs_efd_item_free(struct xfs_efd_log_item *efdp) { kvfree(efdp->efd_item.li_lv_shadow); if (efdp->efd_format.efd_nextents > XFS_EFD_MAX_FAST_EXTENTS) - kmem_free(efdp); + kfree(efdp); else kmem_cache_free(xfs_efd_cache, efdp); } diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c index e2a3c8d3fe4f..e3aaa0555597 100644 --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c @@ -44,7 +44,7 @@ xfs_fstrm_free_func( atomic_dec(&pag->pagf_fstrms); xfs_perag_rele(pag); - kmem_free(item); + kfree(item); } /* @@ -326,7 +326,7 @@ xfs_filestream_create_association( out_free_item: xfs_perag_rele(item->pag); - kmem_free(item); + kfree(item); out_put_fstrms: atomic_dec(&args->pag->pagf_fstrms); return 0; diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 1fd94958aa97..37ec247edc13 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -671,7 +671,7 @@ xfs_lookup( out_free_name: if (ci_name) - kmem_free(ci_name->name); + kfree(ci_name->name); out_unlock: *ipp = NULL; return error; @@ -2378,7 +2378,7 @@ xfs_ifree( * already been freed by xfs_attr_inactive. */ if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { - kmem_free(ip->i_df.if_data); + kfree(ip->i_df.if_data); ip->i_df.if_data = NULL; ip->i_df.if_bytes = 0; } diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c index 5d7b937179a0..dbdab4ce7c44 100644 --- a/fs/xfs/xfs_inode_item_recover.c +++ b/fs/xfs/xfs_inode_item_recover.c @@ -554,7 +554,7 @@ xlog_recover_inode_commit_pass2( xfs_buf_relse(bp); error: if (need_free) - kmem_free(in_f); + kfree(in_f); return error; } diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 45fb169bd819..7eeebcb6b925 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -435,7 +435,7 @@ xfs_ioc_attr_list( copy_to_user(ucursor, &context.cursor, sizeof(context.cursor))) error = -EFAULT; out_free: - kmem_free(buffer); + kfree(buffer); return error; } @@ -1506,7 +1506,7 @@ xfs_ioc_getbmap( error = 0; out_free_buf: - kmem_free(buf); + kfree(buf); return error; } @@ -1636,7 +1636,7 @@ xfs_ioc_getfsmap( } out_free: - kmem_free(recs); + kfree(recs); return error; } diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index a0d77f5f512e..be102fd49560 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -346,7 +346,7 @@ xfs_vn_ci_lookup( dname.name = ci_name.name; dname.len = ci_name.len; dentry = d_add_ci(dentry, VFS_I(ip), &dname); - kmem_free(ci_name.name); + kfree(ci_name.name); return dentry; } diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 14211174267a..95fc31b9f87d 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c @@ -214,7 +214,7 @@ xfs_bulkstat_one( breq->startino, &bc); xfs_trans_cancel(tp); out: - kmem_free(bc.buf); + kfree(bc.buf); /* * If we reported one inode to userspace then we abort because we hit @@ -309,7 +309,7 @@ xfs_bulkstat( xfs_bulkstat_iwalk, breq->icount, &bc); xfs_trans_cancel(tp); out: - kmem_free(bc.buf); + kfree(bc.buf); /* * We found some inodes, so clear the error status and return them. diff --git a/fs/xfs/xfs_iwalk.c b/fs/xfs/xfs_iwalk.c index 5dd622aa54c5..6d2eb6364867 100644 --- a/fs/xfs/xfs_iwalk.c +++ b/fs/xfs/xfs_iwalk.c @@ -172,7 +172,7 @@ STATIC void xfs_iwalk_free( struct xfs_iwalk_ag *iwag) { - kmem_free(iwag->recs); + kfree(iwag->recs); iwag->recs = NULL; } @@ -627,7 +627,7 @@ xfs_iwalk_ag_work( xfs_iwalk_free(iwag); out: xfs_perag_put(iwag->pag); - kmem_free(iwag); + kfree(iwag); return error; } diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 666618b463c9..caccb7f76690 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h @@ -20,8 +20,6 @@ typedef __u32 xfs_dev_t; typedef __u32 xfs_nlink_t; #include "xfs_types.h" - -#include "kmem.h" #include "mrlock.h" #include @@ -30,6 +28,7 @@ typedef __u32 xfs_nlink_t; #include #include #include +#include #include #include #include diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0009ffbec932..ee39639bb92b 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -1663,12 +1663,12 @@ xlog_alloc_log( for (iclog = log->l_iclog; iclog; iclog = prev_iclog) { prev_iclog = iclog->ic_next; kvfree(iclog->ic_data); - kmem_free(iclog); + kfree(iclog); if (prev_iclog == log->l_iclog) break; } out_free_log: - kmem_free(log); + kfree(log); out: return ERR_PTR(error); } /* xlog_alloc_log */ @@ -2120,13 +2120,13 @@ xlog_dealloc_log( for (i = 0; i < log->l_iclog_bufs; i++) { next_iclog = iclog->ic_next; kvfree(iclog->ic_data); - kmem_free(iclog); + kfree(iclog); iclog = next_iclog; } log->l_mp->m_log = NULL; destroy_workqueue(log->l_ioend_workqueue); - kmem_free(log); + kfree(log); } /* diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 2c0512916cc9..815a2181004c 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -703,7 +703,7 @@ xlog_cil_free_logvec( while (!list_empty(lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list); list_del_init(&lv->lv_list); - kmem_free(lv); + kfree(lv); } } @@ -753,7 +753,7 @@ xlog_cil_committed( return; } - kmem_free(ctx); + kfree(ctx); } void @@ -1339,7 +1339,7 @@ xlog_cil_push_work( out_skip: up_write(&cil->xc_ctx_lock); xfs_log_ticket_put(new_ctx->ticket); - kmem_free(new_ctx); + kfree(new_ctx); return; out_abort_free_ticket: @@ -1533,7 +1533,7 @@ xlog_cil_process_intents( set_bit(XFS_LI_WHITEOUT, &ilip->li_flags); trace_xfs_cil_whiteout_mark(ilip); len += ilip->li_lv->lv_bytes; - kmem_free(ilip->li_lv); + kfree(ilip->li_lv); ilip->li_lv = NULL; xfs_trans_del_item(lip); @@ -1786,7 +1786,7 @@ xlog_cil_init( out_destroy_wq: destroy_workqueue(cil->xc_push_wq); out_destroy_cil: - kmem_free(cil); + kfree(cil); return -ENOMEM; } @@ -1799,12 +1799,12 @@ xlog_cil_destroy( if (cil->xc_ctx) { if (cil->xc_ctx->ticket) xfs_log_ticket_put(cil->xc_ctx->ticket); - kmem_free(cil->xc_ctx); + kfree(cil->xc_ctx); } ASSERT(test_bit(XLOG_CIL_EMPTY, &cil->xc_flags)); free_percpu(cil->xc_pcp); destroy_workqueue(cil->xc_push_wq); - kmem_free(cil); + kfree(cil); } diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 295306ef6959..e9ed43a833af 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c @@ -2229,11 +2229,11 @@ xlog_recover_free_trans( for (i = 0; i < item->ri_cnt; i++) kvfree(item->ri_buf[i].i_addr); /* Free the item itself */ - kmem_free(item->ri_buf); - kmem_free(item); + kfree(item->ri_buf); + kfree(item); } /* Free the transaction recover structure */ - kmem_free(trans); + kfree(trans); } /* diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index aabb25dc3efa..7328034d42ed 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -45,7 +45,7 @@ xfs_uuid_table_free(void) { if (xfs_uuid_table_size == 0) return; - kmem_free(xfs_uuid_table); + kfree(xfs_uuid_table); xfs_uuid_table = NULL; xfs_uuid_table_size = 0; } diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c index feae3115617b..ce496704748d 100644 --- a/fs/xfs/xfs_mru_cache.c +++ b/fs/xfs/xfs_mru_cache.c @@ -365,9 +365,9 @@ xfs_mru_cache_create( exit: if (err && mru && mru->lists) - kmem_free(mru->lists); + kfree(mru->lists); if (err && mru) - kmem_free(mru); + kfree(mru); return err; } @@ -407,8 +407,8 @@ xfs_mru_cache_destroy( xfs_mru_cache_flush(mru); - kmem_free(mru->lists); - kmem_free(mru); + kfree(mru->lists); + kfree(mru); } /* diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index b130bf49013b..46a7fe70e57e 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -701,7 +701,7 @@ xfs_qm_init_quotainfo( out_free_lru: list_lru_destroy(&qinf->qi_lru); out_free_qinf: - kmem_free(qinf); + kfree(qinf); mp->m_quotainfo = NULL; return error; } @@ -725,7 +725,7 @@ xfs_qm_destroy_quotainfo( xfs_qm_destroy_quotainos(qi); mutex_destroy(&qi->qi_tree_lock); mutex_destroy(&qi->qi_quotaofflock); - kmem_free(qi); + kfree(qi); mp->m_quotainfo = NULL; } @@ -1060,7 +1060,7 @@ xfs_qm_reset_dqcounts_buf( } while (nmaps > 0); out: - kmem_free(map); + kfree(map); return error; } diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c index a9b322e23cfb..d850b9685f7f 100644 --- a/fs/xfs/xfs_refcount_item.c +++ b/fs/xfs/xfs_refcount_item.c @@ -38,7 +38,7 @@ xfs_cui_item_free( { kvfree(cuip->cui_item.li_lv_shadow); if (cuip->cui_format.cui_nextents > XFS_CUI_MAX_FAST_EXTENTS) - kmem_free(cuip); + kfree(cuip); else kmem_cache_free(xfs_cui_cache, cuip); } diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 489ca8c0e1dc..a40b92ac81e8 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -38,7 +38,7 @@ xfs_rui_item_free( { kvfree(ruip->rui_item.li_lv_shadow); if (ruip->rui_format.rui_nextents > XFS_RUI_MAX_FAST_EXTENTS) - kmem_free(ruip); + kfree(ruip); else kmem_cache_free(xfs_rui_cache, ruip); } diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 57ed9baaf156..2f85567f3d75 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1050,7 +1050,7 @@ xfs_growfs_rt( /* * Free the fake mp structure. */ - kmem_free(nmp); + kfree(nmp); /* * If we had to allocate a new rsum_cache, we either need to free the diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 7b1b29814be2..96cb00e94551 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -773,7 +773,7 @@ xfs_mount_free( debugfs_remove(mp->m_debugfs); kfree(mp->m_rtname); kfree(mp->m_logname); - kmem_free(mp); + kfree(mp); } STATIC int diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 5f206cdb40ff..e4c343096f95 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c @@ -922,7 +922,7 @@ xfs_trans_ail_init( return 0; out_free_ailp: - kmem_free(ailp); + kfree(ailp); return -ENOMEM; } @@ -933,5 +933,5 @@ xfs_trans_ail_destroy( struct xfs_ail *ailp = mp->m_ail; kthread_stop(ailp->ail_task); - kmem_free(ailp); + kfree(ailp); } From patchwork Mon Jan 15 22:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520253 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 E457BC3DA79 for ; Mon, 15 Jan 2024 23:01:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF4776B006E; Mon, 15 Jan 2024 18:01:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CADCC6B0074; 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 9E5816B006E; Mon, 15 Jan 2024 18:01:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 86DAA6B006E for ; Mon, 15 Jan 2024 18:01:22 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 548F94087B for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) X-FDA: 81683068404.03.4BAA298 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf02.hostedemail.com (Postfix) with ESMTP id 8EFCF80011 for ; Mon, 15 Jan 2024 23:01:20 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=MOUA4iCY; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf02.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.173 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=bprujdq9x6vGUjX7hmrzPJN/IZ+ZvLny33A51Hvuzf0=; b=4G2P/TexYULZ7ut7OsGbj3msUX4DUJBHlV77vcvvTDhnToDWtpARfqGR5euB83lMGG/c0v cKbjpSafUWLs9h1DWgnuYh+urD+t4pdhN0SL9lguq/sl9ymSOuL5WV9+G0nKKvZG+p0udn 77tQ5TkDqpcDgew0H/kMc8L6vBuL2lw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=MOUA4iCY; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf02.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.173 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=RMvAp/7+h7ECNP7Guq+UPEzTC3zjPCwAhgjmJwltbKYuMijbHZaGnHJ3PY6AxrhpgYV5Oc IgspgGbXptNzxoTZNyTunxqBBCDARkZNXNxHa9173yQA1+SMUsvuFoyD/HCEsLJSOa8K5r 4mTsLpQLRgtSBVbZucCfOdAyxC33XAo= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d3eae5c1d7so46816735ad.2 for ; Mon, 15 Jan 2024 15:01:20 -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=bprujdq9x6vGUjX7hmrzPJN/IZ+ZvLny33A51Hvuzf0=; b=MOUA4iCYlX33jeHYDKlg014XSEJkrP3kG7wbAKdZoJ4xAOZi9QVrJEY+3OK/pUNCig AWNvWLABVBrP9fmMavV9cuZsWN0xK6YnC/WEE2z8z2GbDVrRqiLC3dbmGWONj2vYoLIy /2KN8dOdKV90t3SIsbMiNd5ew850yqlxNOm7BAtUE039OvfcpqLKflrDNkbRCYZbKkWv 9rqnsxE3je0XJTK82CTtqBBEizQZZBc7B/iMn5g8i6WCP9lRpm+R7UKST9ggz0lK3MHp uxWqjS1Gpu/MXUZTgC3NIVEQhPBZ16uvRQhsvnltvpnOzOTro35M2CiPrxYpT4FL7BGW kBcw== 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=bprujdq9x6vGUjX7hmrzPJN/IZ+ZvLny33A51Hvuzf0=; b=n03G89FIeWqK6pBGkd4SE5GQFzB2ZyuTRO55wP9Ab46FlKFxpTJ96roWJq11n3VjJX GpuM2347duyScZFN2fqOdLb4HIQZKlocYzixguV715WMeYdfpHj6N3mqeFrsnBc7RA36 fgNf8ip7p314PKm2xtW6zxvrdtrezIR7tmUF7qzqas25d0osSfl9nfT9rpg61QzcmCag ttsd6JHltIM1V8q9PzM2V2Nl5dbm1HGY4vs3iom+rWxODFsQpYc95X9CvBWTiXLGuSyk jAZbY2nPyEc2yR2hYPI9ksOYLlzv4GrQ/dGXwWWdYPQQ/xmWckwzR093EY2yv/K6R2pB kUMQ== X-Gm-Message-State: AOJu0YwBc1GZyKIkTJskRXtbBdOzY6DuXXHk5VrvaM3V2tE8p9zvtgRJ mLSJuwFLYsFnd3sGCG7/CtiqkG1FGrQHXg== X-Google-Smtp-Source: AGHT+IEiof1jeUl/P8MCSvHO3zALDxYJPl6CwcuUzGZhqGNXCpwzMiN1PzBQ1/m0xGV6eG7CXA73PA== X-Received: by 2002:a17:902:e751:b0:1d4:6429:4e1c with SMTP id p17-20020a170902e75100b001d464294e1cmr4036272plf.4.1705359679338; Mon, 15 Jan 2024 15:01:19 -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 i10-20020a170902c94a00b001d538ee9ff3sm8076467pla.183.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-00AtKA-0Z; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fn-2ghT; 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 06/12] xfs: use an empty transaction for fstrim Date: Tue, 16 Jan 2024 09:59:44 +1100 Message-ID: <20240115230113.4080105-7-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 X-Rspamd-Queue-Id: 8EFCF80011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: wmde3i5fr1cxufkadqgr8n6apc48ixbd X-HE-Tag: 1705359680-989504 X-HE-Meta: U2FsdGVkX19e7ypyvR5fRcMeDcUso2X3xsEtESKWvrYABV7IZxj3+X8tT6mOtHv9P3NFsATGX5e6oucvbtglvO55T7yYAD+004OQJsBXhnnwKU7fzQ5qLTrqUtzjSCKYJMbYE7Ke/7pYH9MN5I37aB5HCPnp5JSXCughba+C+9ymfG/SeY1Bj8q7JtwMA1pKGioKbLESZ/HRn4jRxXxcegdotrb0g4Rc0wC+Vdleo7URCgjRvb0y03of5b/lWiSRsqkALzUH0qL6APeZXErQjkOLFmtWUZZxTm1OxpP//XSuySvYPvYOxPa1a1Tdyb+6sG/8eFCNhW3MnIcV5+XUpBUA21WZT6drWYxVXUlXVzy6E46JGfH3sw4GrNvRFxtloedQO2SH8r4oxEqJXpcbgp1eS2R7M2obJFENJ7ucqHq0834BsJQ6rLX6N8/FfEqDAyLwiz9vz5b/R0SNhfXMcu1NuIdJWu3KjXkxvjPswN1bTuOgPecKRDBnYKtQC28j9SkEAu7nBD5tHhmODDCzxxnClTxFDCeeqABTdhunrlFHaWPpZWgg/jjNIdXXPJ1R9Lq5DTppn2+vQEpt9BAHn8jHo0t9rsqlpyKWPuvwSc8ZQEAHGn0tKIAwFq5hD3iBz4lgjZ/k2Fz+u3dvDIqN4q+N9C6AxamZhD+MlKqhD31qmjX0XX3bKTd/xaUCTBvSW7k6ACG16XCUv8tyGbNhF9pcRBpehfoq4314Gu4lhezZqJ5jeCiyFxiDuCOOdmC34xA4BEwmoKiBQbb8Q4NkKBBxtcFEUM24Rc+0xqT9SXnixkWB88TpInRhEpne9holHG9UAZHsoDEpVEJlpDKUVDPH8oyI40LKIVUoZXJZPP9DDMhqjayMea9SlvxWxvJmyQqJxrVViQwXfYWUQvJjU+ymg8Q6AK1cm4dnngNE6RpiM08K2mb2wudgwHwb0xtlRS0ostYZEgWGia4BRiv kMaiU8/x 2zl9XDgSiizC/eF6EN7to6sNa+TiJoAaBTfS7Q+8K7+GjtcU/DQTKkwhmo8jRZ3M81aPKwZO/n9uzG1L5SmbbRxOj3h2BqY9i385MJtMDtskK8B2r5xQriGxBxfQrxPSczhH8KRqaCsKQeEISemQE2MMbV1LWJqQxu3nU1SvxHzhVfCLXvJjjZr7Eb9KDWG4ZE5bl 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 We currently use a btree walk in the fstrim code. This requires a btree cursor and btree cursors are only used inside transactions except for the fstrim code. This means that all the btree operations that allocate memory operate in both GFP_KERNEL and GFP_NOFS contexts. This causes problems with lockdep being unable to determine the difference between objects that are safe to lock both above and below memory reclaim. Free space btree buffers are definitely locked both above and below reclaim and that means we have to mark all btree infrastructure allocations with GFP_NOFS to avoid potential lockdep false positives. If we wrap this btree walk in an empty cursor, all btree walks are now done under transaction context and so all allocations inherit GFP_NOFS context from the tranaction. This enables us to move all the btree allocations to GFP_KERNEL context and hence help remove the explicit use of GFP_NOFS in XFS. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_discard.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index 8539f5c9a774..299b8f907292 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c @@ -8,6 +8,7 @@ #include "xfs_format.h" #include "xfs_log_format.h" #include "xfs_trans_resv.h" +#include "xfs_trans.h" #include "xfs_mount.h" #include "xfs_btree.h" #include "xfs_alloc_btree.h" @@ -120,7 +121,7 @@ xfs_discard_extents( error = __blkdev_issue_discard(mp->m_ddev_targp->bt_bdev, XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno), XFS_FSB_TO_BB(mp, busyp->length), - GFP_NOFS, &bio); + GFP_KERNEL, &bio); if (error && error != -EOPNOTSUPP) { xfs_info(mp, "discard failed for extent [0x%llx,%u], error %d", @@ -155,6 +156,7 @@ xfs_trim_gather_extents( uint64_t *blocks_trimmed) { struct xfs_mount *mp = pag->pag_mount; + struct xfs_trans *tp; struct xfs_btree_cur *cur; struct xfs_buf *agbp; int error; @@ -168,11 +170,15 @@ xfs_trim_gather_extents( */ xfs_log_force(mp, XFS_LOG_SYNC); - error = xfs_alloc_read_agf(pag, NULL, 0, &agbp); + error = xfs_trans_alloc_empty(mp, &tp); if (error) return error; - cur = xfs_allocbt_init_cursor(mp, NULL, agbp, pag, XFS_BTNUM_CNT); + error = xfs_alloc_read_agf(pag, tp, 0, &agbp); + if (error) + goto out_trans_cancel; + + cur = xfs_allocbt_init_cursor(mp, tp, agbp, pag, XFS_BTNUM_CNT); /* * Look up the extent length requested in the AGF and start with it. @@ -279,7 +285,8 @@ xfs_trim_gather_extents( xfs_extent_busy_clear(mp, &extents->extent_list, false); out_del_cursor: xfs_btree_del_cursor(cur, error); - xfs_buf_relse(agbp); +out_trans_cancel: + xfs_trans_cancel(tp); return error; } From patchwork Mon Jan 15 22:59:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520260 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 AF21DC3DA79 for ; Mon, 15 Jan 2024 23:01:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF25E6B007E; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC0B16B0080; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9231F6B0081; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 59CC36B0080 for ; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 232411C11EE for ; Mon, 15 Jan 2024 23:01:25 +0000 (UTC) X-FDA: 81683068530.20.EA9B8D8 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf11.hostedemail.com (Postfix) with ESMTP id 1801D40027 for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=HFjTCXo9; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf11.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.179 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=1705359683; 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=DvVUbq4f8t6Cv63H6GruWlEMt6Dq66cPsSdsWLn42bk=; b=qutXkxIN7d9Kih34bmal6WC0PGktzXKB1NY7wgnYCFq/uQ5N49ixYvhMfV4WkR5nfQVKG+ jlWFCfoi56SboJemwT2WHUnTTbakCCMybUSYW1L3ePfQ4dfjsPCPiXwksyhUF0FIlaenJs 7g2pKjuh44o9asA/n2WX5ihAm4MM9yA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=HFjTCXo9; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf11.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359683; a=rsa-sha256; cv=none; b=Grx9m8IzsmGTSCh+DkSiDDX5gqoWSa6awFjHAWCvbBmEJ6bFZXZ47+j3vHKVbHnQZ4jl9H RIxDuG1p7MK2IEGamuHyzNtta6ALHOJFplxbgIiVD5QQOC8UuKUU1eyINgbwRsCqcmtCcd sCAl8ruNTOg0ymPhxGfx1IhOY2CUILA= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6db81c6287dso1075676b3a.0 for ; Mon, 15 Jan 2024 15:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359682; x=1705964482; 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=DvVUbq4f8t6Cv63H6GruWlEMt6Dq66cPsSdsWLn42bk=; b=HFjTCXo9Qx0lEZqnOBSHd+kPQl+xVB68KCXtwpW5oye8GhOqNPzbilAkjPzNhKyCxD EpxPeGilt4XNXYGnB9wre/LGblxe1CkZjCAI3eljYevftrIicUwWqMJqp0rzdUmN+t+b 4dMew25oYceAiAZsbNv+yxW7Ew0ynPhn3RQvPwAB7KLjmq39FfYlbM7SCt1gd89oyx90 b/4gpexQM6GtEKAk/K1gXGHqy+hL1T3YMoDcXw2gEyUgZ10vzk8M8Httd1xVLWM//d9A 1OhI/PkK8Zd5Vpsa3owhBktEjaax40VvYgtkJofL4WNaiogKM2nqtRSYkE0o5Wc3Hvhl dixg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359682; x=1705964482; 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=DvVUbq4f8t6Cv63H6GruWlEMt6Dq66cPsSdsWLn42bk=; b=tsX+N5DVTpuF3oips+1ZPLUP6c370j48DIJOsjW3uZT0VTcf3qIs9hgh4qkkBEv7p5 uTJzqe+CEIhLnnqTncPpEKcZKRxbwi0WYRYyaZrKnPVZxgvZTd2KZfnCdAe6spLDgwRq 2Pe2KGpFVy/MoEaWeR2q6ifVoOHnf93jkDBGwID9Xt7t7Br5kChD0wkut5V/CWfk+k6n dwN16pyZM8Tvp/BACJNkSX5yckjvc9bx7Ha0Kf42Mu7CfpBiU5xaUJDVrQYqhpkgHI4P NWc4IFko6PqPhPG4/le+TGECHyl8OA/c1BeCbCDe6feGku79hzUhKltYLsxTwHh1xIvb T5/Q== X-Gm-Message-State: AOJu0Yy/IQjosYLvC+4g7KfPUSKAsFzBw0mVr2rUywlujmk6Nq8l7W/3 a0lMv60VVKLOhxYruxsOADYoXZ6or7CTzQ== X-Google-Smtp-Source: AGHT+IFaFLF0wQYlQlLLCZ8wr4ZkEhNZnxbAO8R0dD2lI0Z+w6FchnIrD8zwblq5AgkNyfZu4lZQBA== X-Received: by 2002:a05:6a20:8407:b0:199:fe49:6bb3 with SMTP id c7-20020a056a20840700b00199fe496bb3mr9488275pzd.5.1705359681921; Mon, 15 Jan 2024 15:01:21 -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 ff23-20020a056a002f5700b006d9361fcfc8sm8397979pfb.177.2024.01.15.15.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 15:01:19 -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-00AtKF-0f; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fs-2pfv; 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 07/12] xfs: use __GFP_NOLOCKDEP instead of GFP_NOFS Date: Tue, 16 Jan 2024 09:59:45 +1100 Message-ID: <20240115230113.4080105-8-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 X-Rspamd-Queue-Id: 1801D40027 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: kk4wtjdt5tq9bppzy63rgxxznm5j3bgw X-HE-Tag: 1705359682-123069 X-HE-Meta: U2FsdGVkX18KRy+409ybMBeiyiWLdHePKYZ9rKyIQglA8mWTxGQ3rUs291voX011SIZHezyITwnGDInJWsHbjMqRKx9RSsZ1S/PTUSaNqsJ3338shhdt4jc3s1OymeQ/n2mVNvAdPzh0iJWbcTV4M/Q20YYPOdjUD1ClRrGhdqTZZDzkG84wstCiJ/DwkFFcpzVytSx6RIsw978lWDaaCFMY299whWqD/HL7OJeJ09ItCLgfLhissmi77Na0a/yxvsrRrLf+2NXAYrS//l6P6LGOVZR0hz61T94Fp5FGODVr3QJKgezjtaGQUUgoY4fWUEEJI0jPkZ0uxwEDH7LgC6+w6clgNQM+KT2v5OpORJelPW9TFtw/WUp5Rf3hD2YcUer7ChM26gfPnMFEPTNHjiS5GM5Q80ljcoP3e3o3kjHfMTD23MkyrJm8Noj83tG38b0OFjXR1WhEcqMGhCoUrmCv7Viyk0p+kvj4ek0Ya/9fU2FKUXL9PGyFYXAyZAlq4ld/SysrlWqM/mfpQwRPnzPA4av/C531cF7kFs2wBZJ2h6z30Wx7u1ekLCwCD/07zUcRU+qOuq/xJ5fvymMHvLRP2EloAYR5L54F/TTwhR+mZYjDg9f/SipLmWK4qrojibp4R7yfDsna9RXDSyDlwxeTWt3Qo5yKMi0Q9WRX2kzhPWgxERsalYS5EhcbqoegfyGM+F8njIRXwnGpRcNMeV4pAN+wXVSapaJzkpLS2tI2N+qaiZDNvnTpSqSJg9VU6n37WPY97sDpgxuL0GkzrObFax3HOGqipun1Lo/eB0u9OS6Z36RxJFwz2SKv5FAlukBWJNS0qHt0dQuFPNDIIhzY7reqn4BhNCE50Kel69z9Kz8jZQR6QQQWWr3jksmj0CBCxcu1IHj3mBZosAd4avbFA+m1iVXDfFcSZWLdZue/m9rk8LqmTMJP5gWKgpOWZjVxDzCcfSWpLOaKOQ9 kOzTwztB mhWkRobUXvLTvZjqv2bHc2ehNtSMv6cQh7mVcZW1Ts8dEm+FVeC7u7WFdvsvP/7y+/JH/yCHXpB0TylhQash6E6wYwYkkRFGPpFjcW/xP0MTXf1MbFy4SKqjri46gqqskKAdZLYWuHKX+meVwcvFq9GLjEoOseNRXLf1tADczjxhidbYTW9ZfOLSNnO8d3GLptxtAUvwc9ysaozpNEgoz2xE+alhRj5NoY+2wX1wPr8lNvCFB9MfLPBisaOxZtuwck5Kl8wz79m4oNUbxrblC1HrcFbwSmW1UktrW+lbvVD5fXgYIBaBqe4HOzOPyxjSj61EImcohUezj+X8w/tUtPYz0xH1FkCaVMXNE59U1e6/XmZJZ7kL/w+5HVZxxS36P7y62oKL5OJO9Fb8Chm25sq3gDgjzROA0y9gA9n75IS++LeJHfV6XnhJTV+zg4ASd3+c3OzDRmJWJ3DBO/nebnzXMVKCfu1arYID0CfFgdj11w5nlt4aUQHugtZrxejkQVRrxIqgs63M45IZ2VrJSYJoAsw== 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 In the past we've had problems with lockdep false positives stemming from inode locking occurring in memory reclaim contexts (e.g. from superblock shrinkers). Lockdep doesn't know that inodes access from above memory reclaim cannot be accessed from below memory reclaim (and vice versa) but there has never been a good solution to solving this problem with lockdep annotations. This situation isn't unique to inode locks - buffers are also locked above and below memory reclaim, and we have to maintain lock ordering for them - and against inodes - appropriately. IOWs, the same code paths and locks are taken both above and below memory reclaim and so we always need to make sure the lock orders are consistent. We are spared the lockdep problems this might cause by the fact that semaphores and bit locks aren't covered by lockdep. In general, this sort of lockdep false positive detection is cause by code that runs GFP_KERNEL memory allocation with an actively referenced inode locked. When it is run from a transaction, memory allocation is automatically GFP_NOFS, so we don't have reclaim recursion issues. So in the places where we do memory allocation with inodes locked outside of a transaction, we have explicitly set them to use GFP_NOFS allocations to prevent lockdep false positives from being reported if the allocation dips into direct memory reclaim. More recently, __GFP_NOLOCKDEP was added to the memory allocation flags to tell lockdep not to track that particular allocation for the purposes of reclaim recursion detection. This is a much better way of preventing false positives - it allows us to use GFP_KERNEL context outside of transactions, and allows direct memory reclaim to proceed normally without throwing out false positive deadlock warnings. The obvious places that lock inodes and do memory allocation are the lookup paths and inode extent list initialisation. These occur in non-transactional GFP_KERNEL contexts, and so can run direct reclaim and lock inodes. This patch makes a first path through all the explicit GFP_NOFS allocations in XFS and converts the obvious ones to GFP_KERNEL | __GFP_NOLOCKDEP as a first step towards removing explicit GFP_NOFS allocations from the XFS code. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_ag.c | 2 +- fs/xfs/libxfs/xfs_btree.h | 4 +++- fs/xfs/libxfs/xfs_da_btree.c | 8 +++++--- fs/xfs/libxfs/xfs_dir2.c | 14 ++++---------- fs/xfs/libxfs/xfs_iext_tree.c | 22 +++++++++++++--------- fs/xfs/libxfs/xfs_inode_fork.c | 8 +++++--- fs/xfs/xfs_icache.c | 5 ++--- fs/xfs/xfs_qm.c | 6 +++--- 8 files changed, 36 insertions(+), 33 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c index 937ea48d5cc0..036f4ee43fd3 100644 --- a/fs/xfs/libxfs/xfs_ag.c +++ b/fs/xfs/libxfs/xfs_ag.c @@ -389,7 +389,7 @@ xfs_initialize_perag( pag->pag_agno = index; pag->pag_mount = mp; - error = radix_tree_preload(GFP_NOFS); + error = radix_tree_preload(GFP_KERNEL | __GFP_RETRY_MAYFAIL); if (error) goto out_free_pag; diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h index d906324e25c8..75a0e2c8e115 100644 --- a/fs/xfs/libxfs/xfs_btree.h +++ b/fs/xfs/libxfs/xfs_btree.h @@ -725,7 +725,9 @@ xfs_btree_alloc_cursor( { struct xfs_btree_cur *cur; - cur = kmem_cache_zalloc(cache, GFP_NOFS | __GFP_NOFAIL); + /* BMBT allocations can come through from non-transactional context. */ + cur = kmem_cache_zalloc(cache, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); cur->bc_tp = tp; cur->bc_mp = mp; cur->bc_btnum = btnum; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 3383b4525381..444ec1560f43 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -85,7 +85,8 @@ xfs_da_state_alloc( { struct xfs_da_state *state; - state = kmem_cache_zalloc(xfs_da_state_cache, GFP_NOFS | __GFP_NOFAIL); + state = kmem_cache_zalloc(xfs_da_state_cache, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); state->args = args; state->mp = args->dp->i_mount; return state; @@ -2519,7 +2520,8 @@ xfs_dabuf_map( int error = 0, nirecs, i; if (nfsb > 1) - irecs = kzalloc(sizeof(irec) * nfsb, GFP_NOFS | __GFP_NOFAIL); + irecs = kzalloc(sizeof(irec) * nfsb, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); nirecs = nfsb; error = xfs_bmapi_read(dp, bno, nfsb, irecs, &nirecs, @@ -2533,7 +2535,7 @@ xfs_dabuf_map( */ if (nirecs > 1) { map = kzalloc(nirecs * sizeof(struct xfs_buf_map), - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); if (!map) { error = -ENOMEM; goto out_free_irecs; diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index e60aa8f8d0a7..728f72f0d078 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -333,7 +333,8 @@ xfs_dir_cilookup_result( !(args->op_flags & XFS_DA_OP_CILOOKUP)) return -EEXIST; - args->value = kmalloc(len, GFP_NOFS | __GFP_RETRY_MAYFAIL); + args->value = kmalloc(len, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL); if (!args->value) return -ENOMEM; @@ -364,15 +365,8 @@ xfs_dir_lookup( ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); XFS_STATS_INC(dp->i_mount, xs_dir_lookup); - /* - * We need to use KM_NOFS here so that lockdep will not throw false - * positive deadlock warnings on a non-transactional lookup path. It is - * safe to recurse into inode recalim in that case, but lockdep can't - * easily be taught about it. Hence KM_NOFS avoids having to add more - * lockdep Doing this avoids having to add a bunch of lockdep class - * annotations into the reclaim path for the ilock. - */ - args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); + args = kzalloc(sizeof(*args), + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); args->geo = dp->i_mount->m_dir_geo; args->name = name->name; args->namelen = name->len; diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c index 16f18b08fe4c..8796f2b3e534 100644 --- a/fs/xfs/libxfs/xfs_iext_tree.c +++ b/fs/xfs/libxfs/xfs_iext_tree.c @@ -394,12 +394,18 @@ xfs_iext_leaf_key( return leaf->recs[n].lo & XFS_IEXT_STARTOFF_MASK; } +static inline void * +xfs_iext_alloc_node( + int size) +{ + return kzalloc(size, GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); +} + static void xfs_iext_grow( struct xfs_ifork *ifp) { - struct xfs_iext_node *node = kzalloc(NODE_SIZE, - GFP_NOFS | __GFP_NOFAIL); + struct xfs_iext_node *node = xfs_iext_alloc_node(NODE_SIZE); int i; if (ifp->if_height == 1) { @@ -455,8 +461,7 @@ xfs_iext_split_node( int *nr_entries) { struct xfs_iext_node *node = *nodep; - struct xfs_iext_node *new = kzalloc(NODE_SIZE, - GFP_NOFS | __GFP_NOFAIL); + struct xfs_iext_node *new = xfs_iext_alloc_node(NODE_SIZE); const int nr_move = KEYS_PER_NODE / 2; int nr_keep = nr_move + (KEYS_PER_NODE & 1); int i = 0; @@ -544,8 +549,7 @@ xfs_iext_split_leaf( int *nr_entries) { struct xfs_iext_leaf *leaf = cur->leaf; - struct xfs_iext_leaf *new = kzalloc(NODE_SIZE, - GFP_NOFS | __GFP_NOFAIL); + struct xfs_iext_leaf *new = xfs_iext_alloc_node(NODE_SIZE); const int nr_move = RECS_PER_LEAF / 2; int nr_keep = nr_move + (RECS_PER_LEAF & 1); int i; @@ -586,8 +590,7 @@ xfs_iext_alloc_root( { ASSERT(ifp->if_bytes == 0); - ifp->if_data = kzalloc(sizeof(struct xfs_iext_rec), - GFP_NOFS | __GFP_NOFAIL); + ifp->if_data = xfs_iext_alloc_node(sizeof(struct xfs_iext_rec)); ifp->if_height = 1; /* now that we have a node step into it */ @@ -607,7 +610,8 @@ xfs_iext_realloc_root( if (new_size / sizeof(struct xfs_iext_rec) == RECS_PER_LEAF) new_size = NODE_SIZE; - new = krealloc(ifp->if_data, new_size, GFP_NOFS | __GFP_NOFAIL); + new = krealloc(ifp->if_data, new_size, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes); ifp->if_data = new; cur->leaf = new; diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index f6d5b86b608d..709fda3d742f 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -50,7 +50,8 @@ xfs_init_local_fork( mem_size++; if (size) { - char *new_data = kmalloc(mem_size, GFP_NOFS | __GFP_NOFAIL); + char *new_data = kmalloc(mem_size, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); memcpy(new_data, data, size); if (zero_terminate) @@ -205,7 +206,8 @@ xfs_iformat_btree( } ifp->if_broot_bytes = size; - ifp->if_broot = kmalloc(size, GFP_NOFS | __GFP_NOFAIL); + ifp->if_broot = kmalloc(size, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); ASSERT(ifp->if_broot != NULL); /* * Copy and convert from the on-disk structure @@ -690,7 +692,7 @@ xfs_ifork_init_cow( return; ip->i_cowfp = kmem_cache_zalloc(xfs_ifork_cache, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); ip->i_cowfp->if_format = XFS_DINODE_FMT_EXTENTS; } diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index dba514a2c84d..06046827b5fe 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -659,10 +659,9 @@ xfs_iget_cache_miss( /* * Preload the radix tree so we can insert safely under the * write spinlock. Note that we cannot sleep inside the preload - * region. Since we can be called from transaction context, don't - * recurse into the file system. + * region. */ - if (radix_tree_preload(GFP_NOFS)) { + if (radix_tree_preload(GFP_KERNEL | __GFP_NOLOCKDEP)) { error = -EAGAIN; goto out_destroy; } diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 46a7fe70e57e..384a5349e696 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -643,9 +643,9 @@ xfs_qm_init_quotainfo( if (error) goto out_free_lru; - INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS); - INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS); - INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS); + INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_KERNEL); + INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_KERNEL); + INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_KERNEL); mutex_init(&qinf->qi_tree_lock); /* mutex used to serialize quotaoffs */ From patchwork Mon Jan 15 22:59:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520256 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 1F168C4707B for ; Mon, 15 Jan 2024 23:01:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AADB06B0074; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A35AB6B007B; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8876F6B0078; Mon, 15 Jan 2024 18:01:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 638866B007B for ; Mon, 15 Jan 2024 18:01:23 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3BBD71C12A3 for ; Mon, 15 Jan 2024 23:01:23 +0000 (UTC) X-FDA: 81683068446.20.49047DA Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 572E51C0017 for ; Mon, 15 Jan 2024 23:01:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=EKcGLITh; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf21.hostedemail.com: domain of david@fromorbit.com designates 209.85.167.172 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=1705359681; 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=AReH4fPhX0qnf2rGMtllGHRPMoAw4H7smgC9h2elFy0=; b=vHa3GhB0U85+qNaz61hrt6IP163TggJKqCd/p06eKImfVFPqNm9NEmEbt/u6KNCPHXFO5c hgN1vD7TiWnT9yRte8Gm/c7LABR0A4fQ93OQ9K6ziVOLjvIWN8MFpJab9BKXAUuYI26fSM yMcmm+Va9KFCKMLAnSxdU8UalMCvBj0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=EKcGLITh; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf21.hostedemail.com: domain of david@fromorbit.com designates 209.85.167.172 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359681; a=rsa-sha256; cv=none; b=zvlVzcG2WvhEN+ZbTKzGotIdIZ3mnRbIzdSv4XiRWB+dE7fQqZOiFw1ec4DGeSkWDGiiD9 YKbAakpeohewroYyo613Ww+98+ZFt5JhPWwjhwF0m3SvSYi4q/kyStxOG136YJ+D8llN6v 97e+INpdEc91Nw+q1uEaAtDuI/6aQvk= Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3bd3b34a58dso4219275b6e.3 for ; Mon, 15 Jan 2024 15:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359680; x=1705964480; 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=AReH4fPhX0qnf2rGMtllGHRPMoAw4H7smgC9h2elFy0=; b=EKcGLITh5GWhHsHIDL4RVk0cDRTyUyHM+hrK4B5Yo1OQWv3F7WWQyYvitV5OQRytz1 nqykYXzEt5oiLDOQqovvErdFN0KmoNaY3vl0qw5wFo3PI1zBPhHdM+I/RwvT7y6MAE/+ JmMCRmPWIdgw1INQg/mQIxTTJZc5GdES8bILvW9h0qkHl2m010cnSTi0qrPT7rxyznQp Q9Gyrzfzv04EsJgsIHGEy9FHbG990mCWkUFEXzjq/jzpjOczT7mB1M/x8ImnxefS9Lb0 +3vMFcRimPV4QhJoEH1kmnNXWoKf2ffl7GIBNeG4zGMhzlXwHI3EZrwh2CCXd8O6ERET nOAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359680; x=1705964480; 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=AReH4fPhX0qnf2rGMtllGHRPMoAw4H7smgC9h2elFy0=; b=ujbMwl/IO0M9AY0LOdKCXYAArydelFRQ/Epb/I8y2ZKR257dD1k/eL1ZC6JCr1kpCY 289wEoU3uEAWpd0q0q4ZnKeSJP9MsdnyK9yH60fmj+O+EYzajwzGZL2opA9xxfzAYdJ9 hYaRnyobDAUXYQfv2XI0AaKJvgwct5WM0uHQRO56Xi/pc3U04Hz1xKzz3rlsboyVDSdC 38nj34Z00bEukmYpV4AFzIHhDQBmUTs2a8FIc7K3oXMjyt7wCRWtnR23D56uumzHAvIg q5aq0WEqvz9ouqh5Or1w9cFL3TOe/fhKm/O1c9u8WqpKOIbe0DQiSr4ZLmpn/26RWq0g Wqdw== X-Gm-Message-State: AOJu0YysTTKBnfLGfygE81u2wwKfTAQOsQlF/tyboZWz5JsHCY99vDnw +JQNcAYpNswnBJF71m2NcbgMVYyEv4Dtsg== X-Google-Smtp-Source: AGHT+IEYlcJQMm5bEb8rOiDx/77KPnN71bc52YGCAdpGz+zxZPCud2iakyhoXEj0f1EPTTWIVkPnhA== X-Received: by 2002:a05:6808:1826:b0:3bd:5be7:def2 with SMTP id bh38-20020a056808182600b003bd5be7def2mr7489577oib.8.1705359680200; Mon, 15 Jan 2024 15:01:20 -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 c23-20020aa78817000000b006d96dc803b3sm8366593pfo.12.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-00AtKJ-0l; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8fw-2xxB; 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 08/12] xfs: use GFP_KERNEL in pure transaction contexts Date: Tue, 16 Jan 2024 09:59:46 +1100 Message-ID: <20240115230113.4080105-9-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 X-Rspam-User: X-Stat-Signature: 91ygbtkpkm334pdpbbtnmcg5acxwfd43 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 572E51C0017 X-HE-Tag: 1705359681-432210 X-HE-Meta: U2FsdGVkX19+92mn447wvQDpTcLHkNacdsEWhdk+2umvbFZwFGMXbBzXILMnuG5MGU7gQaoAiAyxjVCrIpZmLvH4PfekcaUhyOFvyCHyrXnd6PeTLWBjMG5N+Hz2A5GZvX/skMy7uqf3kAL1xZrqP2e39WQIyIPYgW8FNgxtMLFxuXqgtxzkGVOQlhFzLJCquGd6PMk50rg9EeDbxuGXAjCwol0HelLzD4M3ge6lUwJiHzutG5+dTvThaBwLHzPxF21h/0EStTsNFSQbhksV+q70F4LIrAtTQ+7Dq9CUL2iYMo8wDRXUtG3HiRz5yofJk4wyMWnuseNgI3Y1qB30DPqQElw2c5RYyhDOHtpYvklz8bwh8LJCJY6T/O91D37LHYUf+qzOJGDqO7vGUiAPHLR/TsbwhaZKsbc9leI+G6grT0kJamlQU5jCVgWE4tXBQzVC8CpX2S3gScGUP/UoFZSVo6UPk2rfWwV0vdjWvmH3bljtpiStsecsvCzeUo3jMLegua8/0ghQKRP4kFDejZfxxFJP+XBL0SbUBIk/lo9Olw8YCVlxWGZ4abjIhwc1d0WkbEe6++BtRkZLPmX9FZU2eLzhIV8CdZjLICnyvoz7IhR78wNGpWsTH7gS/aVgwaHVN2NHNNuL9IU/LgnKnfb+UkRgqeOhkqyuV31jJRcJ6l4wm3OTv7T9JUpAGbsAS1K8T0atYaJRXSa1lCPeh9tXdD6MRGPVkXRPJeyRJhr0po1u9V0eiqA96+8LiE+U9lQlqxtf1/rddoNIqZEGjxsQc8lbErwpHXm3y5Wcr3GAHdRE8xohYL02JrO4+a7ywgcWAQ88QEYQ7h99L5h3T4hwIxPTIFBgwDaII+Xg1sXAfYlXbEcTuwuwlmutq8IO/EfkQ+NiGTzbimfOFQnfBADyCQvPWI1EoyrHAx1d5liREIF2Z7YgMiGzSw+I27dcPlkJX0zuz14lk+IK+Z6 lsltUZYM cwTXv5iSOKCjrC+92O2L5VCBPBG99Y8j+CbfdYASBC9IMYMgCUyHTSAAi0sy6+0EJk5lo918EpU/1D3cvykonaEqqA/rgCUjWK3YIoXHWND3D5sFq2gAbvk8nROt3dSkt63uvEMrG/nqUI93DKcMUR41CbU7LOiLObwoLlI5BVTaQHPn2cSJOVCASz4Aoj1PNkTD/L/k/AfePbELLqLOAuWCeSE6gkoRW6CHHE4UNz1qT5yxh5Ap0mPE8OrFYD0hM3e8yI8spfP0I+jFwWnEUQSTOtzz3RYSY7LJKcgaB+FgwFRuELCgqtiCYW07bH+4881dLmHEzcuEK4Vd75rBi6G9uR1yu/9Bj5LwqOxWz2BVkSF+sxO28bDeLFaQsBKt40mvPH5Mtb1PXBTsskc4405Sb/9yXEuiVeCZb3LrWFKMY0krMkc1DKQ2VQaBpN/DlZOeawRUMSjmw2UaKWA1SLy+F9YH+srVmnAwBZ4gvee8kvedkVgU84IkF2Eop50gabJydRns8PBpASBMnQ2z5KxOJUWTwZrFNQocw 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 running in a transaction context, memory allocations are scoped to GFP_NOFS. Hence we don't need to use GFP_NOFS contexts in pure transaction context allocations - GFP_KERNEL will automatically get converted to GFP_NOFS as appropriate. Go through the code and convert all the obvious GFP_NOFS allocations in transaction context to use GFP_KERNEL. This further reduces the explicit use of GFP_NOFS in XFS. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr.c | 3 ++- fs/xfs/libxfs/xfs_bmap.c | 2 +- fs/xfs/libxfs/xfs_defer.c | 6 +++--- fs/xfs/libxfs/xfs_dir2.c | 8 ++++---- fs/xfs/libxfs/xfs_inode_fork.c | 8 ++++---- fs/xfs/libxfs/xfs_refcount.c | 2 +- fs/xfs/libxfs/xfs_rmap.c | 2 +- fs/xfs/xfs_attr_item.c | 4 ++-- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_buf.c | 28 +++++++++++++++++----------- fs/xfs/xfs_log.c | 3 ++- fs/xfs/xfs_mru_cache.c | 2 +- 12 files changed, 39 insertions(+), 31 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 9976a00a73f9..269a57420859 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c @@ -891,7 +891,8 @@ xfs_attr_defer_add( struct xfs_attr_intent *new; - new = kmem_cache_zalloc(xfs_attr_intent_cache, GFP_NOFS | __GFP_NOFAIL); + new = kmem_cache_zalloc(xfs_attr_intent_cache, + GFP_KERNEL | __GFP_NOFAIL); new->xattri_op_flags = op_flags; new->xattri_da_args = args; diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 98aaca933bdd..fbdaa53deecd 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -6098,7 +6098,7 @@ __xfs_bmap_add( bmap->br_blockcount, bmap->br_state); - bi = kmem_cache_alloc(xfs_bmap_intent_cache, GFP_NOFS | __GFP_NOFAIL); + bi = kmem_cache_alloc(xfs_bmap_intent_cache, GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&bi->bi_list); bi->bi_type = type; bi->bi_owner = ip; diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 75689c151a54..8ae4401f6810 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -825,7 +825,7 @@ xfs_defer_alloc( struct xfs_defer_pending *dfp; dfp = kmem_cache_zalloc(xfs_defer_pending_cache, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); dfp->dfp_ops = ops; INIT_LIST_HEAD(&dfp->dfp_work); list_add_tail(&dfp->dfp_list, &tp->t_dfops); @@ -888,7 +888,7 @@ xfs_defer_start_recovery( struct xfs_defer_pending *dfp; dfp = kmem_cache_zalloc(xfs_defer_pending_cache, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); dfp->dfp_ops = ops; dfp->dfp_intent = lip; INIT_LIST_HEAD(&dfp->dfp_work); @@ -979,7 +979,7 @@ xfs_defer_ops_capture( return ERR_PTR(error); /* Create an object to capture the defer ops. */ - dfc = kzalloc(sizeof(*dfc), GFP_NOFS | __GFP_NOFAIL); + dfc = kzalloc(sizeof(*dfc), GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&dfc->dfc_list); INIT_LIST_HEAD(&dfc->dfc_dfops); diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 728f72f0d078..8c9403b33191 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c @@ -236,7 +236,7 @@ xfs_dir_init( if (error) return error; - args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); + args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -273,7 +273,7 @@ xfs_dir_createname( XFS_STATS_INC(dp->i_mount, xs_dir_create); } - args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); + args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -435,7 +435,7 @@ xfs_dir_removename( ASSERT(S_ISDIR(VFS_I(dp)->i_mode)); XFS_STATS_INC(dp->i_mount, xs_dir_remove); - args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); + args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); if (!args) return -ENOMEM; @@ -496,7 +496,7 @@ xfs_dir_replace( if (rval) return rval; - args = kzalloc(sizeof(*args), GFP_NOFS | __GFP_NOFAIL); + args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL); if (!args) return -ENOMEM; diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 709fda3d742f..136d5d7b9de9 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c @@ -402,7 +402,7 @@ xfs_iroot_realloc( if (ifp->if_broot_bytes == 0) { new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, rec_diff); ifp->if_broot = kmalloc(new_size, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); ifp->if_broot_bytes = (int)new_size; return; } @@ -417,7 +417,7 @@ xfs_iroot_realloc( new_max = cur_max + rec_diff; new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, new_max); ifp->if_broot = krealloc(ifp->if_broot, new_size, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, ifp->if_broot_bytes); np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1, @@ -443,7 +443,7 @@ xfs_iroot_realloc( else new_size = 0; if (new_size > 0) { - new_broot = kmalloc(new_size, GFP_NOFS | __GFP_NOFAIL); + new_broot = kmalloc(new_size, GFP_KERNEL | __GFP_NOFAIL); /* * First copy over the btree block header. */ @@ -512,7 +512,7 @@ xfs_idata_realloc( if (byte_diff) { ifp->if_data = krealloc(ifp->if_data, new_size, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); if (new_size == 0) ifp->if_data = NULL; ifp->if_bytes = new_size; diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 6709a7f8bad5..7df52daa22cf 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1449,7 +1449,7 @@ __xfs_refcount_add( blockcount); ri = kmem_cache_alloc(xfs_refcount_intent_cache, - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&ri->ri_list); ri->ri_type = type; ri->ri_startblock = startblock; diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c index 76bf7f48cb5a..0bd1f47b2c2b 100644 --- a/fs/xfs/libxfs/xfs_rmap.c +++ b/fs/xfs/libxfs/xfs_rmap.c @@ -2559,7 +2559,7 @@ __xfs_rmap_add( bmap->br_blockcount, bmap->br_state); - ri = kmem_cache_alloc(xfs_rmap_intent_cache, GFP_NOFS | __GFP_NOFAIL); + ri = kmem_cache_alloc(xfs_rmap_intent_cache, GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&ri->ri_list); ri->ri_type = type; ri->ri_owner = owner; diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c index 2a142cefdc3d..0bf25a2ba3b6 100644 --- a/fs/xfs/xfs_attr_item.c +++ b/fs/xfs/xfs_attr_item.c @@ -226,7 +226,7 @@ xfs_attri_init( { struct xfs_attri_log_item *attrip; - attrip = kmem_cache_zalloc(xfs_attri_cache, GFP_NOFS | __GFP_NOFAIL); + attrip = kmem_cache_zalloc(xfs_attri_cache, GFP_KERNEL | __GFP_NOFAIL); /* * Grab an extra reference to the name/value buffer for this log item. @@ -666,7 +666,7 @@ xfs_attr_create_done( attrip = ATTRI_ITEM(intent); - attrdp = kmem_cache_zalloc(xfs_attrd_cache, GFP_NOFS | __GFP_NOFAIL); + attrdp = kmem_cache_zalloc(xfs_attrd_cache, GFP_KERNEL | __GFP_NOFAIL); xfs_log_item_init(tp->t_mountp, &attrdp->attrd_item, XFS_LI_ATTRD, &xfs_attrd_item_ops); diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index c2531c28905c..cb2a4b940292 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -66,7 +66,7 @@ xfs_zero_extent( return blkdev_issue_zeroout(target->bt_bdev, block << (mp->m_super->s_blocksize_bits - 9), count_fsb << (mp->m_super->s_blocksize_bits - 9), - GFP_NOFS, 0); + GFP_KERNEL, 0); } /* diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index a09ffbbb0dda..de99368000b4 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -190,7 +190,7 @@ xfs_buf_get_maps( } bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map), - GFP_NOFS | __GFP_NOFAIL); + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); if (!bp->b_maps) return -ENOMEM; return 0; @@ -222,7 +222,8 @@ _xfs_buf_alloc( int i; *bpp = NULL; - bp = kmem_cache_zalloc(xfs_buf_cache, GFP_NOFS | __GFP_NOFAIL); + bp = kmem_cache_zalloc(xfs_buf_cache, + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL); /* * We don't want certain flags to appear in b_flags unless they are @@ -325,7 +326,7 @@ xfs_buf_alloc_kmem( struct xfs_buf *bp, xfs_buf_flags_t flags) { - gfp_t gfp_mask = GFP_NOFS | __GFP_NOFAIL; + gfp_t gfp_mask = GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL; size_t size = BBTOB(bp->b_length); /* Assure zeroed buffer for non-read cases. */ @@ -356,13 +357,11 @@ xfs_buf_alloc_pages( struct xfs_buf *bp, xfs_buf_flags_t flags) { - gfp_t gfp_mask = __GFP_NOWARN; + gfp_t gfp_mask = GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOWARN; long filled = 0; if (flags & XBF_READ_AHEAD) gfp_mask |= __GFP_NORETRY; - else - gfp_mask |= GFP_NOFS; /* Make sure that we have a page list */ bp->b_page_count = DIV_ROUND_UP(BBTOB(bp->b_length), PAGE_SIZE); @@ -429,11 +428,18 @@ _xfs_buf_map_pages( /* * vm_map_ram() will allocate auxiliary structures (e.g. - * pagetables) with GFP_KERNEL, yet we are likely to be under - * GFP_NOFS context here. Hence we need to tell memory reclaim - * that we are in such a context via PF_MEMALLOC_NOFS to prevent - * memory reclaim re-entering the filesystem here and - * potentially deadlocking. + * pagetables) with GFP_KERNEL, yet we often under a scoped nofs + * context here. Mixing GFP_KERNEL with GFP_NOFS allocations + * from the same call site that can be run from both above and + * below memory reclaim causes lockdep false positives. Hence we + * always need to force this allocation to nofs context because + * we can't pass __GFP_NOLOCKDEP down to auxillary structures to + * prevent false positive lockdep reports. + * + * XXX(dgc): I think dquot reclaim is the only place we can get + * to this function from memory reclaim context now. If we fix + * that like we've fixed inode reclaim to avoid writeback from + * reclaim, this nofs wrapping can go away. */ nofs_flag = memalloc_nofs_save(); do { diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index ee39639bb92b..1f68569e62ca 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -3518,7 +3518,8 @@ xlog_ticket_alloc( struct xlog_ticket *tic; int unit_res; - tic = kmem_cache_zalloc(xfs_log_ticket_cache, GFP_NOFS | __GFP_NOFAIL); + tic = kmem_cache_zalloc(xfs_log_ticket_cache, + GFP_KERNEL | __GFP_NOFAIL); unit_res = xlog_calc_unit_res(log, unit_bytes, &tic->t_iclog_hdrs); diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c index ce496704748d..7443debaffd6 100644 --- a/fs/xfs/xfs_mru_cache.c +++ b/fs/xfs/xfs_mru_cache.c @@ -428,7 +428,7 @@ xfs_mru_cache_insert( if (!mru || !mru->lists) return -EINVAL; - if (radix_tree_preload(GFP_NOFS)) + if (radix_tree_preload(GFP_KERNEL)) return -ENOMEM; INIT_LIST_HEAD(&elem->list_node); From patchwork Mon Jan 15 22:59:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520252 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 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+rSFa6ZUR2A0WgMO0nZNy5zjX1KiBbINUmFj4+9/XVZPy+AMNgw5VH2KOJKLDt+BFnL355ZupQww8Td7wu3PAgs2mtj8jaX1GwDXQckDmaSsj1aklfTOlhrQTCA4RNq9NzFSUfA5N0mf2wlBImtK/1btWJvGu7+dkZM86O7Tn9YdgBBihMFYzVp/i0eRMc0URjRjPnb0AIiKUzSpn3TztlIbM2BeH1ceJsp2UxvZs6thRsAmBVt2oBaj2Qq3Q6tqrYf0rvLsu8T8Dj3O5EH7UY1ADFr1r6wcR9ie1SXTshBLTRh7mEJDxrQyJn6bDuEnvyYBzgCB/AvF7jLHob/nznW+wf/IcTVlUjKVOp+Wh/ZtCfkxvNYDSwgsfFS6G8HqBTuo07ktBcXEX8Ff52n14P3VXnISGGUBio3Zss8TVfmjpMg5Z8rhuJmlwn/5QJ28ZbqQjKpEnORgAfKXBbj5DBdfx/EZQhJhk2dIeu3jHL8ITPrs9+hDKQ3easoNQGTh7iRVSX+atPdz0MWw6/MNbroVGJE4cMtRcX5fbSVy+00Gbj4uhOD8z1S7A1Zg9hw2djsaFv6oNPJtNrS00dOlUI/YPzQiyibMdJigpJgK5/RQHJgWIoCu7/bTv04ZT65RLA9qGPYHGCttBJMiigQXlCGhQnMJIHAv1XBEa1Xrk48/WgDYZSe1o208KSqSe2U4qefk yB4GStIx +c/XX/pcyRDZLhIHrJOPPifwWqRsKDapMTZFYfzUwECxz3+LZdqfS4TGQzUPPxPWO6KLYdIpeQDGHPrlvAnv/CNDv0u0xac3hu2WX0657hijTWDvuK5xS2KXnSKIs1107bIIxhIBnSl2O6X1InNTK+5glFvy4N41PLbcaP+9FCTEA3uTJfuIQ8bLmUYFixPi9+ePPQYp4BbOwuc7S92wAcm2oBVqfEhgWHOPFZyTPRM+ThzeZZdpOHXG+Hi5thPS8AcOSy3JsNVS++kWUl4C/ldqv54Fpro9DB2ZbEwsm8ThZJMvNehs7Rm33SkO7xRstXBex1seLi58bekpF3nKAucZIAnAggVdOFOmTuEWWZu0ucrwswpr68nLgtZYIimE+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 Reviewed-by: Darrick J. Wong --- 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: From patchwork Mon Jan 15 22:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520258 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 91E2DC3DA79 for ; Mon, 15 Jan 2024 23:01:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F9B46B007B; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1847A6B0080; Mon, 15 Jan 2024 18:01:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E54DA6B007E; Mon, 15 Jan 2024 18:01:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D1B2D6B007D for ; Mon, 15 Jan 2024 18:01:24 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9FF4F1A05E7 for ; Mon, 15 Jan 2024 23:01:24 +0000 (UTC) X-FDA: 81683068488.29.1E236C0 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf04.hostedemail.com (Postfix) with ESMTP id A41A24000B for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=B0ts6bbZ; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf04.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.181 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=1705359682; 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=XTU7Fr08s4rUxky9Yys2MV8QifwgSoaYIdZvg8gWTFY=; b=zlqJzVTVcN4bF5VtmOLZRdYpl8pIs0qnjF38XjFwYBiB7ZlpvMG9K0I4alPejB2uRwQplx I38iKDPv4FJUdtI2e3sJ0oLScQ2SyOVXi6Yp2AzkSvmzxWr/cqnnYg3zLMNVBtl0EInM7O iLJJs1buJlXHsiyd2iSPyXF+9cxL704= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=B0ts6bbZ; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf04.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359682; a=rsa-sha256; cv=none; b=E1koPwrkno0XeK2l40p7t9W0iRP8rXGKPSrggdHc9mxSrgUz+wn0itwAjKpH9+de+DyFvV 1NeH04JSyqxcGZ9IVPk2gIbP+KUxfcqwJEYL3mjZ77i743BHy+p2OD7fxEjwRGsNxNGthi czSyzlNJvLy6Ft8pMwMLBt8xrrp2G/g= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d44200b976so49058275ad.2 for ; Mon, 15 Jan 2024 15:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359681; x=1705964481; 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=XTU7Fr08s4rUxky9Yys2MV8QifwgSoaYIdZvg8gWTFY=; b=B0ts6bbZoEVUkgaAZD5t2gUkpEWLfx046YwKBwfs3TDLSQqnxFzQWULkjcARpB0Y6M Rd0HAvZi3rFVhh6w5y/LC5HWiZIaZzUR5/uYqzhPoirj6q4xHlYtz2Gv6C01gFXm5hde Tm646q48S3FvzLOC5gELHLyDLljLpDyHYPZ2EuXFpHu91Tw2BliCOeR5/+G8t0yBLBxA /Q4E7U2otfnBfiQnhI/2/vehlmlOUkIGFQr+z6v17ID5r0im8hpogmw4IR5xr6kF4iXU WZLDoyw6lRGgaV0AvXcHjAltAF4OFIOAbcbo29arbYP5usStZYuQKC0QBkU/3uPI+RXz p7gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359681; x=1705964481; 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=XTU7Fr08s4rUxky9Yys2MV8QifwgSoaYIdZvg8gWTFY=; b=WOlfMl7VaQ/VBAV0GLzw2C1arvpI93/NKbyaR1PZAx2s8YZjhqXPtYB794ebpUxxjG 2Rr5qJ9ZuEr6eOQSAMN8IP2cwt8ruuLUUKz7quKldzQAeelpWt4BQKcN6pCLFk4eOKuz ffVymLa4i1oXCRRMgG3DZgdqHLzkxpOw4p9x27Jt7cBW3Ov4BmKbf0i/hXaVKcqy/gHI 58VjWVgSpgiRJRoz8DjQ4KHTo0dNw+dZTWox+A2TWkNupquB9CCdOLMqVvqlEKAM9Yqm D2mzzlgy4tN3PurMDEIo7V3/yiICmw9JFR2WGoQE65IYWMBCSCUtDGk3rCj3hKRqvaVG ppPA== X-Gm-Message-State: AOJu0YxFRwrlQde8K4ndeQeP1qmr3P494pfcCwUkkrI7DvT1W+1eyKjM QeZ1CmbXxUyvXFrqKlA2nZhJsTdHVO/k7mFiBuWkJOEfVwQ= X-Google-Smtp-Source: AGHT+IGNiHk1RuGG1sc4v4L0zJg68Gv9p9I32eJCDEJ/+w/GY8Au5JZTtLDF5HjZXmrnuOPcXmWQew== X-Received: by 2002:a17:902:c78b:b0:1d4:1bcc:416a with SMTP id w11-20020a170902c78b00b001d41bcc416amr2727232pla.30.1705359681657; Mon, 15 Jan 2024 15:01:21 -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 jj7-20020a170903048700b001d472670a30sm8176436plb.162.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-00AtKR-0v; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8g6-3Een; 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 10/12] xfs: place the CIL under nofs allocation context Date: Tue, 16 Jan 2024 09:59:48 +1100 Message-ID: <20240115230113.4080105-11-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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A41A24000B X-Stat-Signature: fapxqzqef7c3jggnqkccnupmco5mm6fy X-HE-Tag: 1705359682-163513 X-HE-Meta: U2FsdGVkX19tpCVTFCj4BmRk42aKG/7rRjQ7JPvyEGR9gzwF5Fp6gbEOtV3ZPsyfh/N3IDcXiUzwvIuBKcYEqtLWWMeAw9CZ7KwIta0DpDrBL1QMIquBXUzv2feCGgS9HLSTBFtrCKqIrcwNh2f4veIGdZJsac7Ok1Ec8EkXTyhpClunFLgPILfTW/QgfcUS/4OWkQ8iXrOrLf+MuI+v9NgyDvgZqk9PcW2wWt8GSGtHX8Wb+Obnfy6+Lh0Zeikmq2/ujY1T1ADSogSFHTVd9BLox4+u5PX6KtStCeCsIXjlfjWC9OCJ/fRGpyTdsEqRD2uPgkGwUYEv15iV8cMKkQEEFdz+Miv8C4fxH+bzrgpsucH3EeTHPPW+HpTudQCgsCOC+XONABdjFA4bPUhelKJXq4XzMJbYFUbcgn5LDx/iKy2cyE/TusuC8eF+XxbRy7bIQXurktin0NE23kBcVlUUJpE86ocI2ab/vq3MApcAs+tt//jgcucUUhumD1N0fnlKlSKpi739h6Qnzg3cnJ2r4OqxRRHmY+7t/XxOS6GMhNGhfnao3sq6/tkf21s9fDWb4amtVl3EQoQ0S/GW25Kfvm7FSeBIoBwkEsvjHEwRdhyM+iIk36JevAx8GLNtk3PGrnEyJfKyTQiCENokR7+8NLXI64CfvxECEmDqoovPWGc+JTvrtJCRYIasUKhyST21L0G5Rrh6VhkakBAXCGHWfW4CdusIDL0jIGBbRQhiAuTMjx6nBJ+WiM1C1Xsp93+muHBUOSS0rj+yHpiVA/eS/7DxxKK+QFMw5QFHHbPdeWBh/xfRwnGbvFOxMsWky9TXJtv0brbydFMSZ5zoJ/zRzTffg+zUCe6BqQcWLB+3OLHAauGlXKMY3b2MdoTDiKocJX0uL6oz/LoZvLseDfwt7muxAz0dnGfsDqQRI0J2El2Jc0EvhZZ+b9gImvDwQvSLCYDI83gBoqBDdb6 XV13TaIG GsQtkZv65E/Y42YxDaWoQHxGHaRVPBM+c4OnfrwgB8bcvTc+lvAYe515XyQvMWat3Sou0VFYwmvIZQozxgao961zpqslG9fnVd+rONY/miSCvmmqXZb3kVgJqfux1D8IFBt98RToaO79tlrAAXjGTbBXm+61dO/hEOycsWJIoaTRNuBk97WzhNOZAcZSNyU6iPDCF7NYv5EIWS75Yx9e/Kr0qqVOMcSmU55Qq1UFf/Dp9KTkM4sbPjo+051G5hnDodF6WddcZFN7kr8a6oyPTNkXrELN1m6RxcFqST8zBis6hAePTW1aFs4PgeW7EAhPFoO8ZS8wfhRl56Qej6pe+bDs4jT1Bc64Jb1rjNKTnIYantuyDjV0ZNHGGCo38/fAfi2wl+ORbg3nS/JoFt/bAAC7RYOtkipEwWC8s/RQtzX7hWsDU88DM+ME5arBmEycX2uYzWlZhi4HxBDagMy7XMS9j1dXGaow2L5A4rmd0yt+Yl9k= 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 This is core code that needs to run in low memory conditions and can be triggered from memory reclaim. While it runs in a workqueue, it really shouldn't be recursing back into the filesystem during any memory allocation it needs to function. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_log_cil.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 815a2181004c..8c3b09777006 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -100,7 +100,7 @@ xlog_cil_ctx_alloc(void) { struct xfs_cil_ctx *ctx; - ctx = kzalloc(sizeof(*ctx), GFP_NOFS | __GFP_NOFAIL); + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL | __GFP_NOFAIL); INIT_LIST_HEAD(&ctx->committing); INIT_LIST_HEAD(&ctx->busy_extents.extent_list); INIT_LIST_HEAD(&ctx->log_items); @@ -1116,11 +1116,18 @@ xlog_cil_cleanup_whiteouts( * same sequence twice. If we get a race between multiple pushes for the same * sequence they will block on the first one and then abort, hence avoiding * needless pushes. + * + * This runs from a workqueue so it does not inherent any specific memory + * allocation context. However, we do not want to block on memory reclaim + * recursing back into the filesystem because this push may have been triggered + * by memory reclaim itself. Hence we really need to run under full GFP_NOFS + * contraints here. */ static void xlog_cil_push_work( struct work_struct *work) { + unsigned int nofs_flags = memalloc_nofs_save(); struct xfs_cil_ctx *ctx = container_of(work, struct xfs_cil_ctx, push_work); struct xfs_cil *cil = ctx->cil; @@ -1334,12 +1341,14 @@ xlog_cil_push_work( spin_unlock(&log->l_icloglock); xlog_cil_cleanup_whiteouts(&whiteouts); xfs_log_ticket_ungrant(log, ticket); + memalloc_nofs_restore(nofs_flags); return; out_skip: up_write(&cil->xc_ctx_lock); xfs_log_ticket_put(new_ctx->ticket); kfree(new_ctx); + memalloc_nofs_restore(nofs_flags); return; out_abort_free_ticket: @@ -1348,6 +1357,7 @@ xlog_cil_push_work( if (!ctx->commit_iclog) { xfs_log_ticket_ungrant(log, ctx->ticket); xlog_cil_committed(ctx); + memalloc_nofs_restore(nofs_flags); return; } spin_lock(&log->l_icloglock); @@ -1356,6 +1366,7 @@ xlog_cil_push_work( /* Not safe to reference ctx now! */ spin_unlock(&log->l_icloglock); xfs_log_ticket_ungrant(log, ticket); + memalloc_nofs_restore(nofs_flags); } /* From patchwork Mon Jan 15 22:59:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520263 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 B19A7C4707B for ; Mon, 15 Jan 2024 23:01:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F8996B0081; Mon, 15 Jan 2024 18:01:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DE2F6B0082; Mon, 15 Jan 2024 18:01:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30A5D6B0087; Mon, 15 Jan 2024 18:01:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F19596B0089 for ; Mon, 15 Jan 2024 18:01:25 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CA9C11C127A for ; Mon, 15 Jan 2024 23:01:25 +0000 (UTC) X-FDA: 81683068530.11.6CFAFB9 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf18.hostedemail.com (Postfix) with ESMTP id F3D511C0011 for ; Mon, 15 Jan 2024 23:01:23 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=lMeeXKAM; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf18.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.182 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=1705359684; 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=3LJife0DkUSCWANql4//DrwcmVy3A9Mu4G9yC26ZmxY=; b=bJXatoiSEp6a9E+ZtrHfXbQtYgYxlfbJNfQ1WbdpheTengCfsf5Z0CQjtTlgiLHDETFEFl z0VKasilrEZmPHCsomL6OUj1yysbOGqRdbeZHuCtu53vEKt8bhBftQiRwtKFYZ8kM53PUh IE3Nj2T9kY2PpRu22YprdzDyzmy1PSA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=lMeeXKAM; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf18.hostedemail.com: domain of david@fromorbit.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359684; a=rsa-sha256; cv=none; b=u1H3OXvFMKZtk5SzHE0Xm6cAyRriJt5d2d/ioLOHzlm+dbNmKWGrx/4N6vUpZ4jUehPMcB EITXS5nEeoW7s+S53BAbxE2TMYzJ1UURGHlLjohzcvBb7jL7oKNUp3kGbSzVKrbkTi+6Vi Sza4YIX2aArozY0W1MXEUNbp0BqdVvM= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6d9f94b9186so7686733b3a.0 for ; Mon, 15 Jan 2024 15:01:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359683; x=1705964483; 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=3LJife0DkUSCWANql4//DrwcmVy3A9Mu4G9yC26ZmxY=; b=lMeeXKAMJ2nlkGb1sswnAu/o80AWeZSR8687jyQGgkcPFBFXPeRNy8f+1EfBVTipVZ UpBJnTguTdbbb4QE5ikyol/EcaVkei7ZR+nHs62qrZGxOlkOA4htt1G9AAIGMj88H08H b8VmIw1n0lGHAE+05m5/GwCa/po2kUMMYM03O/9gfuSNnpmgykyaN0WIzCB0+ZBkH0C6 slANpkI84Y0khOSxPPLmIoXyWoRafDdWqbwA+LpQrYURgOWVsQp6DCAG2lL8yWCEWjWX vGrpGtZ5gUy+cKC4NGmqmCcrXuhTfasGmcmQp5jHpIH/baVpNftkLZUIyF8xErHTDfUS Mw6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359683; x=1705964483; 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=3LJife0DkUSCWANql4//DrwcmVy3A9Mu4G9yC26ZmxY=; b=g/lr/bjcuhaDKLOYqQWCMNzE4fNZ7i0wosNhu0dDWGLJAqVzE7pPbPgnsvpaw/xQw8 nmNsKV7pxY/hA7vSmXkWp4iIytp630WcDRHfZGBN7oJiOmbXCK8WCb65yI7hPY8SVIRl 2lnWdz2M5ZkC5YnMVJc8DnqFOWw7N3FZTaMaT6HXeg8ClYjyT2ooOMZJKDoOD1AjaIUE PTWsu31Ri3v7ZSi+LxEmuAzycNc4f0sXyw2pttvYL0ob8Cl4ufRZIG6GKWaBRaNxX2bz Ey55UiBbMUuSd9vMC0w4NZV9KrsSP3lFi+jDzr1DolETMEdDIybVd5gWhoQWymy2NLcm G++Q== X-Gm-Message-State: AOJu0YyT/LkDV8Z28qwr6Da1RfU3L6t7ZWVA6vakUrLlXZSjWKMBr0vo ri1eb2qlpU+1WBIDhBMlksdY6t1/IWVOy48ufRKNHlNV5+A= X-Google-Smtp-Source: AGHT+IHuvnJ8hiLAOei7LMgoGrEcANGg1wnR1tJpH4QRdpptY/qungv5tMun/Ja8vcEiUVKBDoAqbg== X-Received: by 2002:a62:8142:0:b0:6d9:8d46:814b with SMTP id t63-20020a628142000000b006d98d46814bmr7449168pfd.20.1705359682966; Mon, 15 Jan 2024 15:01:22 -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 b12-20020aa78ecc000000b006db105027basm8081256pfr.50.2024.01.15.15.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 15:01:19 -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-00AtKW-18; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8gB-3MLa; 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 11/12] xfs: clean up remaining GFP_NOFS users Date: Tue, 16 Jan 2024 09:59:49 +1100 Message-ID: <20240115230113.4080105-12-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 X-Rspamd-Queue-Id: F3D511C0011 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1nnoogexm67nnjcygyotgmmpcso3kfxm X-HE-Tag: 1705359683-115558 X-HE-Meta: U2FsdGVkX198vqE6LyxK5mteyA1wlkTVDajrvyGs1j3jx+HGR/GkVD15Ib8k1qp31AdXBJ66trhaxZBnkhl9r/ofSocWWaejgyQHZDtg+cvPBEEKU21ETYZBS/YNZkpv99yfrwdLdbF7xFWk2UkF36Obeyqwjz9uW95u7wMl63y2Q1n699zDEOofIT6XRPG88VTllTJ3yCX9PWFyAngRHiD2Wk5/J8dyW3it9ZPSCxPoh5Fw5ROBmoD+6QlK0S3atUAQLtTfu4z6xqhsgYE2BR5N3rPUEKJHAipR5pWRO6lTDTHz0zN1ni7HBSQ6S5X8i18w9HGPAT5ZP0u07nbF6eMyXItgPzzkYCgVP3GRmZPoPZ+Cz8280YhE6vzMJ/IDNGZWJN1eWpykcRY4Jx/RCA0LSitzOxUjol7gu65+fMOHZBRMOitBvQnEpPkMC22kR4DMKMkAvWODJTVZtoMC2ymR7N3k1Pg5toFRUSN/jelnYkKU89TFlruPc7f2L3KGpCTJvYFu1Rpr/vUjaSNxSJf2c710arfdhbl0ox274WuQ1jPM7mf6ZGO92VuNw36G9URQ9B2uLk6UywD1CsKKf8/75r2L6N0FY8rl+U/Z9SjSJVvgUhuI5fZ3D1+ViPh3wqfTEjTnVt8wuxGbOgg3m50xjlnq3rXkk3bBPy59m4w0oRnYedxpgBDNwjO2a52n9w2HPTrGac5SjWfm1rsYILI/8xhxMAAPp1OMgMPpK8sywoJMHR4GO0USSLJqQesAROA5yRvMH5zL8+CSylo0QDmmqw95Z0YPX6NycJUzmYmRgJ0eW0JhUOTxohzQS7jQoW58Uce9iq6rS/QUmlC5fZKvFOgUbqsZE8q6bVpQcPymDaKZrrwX8PtQ1t4Cj4FqcYZUGa87cceuczJldQPetA44ABLkmEGKmgBeNMvCjlJyRWXgxwlgrX76/JRP7fYZ6I2qxWOQchvquLvjdYZ uWyoRE6y 8zpePQIyDnCFRdyEuZq0bAJrAlHkKcyXUlzlOvCdgvThK+D//lYQKnpIVeq6hESQRPhAwbutNGBshUp3pOWuFFoHl2QwSJRnvXQNB0z/4WxTZ10tWU8LCDr7JwbgdlhSiahb8/vYl8jpyj7nAtaO1pxONvL7WNZt7ITGI26GzHhkcYgW5Y0WvMRRGRDWQAeCcUE3LvhwywuzjHmUINqKlR25GqR2FWXJeTiqEzX25C4p54uXjQ1t+mqaF3FpJCB+KU6ZFX/6mtivwjztc4obXq7NAUClIfdue1OqEk4m0z5J9Ojwd5fz77/TSO2XQ7hQGOShR3fd22jDisKXxpiFVgXW+kzXgTEgVdc8lDwrR55KL6U+RRLELkUURY1FNxH8RomuWmrxuOshva8B0+L2OZXw1Ks2qd4ZqC1YnvdR3Choh5DeHwSKVl8TAdyW8ePh4991obWSmrjcizd5F8QPJLTjIbqE0U4kOcYFYU3NeLB7K2ShCdMjhC7h93K+ywCBrVpFbppwwv7ZeEoios0cTAyroGA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000098, 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 These few remaining GFP_NOFS callers do not need to use GFP_NOFS at all. They are only called from a non-transactional context or cannot be accessed from memory reclaim due to other constraints. Hence they can just use GFP_KERNEL. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_btree_staging.c | 4 ++-- fs/xfs/xfs_attr_list.c | 2 +- fs/xfs/xfs_buf.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xfs/libxfs/xfs_btree_staging.c b/fs/xfs/libxfs/xfs_btree_staging.c index 961f6b898f4b..f0c69f9bb169 100644 --- a/fs/xfs/libxfs/xfs_btree_staging.c +++ b/fs/xfs/libxfs/xfs_btree_staging.c @@ -139,7 +139,7 @@ xfs_btree_stage_afakeroot( ASSERT(!(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)); ASSERT(cur->bc_tp == NULL); - nops = kmalloc(sizeof(struct xfs_btree_ops), GFP_NOFS | __GFP_NOFAIL); + nops = kmalloc(sizeof(struct xfs_btree_ops), GFP_KERNEL | __GFP_NOFAIL); memcpy(nops, cur->bc_ops, sizeof(struct xfs_btree_ops)); nops->alloc_block = xfs_btree_fakeroot_alloc_block; nops->free_block = xfs_btree_fakeroot_free_block; @@ -220,7 +220,7 @@ xfs_btree_stage_ifakeroot( ASSERT(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE); ASSERT(cur->bc_tp == NULL); - nops = kmalloc(sizeof(struct xfs_btree_ops), GFP_NOFS | __GFP_NOFAIL); + nops = kmalloc(sizeof(struct xfs_btree_ops), GFP_KERNEL | __GFP_NOFAIL); memcpy(nops, cur->bc_ops, sizeof(struct xfs_btree_ops)); nops->alloc_block = xfs_btree_fakeroot_alloc_block; nops->free_block = xfs_btree_fakeroot_free_block; diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 0318d768520a..47453510c0ab 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c @@ -109,7 +109,7 @@ xfs_attr_shortform_list( * It didn't all fit, so we have to sort everything on hashval. */ sbsize = sf->count * sizeof(*sbuf); - sbp = sbuf = kmalloc(sbsize, GFP_NOFS | __GFP_NOFAIL); + sbp = sbuf = kmalloc(sbsize, GFP_KERNEL | __GFP_NOFAIL); /* * Scan the attribute list for the rest of the entries, storing diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index de99368000b4..08f2fbc04db5 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -2008,7 +2008,7 @@ xfs_alloc_buftarg( #if defined(CONFIG_FS_DAX) && defined(CONFIG_MEMORY_FAILURE) ops = &xfs_dax_holder_operations; #endif - btp = kzalloc(sizeof(*btp), GFP_NOFS | __GFP_NOFAIL); + btp = kzalloc(sizeof(*btp), GFP_KERNEL | __GFP_NOFAIL); btp->bt_mount = mp; btp->bt_bdev_handle = bdev_handle; From patchwork Mon Jan 15 22:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 13520257 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 03702C3DA79 for ; Mon, 15 Jan 2024 23:01:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC7F6B0078; Mon, 15 Jan 2024 18:01:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A5BFC6B007B; Mon, 15 Jan 2024 18:01:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8862C6B007D; Mon, 15 Jan 2024 18:01:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 779966B0078 for ; Mon, 15 Jan 2024 18:01:24 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5A0581A057D for ; Mon, 15 Jan 2024 23:01:24 +0000 (UTC) X-FDA: 81683068488.01.563814F Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf14.hostedemail.com (Postfix) with ESMTP id 52204100014 for ; Mon, 15 Jan 2024 23:01:22 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=2IFZG6+1; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf14.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.41 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=1705359682; 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=tgxEN+dxuPsIPQ/X2jxskuPK8v7LK84zp/ZH+sCdiJw=; b=u3VuyuY4fA3Ct4xsaf2hb/pGRGiVZddrrzlvTTf8Qh9ySBQ8vZqEzjpqxfQUyesCdRY1eq Jr6LSCiDkr5QASPcfp6feBTMZOwfQs6eooHI1WalHuUxI+5EDTQHQcst4E78tUXNskbgCi yDysDJo56QvU84IGTlrZgMq7qfWB66o= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=2IFZG6+1; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf14.hostedemail.com: domain of david@fromorbit.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705359682; a=rsa-sha256; cv=none; b=B5jNGuQGp0cId3pQtw2UPHw62p37bT4T6LayrKaNgfRQLbRHjXuSVVFIk5dvObx9/1/0SN 9caCJREjZg8eZ8cW8NyxTJ8bpiUti5l181olkXWMiqaqSrY05tLg3Ev151kdj0OpBTEBaV VEqMPlP5F3hPUUMYFPEGGQQmOmRY2iw= Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-28e724d9c47so84599a91.2 for ; Mon, 15 Jan 2024 15:01:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1705359681; x=1705964481; 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=tgxEN+dxuPsIPQ/X2jxskuPK8v7LK84zp/ZH+sCdiJw=; b=2IFZG6+1sFzruNjwBiC+5OZNuE4YHVYH0s0Jv2OULDuKdfZHLey2lYTpAa9MqMlb/M Xx9JS1qj3OEyNIsaqrGUBIRViiou4bC/pmQEKdz2s8fTCgBfWDlqOWz+I9CBOQLNwHgf wGjD0hOYOAUhCjS1RL4fKQehSjVfmxVcWLY2nV8UHzQ+Mnznx/PAaCY7WyBoM33ggWXZ +1I6xij7sRm8nUxrZlpdAMRWJ3LPyghAunqncG7B3O7hI1X9HlVax232TFTCzmRfmdLB +uPMYTr16gJ0HC54A/htEg6cYtcd5f3hIW3lLXIac9jHdVEc5d2RM06czNOLyA0If4PE NQcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705359681; x=1705964481; 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=tgxEN+dxuPsIPQ/X2jxskuPK8v7LK84zp/ZH+sCdiJw=; b=wTwdE4zNM3slKffWnxLGVC8moklDh4puTtaf5AgHnF/SzRXalv6Ibo4/fl5v7mdaHu pzTe08aMrDT+Pz8OzykI+W0I4/bNn6REu4+cfDrZjwQX7O/eVm9ZP5v1SeeKfT8E9W/Q 1RgcEB07hhela3poTG3roGOO5UVT41SprZbroGo7fA/HMh01k5nJxWgfGswQ4QbEoIfW 85zexH/rAU0xSVo15mNbFQ7ejAL8KUHBN5dTN/T/zF9o+bL+JDNbIiZdXk1Ab02TZkfR gspLuw1SdYomvrYdXj7K5IZqDESkEy/v9zCRnJCC3Z7fyw+e0reoUKqsDK28JfQPe/6V z9ww== X-Gm-Message-State: AOJu0YzdudWFAuj2K745XkH0e+5BnxmO8Fit8NPzkBxVDn19W1ivmkzM yuMZtdWCdUkf/ncsV52omaaVospXDPKHOVXMReeWc0tC6YE= X-Google-Smtp-Source: AGHT+IGzpNwsKNu7NVgPnlnsyEIybtI/t9LRuDCZhvbpZAVN6r4/IhKNwivF+6D2KG20ozQ0wahSCw== X-Received: by 2002:a17:90a:e01:b0:28d:2cee:119e with SMTP id v1-20020a17090a0e0100b0028d2cee119emr3549236pje.39.1705359681331; Mon, 15 Jan 2024 15:01:21 -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 sh2-20020a17090b524200b0028dfdfc9a8esm8737391pjb.37.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-00AtKZ-1D; Tue, 16 Jan 2024 10:01:15 +1100 Received: from dave by devoid.disaster.area with local (Exim 4.97) (envelope-from ) id 1rPVxD-0000000H8gH-3WIC; 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 12/12] xfs: use xfs_defer_alloc a bit more Date: Tue, 16 Jan 2024 09:59:50 +1100 Message-ID: <20240115230113.4080105-13-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 X-Rspamd-Queue-Id: 52204100014 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: mp9tbpxrokbcehgihsc4oiqaop73fzh5 X-HE-Tag: 1705359682-213934 X-HE-Meta: U2FsdGVkX19ernfrQl7t0YOanLphRxSgimPjNnFQh44Um7ASqgA+jhBbKC8G1cRdu/WpCjOFnp668hKmw08JTkpLZjDOZobf10dW3d1tF41e77z4qYjEzO856ILtmk6JFFf2m4o9XTxJi+CcQWNXU3euI2ZOEmgYzBwbuoPF5MOFIcLpv/zl80XukbLCjVip6bFRTkHNA40UwuPDD1ztidorq2locLD2SJcrk/Y6IOVj14Vh9y6eui+sGtHfV/jrQ4XavBP5ofBlUE3IY0fX9g2beq+4L3rTKRIGWPDU6lHfqgcB6YZRVpiq9y+tvH2ZM6Rfs1fAJ8RJ4wLVp3O7PeSXTedJ+LoCiOwYmkSAI8B78bNTtkdU7EDWSOEkARm9lrtG4aoBtfZFbjuZXsGBgWP7oJkCyPvjUuizL5Igz7TYsMGkHv6IPPG04oOAsZPSjKSWGBm/OljF4rSSxBnwQcV4CrvMJ6htif3rb872aiqaTAsN3Zwp2rKxsf8ADhc/WoeQQVW6Aib3i6YwtJ8e7mR005IYCULRlpteZwxjD3I0ahweimQwV2ma5GuRMPSCnApo9796TL+1MHkEY8FqdN4w1sa0eFgOjUlxwHw67PyZFDBlvWAvhFP2onKGThILdD/8JlTk8ZqojEuKNdL0sQxmNLNp8tbxUCbcD5z4t2iKiZY4DiwIYzx7pIKxcVzHyKASRg+k5esSpgwK8bLPfIIoyWp57IptM1bDqd23aFtzooLcL7JZWAgLFYP6A1tTwhymkoY3tp9izUXxLEvOO6EXHQQknScVOKWPdRcRuJhaBI5g9RlKDDb2/plDeo540LDsELnUsn9jptzUr9M8AaT8BH8TRdwrAaUQfhFYow5oXzaIb+ioBnvD95IZMzqGn4c1v7vR/TDoNZcJf6fD3uQlCn1s0B07eaB8kz7KckJmVRFHZBNLpgutPFUbfgXJOv4nXohps3bj0Henpkv jeYUoOHI L5YqldMIRqoKTOPrT6BRDnMhXNFdpebzsJp20iwbTsLnjsstDByzHwr0cY3GYNfc4pxJvfYcBEvwMF2OwpiRle4adGCYjZ456i/aX77QlmkxvJI6Jw6GmtuxevFRhyFkG7BmllSN5PcOswHjUXuwD25rZLkDtpmGvW7pUJOAJAp53ZMnRsP2twB9iH2OIqjp/FOwTpapzajF/BpDx/fnhNWXcYoELGYi3OBrf1t+34MMA/bfaReC8rAM2OFwLatrtfrasrbuUsZ8kR36J/EHdX6UdAQe+ueYwVkkgEVdpJ30cIVkblOUZaSRpLkHwqidtQvpd39RYYGBImmjWohRLdlSDX0r+AnV9moqf03s4HY6IRVfiY/9LpArqBDCkLfAtYulLlW+EOT9L9gppBSOPPBklg3xiN4zAr+ek7FRKueJJTQ/2qMpL+Ll7Exu27Y6W0rCXcAXXjDWawdgG7n4FckCpDWCei3olqgixntQGsaHevoeH1BSKx/JPAsyMYI/11jq/MSwc4P9Lib633/0hflTCsA== 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 Noticed by inspection, simple factoring allows the same allocation routine to be used for both transaction and recovery contexts. Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_defer.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 8ae4401f6810..6ed3a5fda081 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -819,7 +819,7 @@ xfs_defer_can_append( /* Create a new pending item at the end of the transaction list. */ static inline struct xfs_defer_pending * xfs_defer_alloc( - struct xfs_trans *tp, + struct list_head *dfops, const struct xfs_defer_op_type *ops) { struct xfs_defer_pending *dfp; @@ -828,7 +828,7 @@ xfs_defer_alloc( GFP_KERNEL | __GFP_NOFAIL); dfp->dfp_ops = ops; INIT_LIST_HEAD(&dfp->dfp_work); - list_add_tail(&dfp->dfp_list, &tp->t_dfops); + list_add_tail(&dfp->dfp_list, dfops); return dfp; } @@ -846,7 +846,7 @@ xfs_defer_add( dfp = xfs_defer_find_last(tp, ops); if (!dfp || !xfs_defer_can_append(dfp, ops)) - dfp = xfs_defer_alloc(tp, ops); + dfp = xfs_defer_alloc(&tp->t_dfops, ops); xfs_defer_add_item(dfp, li); trace_xfs_defer_add_item(tp->t_mountp, dfp, li); @@ -870,7 +870,7 @@ xfs_defer_add_barrier( if (dfp) return; - xfs_defer_alloc(tp, &xfs_barrier_defer_type); + xfs_defer_alloc(&tp->t_dfops, &xfs_barrier_defer_type); trace_xfs_defer_add_item(tp->t_mountp, dfp, NULL); } @@ -885,14 +885,9 @@ xfs_defer_start_recovery( struct list_head *r_dfops, const struct xfs_defer_op_type *ops) { - struct xfs_defer_pending *dfp; + struct xfs_defer_pending *dfp = xfs_defer_alloc(r_dfops, ops); - dfp = kmem_cache_zalloc(xfs_defer_pending_cache, - GFP_KERNEL | __GFP_NOFAIL); - dfp->dfp_ops = ops; dfp->dfp_intent = lip; - INIT_LIST_HEAD(&dfp->dfp_work); - list_add_tail(&dfp->dfp_list, r_dfops); } /*