[PATCH] XFS: random cleanups of xfs_swap_extents

Josef 'Jeff' Sipek jeffpc at josefsipek.net
Fri Nov 7 17:00:54 CST 2008


XFS: random cleanups of xfs_swap_extents

From: Josef 'Jeff' Sipek <jeffpc at josefsipek.net>

1) remove lock_flags var since it's never modified and only obfuscates the
code

2) calling kfree/vfree on a NULL is valid

Signed-off-by: Josef 'Jeff' Sipek <jeffpc at josefsipek.net>

--

I did only compile testing. If people really want, I can go ahead and set up
my xfsqa test box again and run the patch through it.

diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index 75b0cd4..d65e81e 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -132,7 +132,6 @@ xfs_swap_extents(
 	xfs_bstat_t	*sbp = &sxp->sx_stat;
 	xfs_ifork_t	*tempifp, *ifp, *tifp;
 	int		ilf_fields, tilf_fields;
-	static uint	lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
 	int		error = 0;
 	int		aforkblks = 0;
 	int		taforkblks = 0;
@@ -346,10 +345,10 @@ xfs_swap_extents(
 
 
 	IHOLD(ip);
-	xfs_trans_ijoin(tp, ip, lock_flags);
+	xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
 
 	IHOLD(tip);
-	xfs_trans_ijoin(tp, tip, lock_flags);
+	xfs_trans_ijoin(tp, tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
 
 	xfs_trans_log_inode(tp, ip,  ilf_fields);
 	xfs_trans_log_inode(tp, tip, tilf_fields);
@@ -367,10 +366,10 @@ xfs_swap_extents(
 
  error0:
 	if (locked) {
-		xfs_iunlock(ip,  lock_flags);
-		xfs_iunlock(tip, lock_flags);
+		xfs_iunlock(ip,  XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
+		xfs_iunlock(tip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
 	}
-	if (tempifp != NULL)
-		kmem_free(tempifp);
+
+	kmem_free(tempifp);
 	return error;
 }



More information about the xfs mailing list