Re: [PATCH 04/11] xfs: remove kmem_zone_zalloc()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > 
> > diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> > index 6143117770e9..c12ab170c396 100644
> > --- a/fs/xfs/kmem.h
> > +++ b/fs/xfs/kmem.h
> > @@ -83,12 +83,6 @@ kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
> >  
> >  extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t);
> >  
> > -static inline void *
> > -kmem_zone_zalloc(kmem_zone_t *zone, xfs_km_flags_t flags)
> > -{
> > -	return kmem_zone_alloc(zone, flags | KM_ZERO);
> > -}
> > -
> >  static inline struct page *
> >  kmem_to_page(void *addr)
> >  {
> > diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
> > index 279694d73e4e..0867c1fad11b 100644
> > --- a/fs/xfs/libxfs/xfs_alloc_btree.c
> > +++ b/fs/xfs/libxfs/xfs_alloc_btree.c
> > @@ -487,7 +487,7 @@ xfs_allocbt_init_cursor(
> >  
> >  	ASSERT(btnum == XFS_BTNUM_BNO || btnum == XFS_BTNUM_CNT);
> >  
> > -	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
> > +	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	cur->bc_tp = tp;
> >  	cur->bc_mp = mp;
> > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> > index b7cc2f9eae7b..9fbdca183465 100644
> > --- a/fs/xfs/libxfs/xfs_bmap.c
> > +++ b/fs/xfs/libxfs/xfs_bmap.c
> > @@ -1104,7 +1104,8 @@ xfs_bmap_add_attrfork(
> >  	if (error)
> >  		goto trans_cancel;
> >  	ASSERT(ip->i_afp == NULL);
> > -	ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, 0);
> > +	ip->i_afp = kmem_cache_zalloc(xfs_ifork_zone,
> > +				      GFP_KERNEL | __GFP_NOFAIL);
> >  	ip->i_afp->if_flags = XFS_IFEXTENTS;
> >  	logflags = 0;
> >  	switch (ip->i_d.di_format) {
> > diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> > index ffe608d2a2d9..77fe4ae671e5 100644
> > --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> > +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> > @@ -552,7 +552,7 @@ xfs_bmbt_init_cursor(
> >  	struct xfs_btree_cur	*cur;
> >  	ASSERT(whichfork != XFS_COW_FORK);
> >  
> > -	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
> > +	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	cur->bc_tp = tp;
> >  	cur->bc_mp = mp;
> > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > index c5c0b73febae..4e0ec46aec78 100644
> > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > @@ -81,7 +81,7 @@ kmem_zone_t *xfs_da_state_zone;	/* anchor for state struct zone */
> >  xfs_da_state_t *
> >  xfs_da_state_alloc(void)
> >  {
> > -	return kmem_zone_zalloc(xfs_da_state_zone, KM_NOFS);
> > +	return kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
> >  }
> >  
> >  /*
> > diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
> > index b82992f795aa..5366a874b076 100644
> > --- a/fs/xfs/libxfs/xfs_ialloc_btree.c
> > +++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
> > @@ -413,7 +413,7 @@ xfs_inobt_init_cursor(
> >  	struct xfs_agi		*agi = XFS_BUF_TO_AGI(agbp);
> >  	struct xfs_btree_cur	*cur;
> >  
> > -	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
> > +	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	cur->bc_tp = tp;
> >  	cur->bc_mp = mp;
> > diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> > index ad2b9c313fd2..2bffaa31d62a 100644
> > --- a/fs/xfs/libxfs/xfs_inode_fork.c
> > +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> > @@ -98,7 +98,7 @@ xfs_iformat_fork(
> >  		return 0;
> >  
> >  	ASSERT(ip->i_afp == NULL);
> > -	ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_NOFS);
> > +	ip->i_afp = kmem_cache_zalloc(xfs_ifork_zone, GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	switch (dip->di_aformat) {
> >  	case XFS_DINODE_FMT_LOCAL:
> > @@ -688,8 +688,8 @@ xfs_ifork_init_cow(
> >  	if (ip->i_cowfp)
> >  		return;
> >  
> > -	ip->i_cowfp = kmem_zone_zalloc(xfs_ifork_zone,
> > -				       KM_NOFS);
> > +	ip->i_cowfp = kmem_cache_zalloc(xfs_ifork_zone,
> > +				       GFP_NOFS | __GFP_NOFAIL);
> >  	ip->i_cowfp->if_flags = XFS_IFEXTENTS;
> >  	ip->i_cformat = XFS_DINODE_FMT_EXTENTS;
> >  	ip->i_cnextents = 0;
> > diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
> > index 38529dbacd55..bb86988780ea 100644
> > --- a/fs/xfs/libxfs/xfs_refcount_btree.c
> > +++ b/fs/xfs/libxfs/xfs_refcount_btree.c
> > @@ -325,7 +325,7 @@ xfs_refcountbt_init_cursor(
> >  
> >  	ASSERT(agno != NULLAGNUMBER);
> >  	ASSERT(agno < mp->m_sb.sb_agcount);
> > -	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
> > +	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	cur->bc_tp = tp;
> >  	cur->bc_mp = mp;
> > diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
> > index fc78efa52c94..8d84dd98e8d3 100644
> > --- a/fs/xfs/libxfs/xfs_rmap_btree.c
> > +++ b/fs/xfs/libxfs/xfs_rmap_btree.c
> > @@ -461,7 +461,7 @@ xfs_rmapbt_init_cursor(
> >  	struct xfs_agf		*agf = XFS_BUF_TO_AGF(agbp);
> >  	struct xfs_btree_cur	*cur;
> >  
> > -	cur = kmem_zone_zalloc(xfs_btree_cur_zone, KM_NOFS);
> > +	cur = kmem_cache_zalloc(xfs_btree_cur_zone, GFP_NOFS | __GFP_NOFAIL);
> >  	cur->bc_tp = tp;
> >  	cur->bc_mp = mp;
> >  	/* Overlapping btree; 2 keys per pointer. */
> > diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
> > index ee6f4229cebc..451d6b925930 100644
> > --- a/fs/xfs/xfs_bmap_item.c
> > +++ b/fs/xfs/xfs_bmap_item.c
> > @@ -141,7 +141,7 @@ xfs_bui_init(
> >  {
> >  	struct xfs_bui_log_item		*buip;
> >  
> > -	buip = kmem_zone_zalloc(xfs_bui_zone, 0);
> > +	buip = kmem_cache_zalloc(xfs_bui_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	xfs_log_item_init(mp, &buip->bui_item, XFS_LI_BUI, &xfs_bui_item_ops);
> >  	buip->bui_format.bui_nextents = XFS_BUI_MAX_FAST_EXTENTS;
> > @@ -218,7 +218,7 @@ xfs_trans_get_bud(
> >  {
> >  	struct xfs_bud_log_item		*budp;
> >  
> > -	budp = kmem_zone_zalloc(xfs_bud_zone, 0);
> > +	budp = kmem_cache_zalloc(xfs_bud_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  	xfs_log_item_init(tp->t_mountp, &budp->bud_item, XFS_LI_BUD,
> >  			  &xfs_bud_item_ops);
> >  	budp->bud_buip = buip;
> > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > index a0229c368e78..85f9ef4f504e 100644
> > --- a/fs/xfs/xfs_buf.c
> > +++ b/fs/xfs/xfs_buf.c
> > @@ -209,7 +209,7 @@ _xfs_buf_alloc(
> >  	int			error;
> >  	int			i;
> >  
> > -	bp = kmem_zone_zalloc(xfs_buf_zone, KM_NOFS);
> > +	bp = kmem_cache_zalloc(xfs_buf_zone, GFP_NOFS | __GFP_NOFAIL);
> >  	if (unlikely(!bp))
> >  		return NULL;
> >  
> > diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> > index 3458a1264a3f..676149ac09a3 100644
> > --- a/fs/xfs/xfs_buf_item.c
> > +++ b/fs/xfs/xfs_buf_item.c
> > @@ -747,7 +747,7 @@ xfs_buf_item_init(
> >  		return 0;
> >  	}
> >  
> > -	bip = kmem_zone_zalloc(xfs_buf_item_zone, 0);
> > +	bip = kmem_cache_zalloc(xfs_buf_item_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  	xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops);
> >  	bip->bli_buf = bp;
> >  
> > diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> > index 153815bf18fc..79f0de378123 100644
> > --- a/fs/xfs/xfs_dquot.c
> > +++ b/fs/xfs/xfs_dquot.c
> > @@ -440,7 +440,7 @@ xfs_dquot_alloc(
> >  {
> >  	struct xfs_dquot	*dqp;
> >  
> > -	dqp = kmem_zone_zalloc(xfs_qm_dqzone, 0);
> > +	dqp = kmem_cache_zalloc(xfs_qm_dqzone, GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	dqp->dq_flags = type;
> >  	dqp->q_core.d_id = cpu_to_be32(id);
> > diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
> > index 6ea847f6e298..49ce6d6c4bb9 100644
> > --- a/fs/xfs/xfs_extfree_item.c
> > +++ b/fs/xfs/xfs_extfree_item.c
> > @@ -165,7 +165,8 @@ xfs_efi_init(
> >  			((nextents - 1) * sizeof(xfs_extent_t)));
> >  		efip = kmem_zalloc(size, 0);
> >  	} else {
> > -		efip = kmem_zone_zalloc(xfs_efi_zone, 0);
> > +		efip = kmem_cache_zalloc(xfs_efi_zone,
> > +					 GFP_KERNEL | __GFP_NOFAIL);
> >  	}
> >  
> >  	xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops);
> > @@ -336,7 +337,8 @@ xfs_trans_get_efd(
> >  				(nextents - 1) * sizeof(struct xfs_extent),
> >  				0);
> >  	} else {
> > -		efdp = kmem_zone_zalloc(xfs_efd_zone, 0);
> > +		efdp = kmem_cache_zalloc(xfs_efd_zone,
> > +					 GFP_KERNEL | __GFP_NOFAIL);
> >  	}
> >  
> >  	xfs_log_item_init(tp->t_mountp, &efdp->efd_item, XFS_LI_EFD,
> > diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
> > index 490fee22b878..85bbf9dbe095 100644
> > --- a/fs/xfs/xfs_icreate_item.c
> > +++ b/fs/xfs/xfs_icreate_item.c
> > @@ -89,7 +89,7 @@ xfs_icreate_log(
> >  {
> >  	struct xfs_icreate_item	*icp;
> >  
> > -	icp = kmem_zone_zalloc(xfs_icreate_zone, 0);
> > +	icp = kmem_cache_zalloc(xfs_icreate_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	xfs_log_item_init(tp->t_mountp, &icp->ic_item, XFS_LI_ICREATE,
> >  			  &xfs_icreate_item_ops);
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 3a62976291a1..2097e6932a48 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -652,7 +652,8 @@ xfs_inode_item_init(
> >  	struct xfs_inode_log_item *iip;
> >  
> >  	ASSERT(ip->i_itemp == NULL);
> > -	iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, 0);
> > +	iip = ip->i_itemp = kmem_cache_zalloc(xfs_ili_zone,
> > +					      GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	iip->ili_inode = ip;
> >  	xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE,
> > diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> > index 6a147c63a8a6..30447bd477d2 100644
> > --- a/fs/xfs/xfs_log.c
> > +++ b/fs/xfs/xfs_log.c
> > @@ -454,7 +454,8 @@ xfs_log_reserve(
> >  	XFS_STATS_INC(mp, xs_try_logspace);
> >  
> >  	ASSERT(*ticp == NULL);
> > -	tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent, 0);
> > +	tic = xlog_ticket_alloc(log, unit_bytes, cnt, client, permanent,
> > +				GFP_KERNEL | __GFP_NOFAIL);
> >  	*ticp = tic;
> >  
> >  	xlog_grant_push_ail(log, tic->t_cnt ? tic->t_unit_res * tic->t_cnt
> > @@ -3587,12 +3588,12 @@ xlog_ticket_alloc(
> >  	int			cnt,
> >  	char			client,
> >  	bool			permanent,
> > -	xfs_km_flags_t		alloc_flags)
> > +	gfp_t			alloc_flags)
> >  {
> >  	struct xlog_ticket	*tic;
> >  	int			unit_res;
> >  
> > -	tic = kmem_zone_zalloc(xfs_log_ticket_zone, alloc_flags);
> > +	tic = kmem_cache_zalloc(xfs_log_ticket_zone, alloc_flags);
> >  	if (!tic)
> >  		return NULL;
> >  
> > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > index 48435cf2aa16..630c2482c8f1 100644
> > --- a/fs/xfs/xfs_log_cil.c
> > +++ b/fs/xfs/xfs_log_cil.c
> > @@ -38,7 +38,7 @@ xlog_cil_ticket_alloc(
> >  	struct xlog_ticket *tic;
> >  
> >  	tic = xlog_ticket_alloc(log, 0, 1, XFS_TRANSACTION, 0,
> > -				KM_NOFS);
> > +				GFP_NOFS | __GFP_NOFAIL);
> >  
> >  	/*
> >  	 * set the current reservation to zero so we know to steal the basic
> > diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
> > index c47aa2ca6dc7..54c95fee9dc4 100644
> > --- a/fs/xfs/xfs_log_priv.h
> > +++ b/fs/xfs/xfs_log_priv.h
> > @@ -427,7 +427,7 @@ xlog_ticket_alloc(
> >  	int		count,
> >  	char		client,
> >  	bool		permanent,
> > -	xfs_km_flags_t	alloc_flags);
> > +	gfp_t		alloc_flags);
> >  
> >  
> >  static inline void
> > diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
> > index 8eeed73928cd..a242bc9874a6 100644
> > --- a/fs/xfs/xfs_refcount_item.c
> > +++ b/fs/xfs/xfs_refcount_item.c
> > @@ -146,7 +146,7 @@ xfs_cui_init(
> >  		cuip = kmem_zalloc(xfs_cui_log_item_sizeof(nextents),
> >  				0);
> >  	else
> > -		cuip = kmem_zone_zalloc(xfs_cui_zone, 0);
> > +		cuip = kmem_cache_zalloc(xfs_cui_zone, GFP_KERNEL | __GFP_NOFAIL);
> 
> Long line.  I'll just fix it if nobody else posts any objections...
> 
> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

Thanks, and sorry. It really skipped my eyes while I was reviewing it today.

> 
> --D
> 
> >  
> >  	xfs_log_item_init(mp, &cuip->cui_item, XFS_LI_CUI, &xfs_cui_item_ops);
> >  	cuip->cui_format.cui_nextents = nextents;
> > @@ -223,7 +223,7 @@ xfs_trans_get_cud(
> >  {
> >  	struct xfs_cud_log_item		*cudp;
> >  
> > -	cudp = kmem_zone_zalloc(xfs_cud_zone, 0);
> > +	cudp = kmem_cache_zalloc(xfs_cud_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  	xfs_log_item_init(tp->t_mountp, &cudp->cud_item, XFS_LI_CUD,
> >  			  &xfs_cud_item_ops);
> >  	cudp->cud_cuip = cuip;
> > diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
> > index 4911b68f95dd..857cc78dc440 100644
> > --- a/fs/xfs/xfs_rmap_item.c
> > +++ b/fs/xfs/xfs_rmap_item.c
> > @@ -144,7 +144,8 @@ xfs_rui_init(
> >  	if (nextents > XFS_RUI_MAX_FAST_EXTENTS)
> >  		ruip = kmem_zalloc(xfs_rui_log_item_sizeof(nextents), 0);
> >  	else
> > -		ruip = kmem_zone_zalloc(xfs_rui_zone, 0);
> > +		ruip = kmem_cache_zalloc(xfs_rui_zone,
> > +					 GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	xfs_log_item_init(mp, &ruip->rui_item, XFS_LI_RUI, &xfs_rui_item_ops);
> >  	ruip->rui_format.rui_nextents = nextents;
> > @@ -246,7 +247,7 @@ xfs_trans_get_rud(
> >  {
> >  	struct xfs_rud_log_item		*rudp;
> >  
> > -	rudp = kmem_zone_zalloc(xfs_rud_zone, 0);
> > +	rudp = kmem_cache_zalloc(xfs_rud_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  	xfs_log_item_init(tp->t_mountp, &rudp->rud_item, XFS_LI_RUD,
> >  			  &xfs_rud_item_ops);
> >  	rudp->rud_ruip = ruip;
> > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
> > index 3b208f9a865c..29f34492d5f4 100644
> > --- a/fs/xfs/xfs_trans.c
> > +++ b/fs/xfs/xfs_trans.c
> > @@ -90,7 +90,7 @@ xfs_trans_dup(
> >  
> >  	trace_xfs_trans_dup(tp, _RET_IP_);
> >  
> > -	ntp = kmem_zone_zalloc(xfs_trans_zone, 0);
> > +	ntp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  
> >  	/*
> >  	 * Initialize the new transaction structure.
> > @@ -263,7 +263,7 @@ xfs_trans_alloc(
> >  	 * GFP_NOFS allocation context so that we avoid lockdep false positives
> >  	 * by doing GFP_KERNEL allocations inside sb_start_intwrite().
> >  	 */
> > -	tp = kmem_zone_zalloc(xfs_trans_zone, 0);
> > +	tp = kmem_cache_zalloc(xfs_trans_zone, GFP_KERNEL | __GFP_NOFAIL);
> >  	if (!(flags & XFS_TRANS_NO_WRITECOUNT))
> >  		sb_start_intwrite(mp->m_super);
> >  
> > diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
> > index ff1c326826d3..69e8f6d049aa 100644
> > --- a/fs/xfs/xfs_trans_dquot.c
> > +++ b/fs/xfs/xfs_trans_dquot.c
> > @@ -863,7 +863,8 @@ STATIC void
> >  xfs_trans_alloc_dqinfo(
> >  	xfs_trans_t	*tp)
> >  {
> > -	tp->t_dqinfo = kmem_zone_zalloc(xfs_qm_dqtrxzone, 0);
> > +	tp->t_dqinfo = kmem_cache_zalloc(xfs_qm_dqtrxzone,
> > +					 GFP_KERNEL | __GFP_NOFAIL);
> >  }
> >  
> >  void
> > -- 
> > 2.23.0
> > 
> 

-- 
Carlos





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux