[PATCH 1/5] fs: simplify freeze_super()/thaw_super() exit handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change freeze_super() and thaw_super() to have a common exit

Signed-off-by: Frank Sorenson <sorenson@xxxxxxxxxx>
---
 fs/super.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 1182af8..5e9a974 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1272,26 +1272,21 @@ static void sb_freeze_unlock(struct super_block *sb)
  */
 int freeze_super(struct super_block *sb)
 {
-	int ret;
+	int ret = 0;
 
 	atomic_inc(&sb->s_active);
 	down_write(&sb->s_umount);
 	if (sb->s_writers.frozen != SB_UNFROZEN) {
 		deactivate_locked_super(sb);
-		return -EBUSY;
+		ret = -EBUSY;
+		goto out;
 	}
 
-	if (!(sb->s_flags & MS_BORN)) {
-		up_write(&sb->s_umount);
-		return 0;	/* sic - it's "nothing to do" */
-	}
+	if (!(sb->s_flags & MS_BORN))
+		goto out_unlock; /* nothing to do */
 
-	if (sb->s_flags & MS_RDONLY) {
-		/* Nothing to do really... */
-		sb->s_writers.frozen = SB_FREEZE_COMPLETE;
-		up_write(&sb->s_umount);
-		return 0;
-	}
+	if (sb->s_flags & MS_RDONLY)
+		goto out_complete; /* nothing to do */
 
 	sb->s_writers.frozen = SB_FREEZE_WRITE;
 	/* Release s_umount to preserve sb_start_write -> s_umount ordering */
@@ -1319,16 +1314,19 @@ int freeze_super(struct super_block *sb)
 			sb_freeze_unlock(sb);
 			wake_up(&sb->s_writers.wait_unfrozen);
 			deactivate_locked_super(sb);
-			return ret;
+			goto out;
 		}
 	}
 	/*
 	 * This is just for debugging purposes so that fs can warn if it
 	 * sees write activity when frozen is set to SB_FREEZE_COMPLETE.
 	 */
+out_complete:
 	sb->s_writers.frozen = SB_FREEZE_COMPLETE;
+out_unlock:
 	up_write(&sb->s_umount);
-	return 0;
+out:
+	return ret;
 }
 EXPORT_SYMBOL(freeze_super);
 
@@ -1340,34 +1338,36 @@ EXPORT_SYMBOL(freeze_super);
  */
 int thaw_super(struct super_block *sb)
 {
-	int error;
+	int ret = 0;
 
 	down_write(&sb->s_umount);
 	if (sb->s_writers.frozen == SB_UNFROZEN) {
 		up_write(&sb->s_umount);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto out;
 	}
 
 	if (sb->s_flags & MS_RDONLY) {
 		sb->s_writers.frozen = SB_UNFROZEN;
-		goto out;
+		goto out_wake;
 	}
 
 	if (sb->s_op->unfreeze_fs) {
-		error = sb->s_op->unfreeze_fs(sb);
-		if (error) {
+		ret = sb->s_op->unfreeze_fs(sb);
+		if (ret) {
 			printk(KERN_ERR
 				"VFS:Filesystem thaw failed\n");
 			up_write(&sb->s_umount);
-			return error;
+			goto out;
 		}
 	}
 
 	sb->s_writers.frozen = SB_UNFROZEN;
 	sb_freeze_unlock(sb);
-out:
+out_wake:
 	wake_up(&sb->s_writers.wait_unfrozen);
 	deactivate_locked_super(sb);
-	return 0;
+out:
+	return ret;
 }
 EXPORT_SYMBOL(thaw_super);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux