Skip to content

Commit

Permalink
xfs: convert remaining kmem_free() to kfree()
Browse files Browse the repository at this point in the history
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 <dchinner@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
  • Loading branch information
Dave Chinner authored and Chandan Babu R committed Feb 13, 2024
1 parent 4929257 commit d4c75a1
Show file tree
Hide file tree
Showing 41 changed files with 101 additions and 125 deletions.
23 changes: 0 additions & 23 deletions fs/xfs/kmem.h

This file was deleted.

6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_ag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions fs/xfs/libxfs/xfs_attr_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ xfs_attr_shortform_to_leaf(
}
error = 0;
out:
kmem_free(tmpbuffer);
kfree(tmpbuffer);
return error;
}

Expand Down Expand Up @@ -1124,7 +1124,7 @@ xfs_attr3_leaf_to_shortform(
error = 0;

out:
kmem_free(tmpbuffer);
kfree(tmpbuffer);
return error;
}

Expand Down Expand Up @@ -1570,7 +1570,7 @@ xfs_attr3_leaf_compact(
*/
xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);

kmem_free(tmpbuffer);
kfree(tmpbuffer);
}

/*
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_btree_staging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions fs/xfs/libxfs/xfs_da_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ xfs_da_grow_inode_int(

out_free_map:
if (mapp != &map)
kmem_free(mapp);
kfree(mapp);
return error;
}

Expand Down Expand Up @@ -2559,7 +2559,7 @@ xfs_dabuf_map(
*nmaps = nirecs;
out_free_irecs:
if (irecs != &irec)
kmem_free(irecs);
kfree(irecs);
return error;

invalid_mapping:
Expand Down Expand Up @@ -2615,7 +2615,7 @@ xfs_da_get_buf(

out_free:
if (mapp != &map)
kmem_free(mapp);
kfree(mapp);

return error;
}
Expand Down Expand Up @@ -2656,7 +2656,7 @@ xfs_da_read_buf(
*bpp = bp;
out_free:
if (mapp != &map)
kmem_free(mapp);
kfree(mapp);

return error;
}
Expand Down Expand Up @@ -2687,7 +2687,7 @@ xfs_da_reada_buf(

out_free:
if (mapp != &map)
kmem_free(mapp);
kfree(mapp);

return error;
}
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_defer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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. */
Expand Down
18 changes: 9 additions & 9 deletions fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -313,7 +313,7 @@ xfs_dir_createname(
rval = xfs_dir2_node_addname(args);

out_free:
kmem_free(args);
kfree(args);
return rval;
}

Expand Down Expand Up @@ -419,7 +419,7 @@ xfs_dir_lookup(
}
out_free:
xfs_iunlock(dp, lock_mode);
kmem_free(args);
kfree(args);
return rval;
}

Expand Down Expand Up @@ -477,7 +477,7 @@ xfs_dir_removename(
else
rval = xfs_dir2_node_removename(args);
out_free:
kmem_free(args);
kfree(args);
return rval;
}

Expand Down Expand Up @@ -538,7 +538,7 @@ xfs_dir_replace(
else
rval = xfs_dir2_node_replace(args);
out_free:
kmem_free(args);
kfree(args);
return rval;
}

Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/libxfs/xfs_dir2_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;
}
8 changes: 4 additions & 4 deletions fs/xfs/libxfs/xfs_dir2_sf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
8 changes: 4 additions & 4 deletions fs/xfs/libxfs/xfs_iext_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -1048,7 +1048,7 @@ xfs_iext_destroy_node(
}
}

kmem_free(node);
kfree(node);
}

void
Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/libxfs/xfs_inode_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/scrub/cow_repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion fs/xfs/xfs_attr_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_attr_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -188,7 +188,7 @@ xfs_attr_shortform_list(
cursor->offset++;
}
out:
kmem_free(sbuf);
kfree(sbuf);
return error;
}

Expand Down
Loading

0 comments on commit d4c75a1

Please sign in to comment.