diff mbox series

[3/4] xfs: Modify xlog_ticket_alloc() to use kernel's MM API

Message ID 20200708125608.155645-4-cmaiolino@redhat.com (mailing list archive)
State Superseded, archived
Headers show
Series Continue xfs kmem cleanup | expand

Commit Message

Carlos Maiolino July 8, 2020, 12:56 p.m. UTC
change xlog_ticket_alloc() to use default kmem_cache_zalloc(), and
modify its callers to pass MM flags as arguments.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/xfs_log.c      | 7 ++++---
 fs/xfs/xfs_log_cil.c  | 2 +-
 fs/xfs/xfs_log_priv.h | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

Comments

Dave Chinner July 9, 2020, 3 a.m. UTC | #1
On Wed, Jul 08, 2020 at 02:56:07PM +0200, Carlos Maiolino wrote:
> change xlog_ticket_alloc() to use default kmem_cache_zalloc(), and
> modify its callers to pass MM flags as arguments.
> 
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
>  fs/xfs/xfs_log.c      | 7 ++++---
>  fs/xfs/xfs_log_cil.c  | 2 +-
>  fs/xfs/xfs_log_priv.h | 2 +-
>  3 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 00fda2e8e7380..6d40d479e34a1 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -433,7 +433,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;

xfs_log_reserve() is called either from transaction reservation
which is under memalloc_nofs context, or from the CIL with explicit
GFP_NOFS, or from the unmount path which is GFP_KERNEL but is
holding various filesystem locks.

I suspect that this patch should just remove the gfp flags from
xlog_ticket_alloc() and just unconditionally use GFP_NOFS |
__GFP_NOFAIL fo allocating the ticket. That would clean this up
quite a bit....

Cheers,

Dave.
diff mbox series

Patch

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 00fda2e8e7380..6d40d479e34a1 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -433,7 +433,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
@@ -3409,12 +3410,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 9ed90368ab311..636c53a62cd3f 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 75a62870b63af..039b5cf6e692e 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -465,7 +465,7 @@  xlog_ticket_alloc(
 	int		count,
 	char		client,
 	bool		permanent,
-	xfs_km_flags_t	alloc_flags);
+	gfp_t		alloc_flags);
 
 
 static inline void