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

Darrick J. Wong
2023-12-31T20:14:37Z

Convert kmem_zalloc to kzalloc, and make it so that both memory
allocation functions in this function use GFP_NOFS.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/xfs/xfs_buf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 0ae9a37cd1ddb..05b651672085d 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1981,7 +1981,7 @@ xfs_free_buftarg(
if (btp->bt_bdev != btp->bt_mount->m_super->s_bdev)
bdev_release(btp->bt_bdev_handle);

- kmem_free(btp);
+ kvfree(btp);
}

int
@@ -2026,7 +2026,7 @@ xfs_alloc_buftarg_common(
{
struct xfs_buftarg *btp;

- btp = kmem_zalloc(sizeof(*btp), KM_NOFS);
+ btp = kzalloc(sizeof(*btp), GFP_NOFS);
if (!btp)
return NULL;

@@ -2042,7 +2042,7 @@ xfs_alloc_buftarg_common(
if (list_lru_init(&btp->bt_lru))
goto error_free;

- if (percpu_counter_init(&btp->bt_io_count, 0, GFP_KERNEL))
+ if (percpu_counter_init(&btp->bt_io_count, 0, GFP_NOFS))
goto error_lru;

btp->bt_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE, "xfs-%s:%s",
@@ -2063,7 +2063,7 @@ xfs_alloc_buftarg_common(
error_lru:
list_lru_destroy(&btp->bt_lru);
error_free:
- kmem_free(btp);
+ kvfree(btp);
return NULL;
}