Skip to content

Commit 3050bd0

Browse files
cmaiolinodjwong
authored andcommitted
xfs: Remove kmem_zone_alloc() usage
Use kmem_cache_alloc() directly. All kmem_zone_alloc() users pass 0 as flags, which are translated into: GFP_KERNEL | __GFP_NOWARN, and kmem_zone_alloc() loops forever until the allocation succeeds. We can use __GFP_NOFAIL to tell the allocator to loop forever rather than doing it ourself, and because the allocation will never fail, we do not need to use __GFP_NOWARN anymore. Hence, all callers can be converted to use GFP_KERNEL | __GFP_NOFAIL Signed-off-by: Carlos Maiolino <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> [darrick: add a comment back in about nofail] Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 26270c9 commit 3050bd0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,8 @@ xfs_defer_agfl_block(
24622462
ASSERT(xfs_bmap_free_item_zone != NULL);
24632463
ASSERT(oinfo != NULL);
24642464

2465-
new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0);
2465+
new = kmem_cache_alloc(xfs_bmap_free_item_zone,
2466+
GFP_KERNEL | __GFP_NOFAIL);
24662467
new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
24672468
new->xefi_blockcount = 1;
24682469
new->xefi_oinfo = *oinfo;

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ __xfs_bmap_add_free(
553553
#endif
554554
ASSERT(xfs_bmap_free_item_zone != NULL);
555555

556-
new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0);
556+
new = kmem_cache_alloc(xfs_bmap_free_item_zone,
557+
GFP_KERNEL | __GFP_NOFAIL);
557558
new->xefi_startblock = bno;
558559
new->xefi_blockcount = (xfs_extlen_t)len;
559560
if (oinfo)

fs/xfs/xfs_icache.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,11 @@ xfs_inode_alloc(
3737
struct xfs_inode *ip;
3838

3939
/*
40-
* if this didn't occur in transactions, we could use
41-
* KM_MAYFAIL and return NULL here on ENOMEM. Set the
42-
* code up to do this anyway.
40+
* XXX: If this didn't occur in transactions, we could drop GFP_NOFAIL
41+
* and return NULL here on ENOMEM.
4342
*/
44-
ip = kmem_zone_alloc(xfs_inode_zone, 0);
45-
if (!ip)
46-
return NULL;
43+
ip = kmem_cache_alloc(xfs_inode_zone, GFP_KERNEL | __GFP_NOFAIL);
44+
4745
if (inode_init_always(mp->m_super, VFS_I(ip))) {
4846
kmem_cache_free(xfs_inode_zone, ip);
4947
return NULL;

0 commit comments

Comments
 (0)