diff mbox

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

Message ID 1456945319-16283-2-git-send-email-sorenson@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Frank Sorenson March 2, 2016, 7:01 p.m. UTC
Change freeze_super() and thaw_super() to have a common exit

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

Comments

Al Viro March 2, 2016, 8:06 p.m. UTC | #1
On Wed, Mar 02, 2016 at 01:01:55PM -0600, Frank Sorenson wrote:
> Change freeze_super() and thaw_super() to have a common exit

What makes it a simplification in any kind of sense?
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);