diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 5ce49a8b9de1..5d1d73f99ce0 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c @@ -3009,10 +3009,6 @@ xfs_btree_split_worker( struct xfs_btree_split_args, work); unsigned int nofs_flags; - /* - * Don't use xfs_trans_set_context() here: it would overwrite the - * caller's saved NOFS state in tp->t_pflags. Use a local scope. - */ nofs_flags = memalloc_nofs_save(); args->result = __xfs_btree_split(args->cur, args->level, args->ptrp, diff --git a/fs/xfs/libxfs/xfs_trans.h b/fs/xfs/libxfs/xfs_trans.h index 05b3cc19a311..b0c7724d0619 100644 --- a/fs/xfs/libxfs/xfs_trans.h +++ b/fs/xfs/libxfs/xfs_trans.h @@ -264,20 +264,6 @@ int xfs_trans_alloc_dir(struct xfs_inode *dp, struct xfs_trans_res *resv, struct xfs_inode *ip, unsigned int *dblocks, struct xfs_trans **tpp, int *nospace_error); -static inline void -xfs_trans_set_context( - struct xfs_trans *tp) -{ - tp->t_pflags = memalloc_nofs_save(); -} - -static inline void -xfs_trans_clear_context( - struct xfs_trans *tp) -{ - memalloc_nofs_restore(tp->t_pflags); -} - static inline void xfs_trans_cancel( struct xfs_trans *tp) diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 8f0c308f312f..973e82e1e323 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -72,7 +72,7 @@ xfs_trans_free( xfs_extent_busy_clear(&tp->t_busy, false); trace_xfs_trans_free(tp, _RET_IP_); - xfs_trans_clear_context(tp); + memalloc_nofs_restore(tp->t_pflags); if (!(tp->t_flags & XFS_TRANS_NO_WRITECOUNT)) sb_end_intwrite(tp->t_mountp->m_super); xfs_trans_free_dqinfo(tp); @@ -220,7 +220,11 @@ __xfs_trans_alloc( tp = kmem_cache_zalloc(xfs_trans_cache, GFP_KERNEL | __GFP_NOFAIL); if (!(flags & XFS_TRANS_NO_WRITECOUNT)) sb_start_intwrite(mp->m_super); - xfs_trans_set_context(tp); + /* + * Save NOFS state for xfs_trans_free() to restore. Only the + * transaction owner thread may touch tp->t_pflags. + */ + tp->t_pflags = memalloc_nofs_save(); tp->t_flags = flags; tp->t_mountp = mp; INIT_LIST_HEAD(&tp->t_items); @@ -1038,7 +1042,7 @@ xfs_trans_roll( * xfs_trans_free. Set it again here before doing memory * allocations. */ - xfs_trans_set_context(tp); + tp->t_pflags = memalloc_nofs_save(); if (error) return error;