From: Dave Chinner Date: Wed, 7 Apr 2021 16:00:36 +0000 (-0400) Subject: xfs: use current->journal_info for detecting transaction recursion X-Git-Tag: v5.12.0-rc0~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf47075fcf6f83f7b3aa40fd90aac3a0614b65d6;p=thirdparty%2Fxfsprogs-dev.git xfs: use current->journal_info for detecting transaction recursion Source kernel commit: 756b1c343333a5aefcc26b0409f3fd16f72281bf Because the iomap code using PF_MEMALLOC_NOFS to detect transaction recursion in XFS is just wrong. Remove it from the iomap code and replace it with XFS specific internal checks using current->journal_info instead. [djwong: This change also realigns the lifetime of NOFS flag changes to match the incore transaction, instead of the inconsistent scheme we have now.] Fixes: 9070733b4efa ("xfs: abstract PF_FSTRANS to PF_MEMALLOC_NOFS") Signed-off-by: Dave Chinner Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index d1ac742b5..d52fdc005 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -2803,7 +2803,7 @@ xfs_btree_split_worker( struct xfs_btree_split_args *args = container_of(work, struct xfs_btree_split_args, work); unsigned long pflags; - unsigned long new_pflags = PF_MEMALLOC_NOFS; + unsigned long new_pflags = 0; /* * we are in a transaction context here, but may also be doing work @@ -2815,12 +2815,20 @@ xfs_btree_split_worker( new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; current_set_flags_nested(&pflags, new_pflags); + xfs_trans_set_context(args->cur->bc_tp); args->result = __xfs_btree_split(args->cur, args->level, args->ptrp, args->key, args->curp, args->stat); - complete(args->done); + xfs_trans_clear_context(args->cur->bc_tp); current_restore_flags_nested(&pflags, new_pflags); + + /* + * Do not access args after complete() has run here. We don't own args + * and the owner may run and free args before we return here. + */ + complete(args->done); + } /*