public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix deadlock on failure path in xfs_setattr_nonsize()
@ 2014-10-15 21:22 Alexey Khoroshilov
  2014-10-16 12:40 ` Brian Foster
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Khoroshilov @ 2014-10-15 21:22 UTC (permalink / raw)
  To: Dave Chinner
  Cc: Alexey Khoroshilov, Brian Foster, xfs, linux-kernel,
	spruce-project

If xfs_trans_reserve() fails, xfs_setattr_nonsize() does not deallocate
the transaction and does not release "freeze" lock. That leads to the
following warning from lockdep:
  [ BUG: lock held when returning to user space! ]
  ------------------------------------------------
  fs-driver-tests/7127 is leaving the kernel with locks still held!
  1 lock held by fs-driver-tests/7127:
   #0:  (sb_internal){.+.+.+}, at: [<ffffffffa0389a44>] xfs_trans_alloc+0x24/0x40 [xfs]

The patch adds xfs_trans_cancel() on the failure path.

Found by Linux File System Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 fs/xfs/xfs_iops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 72129493e9d3..e2e785eec831 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -599,8 +599,10 @@ xfs_setattr_nonsize(
 
 	tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
 	error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
-	if (error)
+	if (error) {
+		xfs_trans_cancel(tp, 0);
 		goto out_dqrele;
+	}
 
 	xfs_ilock(ip, XFS_ILOCK_EXCL);
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-16 12:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 21:22 [PATCH] xfs: fix deadlock on failure path in xfs_setattr_nonsize() Alexey Khoroshilov
2014-10-16 12:40 ` Brian Foster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox