From: Tony Ernst <tee@sgi.com>
Subject: DMAPI: XFS_FREE_EOF_HASLOCK flag is not always checked
References: bnc#733390
Patch-mainline: Never, DMAPI

The flag XFS_FREE_EOF_HASLOCK is a special flag that tells xfs_free_eofblocks()
that the calling function ( xfs_dm_punch_hole() ) is calling the function but
it already has the XFS_IOLOCK_EXCL and wants to keep it.

Alain has a patch to make sure we never release the lock if the flag is set.
This fix is in dmapi code, which is not upstream code.

I will attach his patch.

Acked-by: Jeff Mahoney <jeffm@suse.com>
---

 fs/xfs/xfs_vnodeops.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -665,7 +665,8 @@
 		if (error) {
 			ASSERT(XFS_FORCED_SHUTDOWN(mp));
 			xfs_trans_cancel(tp, 0);
-			xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+			if (!(flags & XFS_FREE_EOF_HASLOCK))
+				xfs_iunlock(ip, XFS_IOLOCK_EXCL);
 			return error;
 		}
 
@@ -688,7 +689,10 @@
 			error = xfs_trans_commit(tp,
 						XFS_TRANS_RELEASE_LOG_RES);
 		}
-		xfs_iunlock(ip, XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL);
+		if (!(flags & XFS_FREE_EOF_HASLOCK))
+			xfs_iunlock(ip, XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL);
+		else
+			xfs_iunlock(ip, XFS_ILOCK_EXCL);
 	}
 	return error;
 }

