Commit 3050bd0b authored by Carlos Maiolino's avatar Carlos Maiolino Committed by Darrick J. Wong

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: default avatarCarlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
[darrick: add a comment back in about nofail]
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 26270c9f
...@@ -2462,7 +2462,8 @@ xfs_defer_agfl_block( ...@@ -2462,7 +2462,8 @@ xfs_defer_agfl_block(
ASSERT(xfs_bmap_free_item_zone != NULL); ASSERT(xfs_bmap_free_item_zone != NULL);
ASSERT(oinfo != NULL); ASSERT(oinfo != NULL);
new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0); new = kmem_cache_alloc(xfs_bmap_free_item_zone,
GFP_KERNEL | __GFP_NOFAIL);
new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno); new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
new->xefi_blockcount = 1; new->xefi_blockcount = 1;
new->xefi_oinfo = *oinfo; new->xefi_oinfo = *oinfo;
......
...@@ -553,7 +553,8 @@ __xfs_bmap_add_free( ...@@ -553,7 +553,8 @@ __xfs_bmap_add_free(
#endif #endif
ASSERT(xfs_bmap_free_item_zone != NULL); ASSERT(xfs_bmap_free_item_zone != NULL);
new = kmem_zone_alloc(xfs_bmap_free_item_zone, 0); new = kmem_cache_alloc(xfs_bmap_free_item_zone,
GFP_KERNEL | __GFP_NOFAIL);
new->xefi_startblock = bno; new->xefi_startblock = bno;
new->xefi_blockcount = (xfs_extlen_t)len; new->xefi_blockcount = (xfs_extlen_t)len;
if (oinfo) if (oinfo)
......
...@@ -37,13 +37,11 @@ xfs_inode_alloc( ...@@ -37,13 +37,11 @@ xfs_inode_alloc(
struct xfs_inode *ip; struct xfs_inode *ip;
/* /*
* if this didn't occur in transactions, we could use * XXX: If this didn't occur in transactions, we could drop GFP_NOFAIL
* KM_MAYFAIL and return NULL here on ENOMEM. Set the * and return NULL here on ENOMEM.
* code up to do this anyway.
*/ */
ip = kmem_zone_alloc(xfs_inode_zone, 0); ip = kmem_cache_alloc(xfs_inode_zone, GFP_KERNEL | __GFP_NOFAIL);
if (!ip)
return NULL;
if (inode_init_always(mp->m_super, VFS_I(ip))) { if (inode_init_always(mp->m_super, VFS_I(ip))) {
kmem_cache_free(xfs_inode_zone, ip); kmem_cache_free(xfs_inode_zone, ip);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment