]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use GFP_KERNEL in pure transaction contexts
authorDave Chinner <dchinner@redhat.com>
Mon, 22 Apr 2024 17:00:51 +0000 (10:00 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:35 +0000 (11:37 -0700)
Source kernel commit: 0b3a76e955ebe3d71a2bcd5990404ed522b40e17

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 <dchinner@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
libxfs/xfs_attr.c
libxfs/xfs_bmap.c
libxfs/xfs_defer.c
libxfs/xfs_dir2.c
libxfs/xfs_inode_fork.c
libxfs/xfs_refcount.c
libxfs/xfs_rmap.c

index 630065f1a392f28fda0fd3e818ae39cd9a866720..8356d4a3c6793a828f30089ffe9bafabe49fad75 100644 (file)
@@ -889,7 +889,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;
 
index 494994d360e4dc19e0b90a74536fdb0f177c8041..ee4e6c766144680d8a629bea1e9ccd6defcaf534 100644 (file)
@@ -6092,7 +6092,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;
index 1de3faf5ed2da6f15aaff1f582d1ba5f20377538..dae9ad57fb2ebde37a0f1f9fb26139e4c89a918c 100644 (file)
@@ -819,7 +819,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);
@@ -882,7 +882,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);
@@ -973,7 +973,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);
 
index 1a2fb999ab08c38370b6bffd8ebbdc31143658b0..914c751077535729c658ae79dac8713ddc310d43 100644 (file)
@@ -235,7 +235,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;
 
@@ -272,7 +272,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;
 
@@ -434,7 +434,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;
 
@@ -495,7 +495,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;
 
index cb1964189f5c00e2263c30fdba1cb94394834ebe..f8f6a7364d57ff9b63af642e316b32de2cd47c73 100644 (file)
@@ -400,7 +400,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;
                }
@@ -415,7 +415,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,
@@ -441,7 +441,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.
                 */
@@ -510,7 +510,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;
index de321ab9d91d46c5d4a0ffdb6ab162cedc32a0f2..36dd06e638870ae5a9382c334684f810e1c5ef45 100644 (file)
@@ -1448,7 +1448,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;
index 4731e10d2101e7ac2d288981cb48eff112f483f1..e7681c7c852db94f697d7ee1114bb2329662c2c1 100644 (file)
@@ -2558,7 +2558,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;