[PATCH 03/17] xfs: cleanup handling in xfs_swap_extents

Eric Sandeen sandeen at sandeen.net
Thu May 7 19:45:36 CDT 2009


Christoph Hellwig wrote:

> Use multiple lables for proper error unwinding and get rid of some now
> superflous variables.
>
>
> Signed-off-by: Josef 'Jeff' Sipek <jeffpc at josefsipek.net>
> Reviewed-by: Christoph Hellwig <hch at lst.de>

Problem in this patch, I think, getting hangs on x86 fsr...

> Index: xfs/fs/xfs/xfs_dfrag.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_dfrag.c	2008-12-19 15:02:54.003908425 +0100
> +++ xfs/fs/xfs/xfs_dfrag.c	2008-12-22 15:59:55.013247371 +0100
<snip>
> @@ -352,19 +344,19 @@ xfs_swap_extents(
>  	 * If this is a synchronous mount, make sure that the
>  	 * transaction goes to disk before returning to the user.
>  	 */
> -	if (mp->m_flags & XFS_MOUNT_WSYNC) {
> +	if (mp->m_flags & XFS_MOUNT_WSYNC)
>  		xfs_trans_set_sync(tp);
> -	}
>  
>  	error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT);
> -	locked = 0;

old code said "unlocked" here thanks to the trans commit ...

> - error0:
> -	if (locked) {
> -		xfs_iunlock(ip,  lock_flags);
> -		xfs_iunlock(tip, lock_flags);
> -	}
and so we wouldn't unlock again ...
> -	if (tempifp != NULL)
> -		kmem_free(tempifp);
> +out_unlock:
> +	xfs_iunlock(ip,  XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
> +	xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);

But now we do it unconditionally, and ruh-roh.

> +out:
> +	kmem_free(tempifp);
>  	return error;
> +
> +out_trans_cancel:
> +	xfs_trans_cancel(tp, 0);
> +	goto out_unlock;
>  }

Is this too ugly a fix?

XFS: Fix double unlock of inodes in xfs_swap_extents()

commit ef8f7fc549bf345d92f396f5aa7b152b4969cbf7 had an error
where we would try to re-unlock the inodes after they had been
committed in the transaction; this double unlock caused a

=====================================
[ BUG: bad unlock balance detected! ]
-------------------------------------
xfs_fsr/1459 is trying to release lock (&(&ip->i_iolock)->mr_lock) at:
[<e248dedb>] xfs_iunlock+0x2c/0x92 [xfs]
but there are no more locks to release!

Signed-off-by: Eric Sandeen <sandeen at sandeen.net>
---

Index: linux-2.6/fs/xfs/xfs_dfrag.c
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_dfrag.c
+++ linux-2.6/fs/xfs/xfs_dfrag.c
@@ -347,13 +347,15 @@ xfs_swap_extents(
 
 	error = xfs_trans_commit(tp, XFS_TRANS_SWAPEXT);
 
-out_unlock:
-	xfs_iunlock(ip,  XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
-	xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
 out:
 	kmem_free(tempifp);
 	return error;
 
+out_unlock:
+	xfs_iunlock(ip,  XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
+	xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
+	goto out;
+
 out_trans_cancel:
 	xfs_trans_cancel(tp, 0);
 	goto out_unlock;





More information about the xfs mailing list