diff mbox series

[1/4] xfs: make GFP_ usage consistent when allocating buftargs

Message ID 170681336549.1608248.12420061312909852988.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/4] xfs: make GFP_ usage consistent when allocating buftargs | expand

Commit Message

Darrick J. Wong Feb. 1, 2024, 7:56 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Convert kmem_zalloc to kzalloc, and make it so that both memory
allocation functions in this function use GFP_NOFS.  Also, kzalloc can
at least in theory also fail for small allocations.  Handle that
gracefully.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_buf.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 79a87fb399064..ebaf630182530 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1969,7 +1969,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
@@ -2018,8 +2018,9 @@  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);
+	if (!btp)
+		return NULL;
 	btp->bt_mount = mp;
 	btp->bt_bdev_handle = bdev_handle;
 	btp->bt_dev = bdev_handle->bdev->bd_dev;
@@ -2061,7 +2062,7 @@  xfs_alloc_buftarg(
 error_lru:
 	list_lru_destroy(&btp->bt_lru);
 error_free:
-	kmem_free(btp);
+	kfree(btp);
 	return NULL;
 }