]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: cancel tx on xfs_defer_finish() error during xattr set/remove
authorBrian Foster <bfoster@redhat.com>
Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)
committerEric Sandeen <sandeen@redhat.com>
Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)
Source kernel commit: c468562879a766de2c2fbedd41b653a7bf4c157d

Chris Dunlop reports a problem where an xattr operation fails,
reports the following error to syslog and hangs during unmount:

================================================
[ BUG: lock held when returning to user space! ]
...
------------------------------------------------
<PID> is leaving the kernel with locks still held!
1 lock held by <PID>:
#0:  (sb_internal){......}, at: [<ffffffffa07692a3>] xfs_trans_alloc+0xe3/0x130 [xfs]

The failure/shutdown occurs during deferred ops processing which
leads to an error return from xfs_defer_finish() via
xfs_attr_leaf_addname(). While the root cause of the failure is
unknown corruption, the cause of the subsequent BUG above and
unmount hang is failure to cancel the transaction before returning
to userspace.

The transaction is not cancelled because the out_defer_cancel error
handling paths in the xfs_attr_[leaf|node]_[add|remove]name()
functions clear args.trans without releasing the transaction. The
callers therefore lose the reference to the transaction and fail to
cancel it.

Since xfs_attr_[set|remove]() always cancel args.trans when != NULL
and xfs_defer_finish()->...->xfs_trans_roll() should always return
with a valid transaction, update the leaf/node xattr functions to
not reset args.trans in the error path responsible for cancelling
deferred ops.

Reported-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr.c

index 452244723078b04380a8732c7030a1042d9753de..a4bde022aa7c079d59814e12586971e8c664b0bc 100644 (file)
@@ -712,7 +712,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
        return error;
 out_defer_cancel:
        xfs_defer_cancel(args->dfops);
-       args->trans = NULL;
        return error;
 }
 
@@ -765,7 +764,6 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
        return 0;
 out_defer_cancel:
        xfs_defer_cancel(args->dfops);
-       args->trans = NULL;
        return error;
 }
 
@@ -1040,7 +1038,6 @@ out:
        return retval;
 out_defer_cancel:
        xfs_defer_cancel(args->dfops);
-       args->trans = NULL;
        goto out;
 }
 
@@ -1181,7 +1178,6 @@ out:
        return error;
 out_defer_cancel:
        xfs_defer_cancel(args->dfops);
-       args->trans = NULL;
        goto out;
 }