public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Julian Sun <sunjunchao2870@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: cem@kernel.org, djwong@kernel.org, Julian Sun <sunjunchao2870@gmail.com>
Subject: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
Date: Fri, 28 Feb 2025 16:26:21 +0800	[thread overview]
Message-ID: <20250228082622.2638686-2-sunjunchao2870@gmail.com> (raw)
In-Reply-To: <20250228082622.2638686-1-sunjunchao2870@gmail.com>

The __GFP_NOFAIL flag ensures that allocation will not fail.
So remove the unnecessary checks.

Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
 fs/xfs/libxfs/xfs_da_btree.c | 4 ----
 fs/xfs/libxfs/xfs_dir2.c     | 8 --------
 fs/xfs/xfs_buf.c             | 4 ----
 fs/xfs/xfs_mru_cache.c       | 6 ------
 fs/xfs/xfs_super.c           | 2 --
 5 files changed, 24 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 17d9e6154f19..d4c6ad6be5e1 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2718,10 +2718,6 @@ xfs_dabuf_map(
 	if (nirecs > 1) {
 		map = kzalloc(nirecs * sizeof(struct xfs_buf_map),
 				GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
-		if (!map) {
-			error = -ENOMEM;
-			goto out_free_irecs;
-		}
 		*mapp = map;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 1775abcfa04d..7d837510dc3b 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -249,8 +249,6 @@ xfs_dir_init(
 		return error;
 
 	args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
-	if (!args)
-		return -ENOMEM;
 
 	args->geo = dp->i_mount->m_dir_geo;
 	args->dp = dp;
@@ -342,8 +340,6 @@ xfs_dir_createname(
 	}
 
 	args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
-	if (!args)
-		return -ENOMEM;
 
 	args->geo = dp->i_mount->m_dir_geo;
 	args->name = name->name;
@@ -504,8 +500,6 @@ xfs_dir_removename(
 	XFS_STATS_INC(dp->i_mount, xs_dir_remove);
 
 	args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
-	if (!args)
-		return -ENOMEM;
 
 	args->geo = dp->i_mount->m_dir_geo;
 	args->name = name->name;
@@ -564,8 +558,6 @@ xfs_dir_replace(
 		return rval;
 
 	args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
-	if (!args)
-		return -ENOMEM;
 
 	args->geo = dp->i_mount->m_dir_geo;
 	args->name = name->name;
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 15bb790359f8..4b53dde32689 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -182,8 +182,6 @@ xfs_buf_get_maps(
 
 	bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map),
 			GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
-	if (!bp->b_maps)
-		return -ENOMEM;
 	return 0;
 }
 
@@ -326,8 +324,6 @@ xfs_buf_alloc_kmem(
 		gfp_mask |= __GFP_ZERO;
 
 	bp->b_addr = kmalloc(size, gfp_mask);
-	if (!bp->b_addr)
-		return -ENOMEM;
 
 	if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
 	    ((unsigned long)bp->b_addr & PAGE_MASK)) {
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index d0f5b403bdbe..0d08d6b5e5be 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -333,17 +333,11 @@ xfs_mru_cache_create(
 		return -EINVAL;
 
 	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 = kzalloc(mru->grp_count * sizeof(*mru->lists),
 				GFP_KERNEL | __GFP_NOFAIL);
-	if (!mru->lists) {
-		err = -ENOMEM;
-		goto exit;
-	}
 
 	for (grp = 0; grp < mru->grp_count; grp++)
 		INIT_LIST_HEAD(mru->lists + grp);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0055066fb1d9..59a600d8de7c 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -2075,8 +2075,6 @@ xfs_init_fs_context(
 	int			i;
 
 	mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL | __GFP_NOFAIL);
-	if (!mp)
-		return -ENOMEM;
 
 	spin_lock_init(&mp->m_sb_lock);
 	for (i = 0; i < XG_TYPE_MAX; i++)
-- 
2.39.5


  reply	other threads:[~2025-02-28  8:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  8:26 [PATCH 0/2] *** Code cleanup *** Julian Sun
2025-02-28  8:26 ` Julian Sun [this message]
2025-03-01 10:20   ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation kernel test robot
2025-03-06 15:31   ` kernel test robot
2025-03-07 13:58   ` Dan Carpenter
2025-02-28  8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
2025-03-01 11:55   ` kernel test robot
2025-03-04 13:58   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250228082622.2638686-2-sunjunchao2870@gmail.com \
    --to=sunjunchao2870@gmail.com \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox