From: Frank Sorenson <sorenson@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: dwysocha@redhat.com, lvaz@redhat.com
Subject: [PATCH 1/5] fs: simplify freeze_super()/thaw_super() exit handling
Date: Wed, 2 Mar 2016 13:01:55 -0600 [thread overview]
Message-ID: <1456945319-16283-2-git-send-email-sorenson@redhat.com> (raw)
In-Reply-To: <1456945319-16283-1-git-send-email-sorenson@redhat.com>
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(-)
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
next prev parent reply other threads:[~2016-03-02 19:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-02 19:01 [PATCH 0/5] Add trace events for filesystem freeze/thaw events Frank Sorenson
2016-03-02 19:01 ` Frank Sorenson [this message]
2016-03-02 20:06 ` [PATCH 1/5] fs: simplify freeze_super()/thaw_super() exit handling Al Viro
2016-03-02 19:01 ` [PATCH 2/5] fs/block_dev.c: simplify freeze_bdev() and thaw_bdev() " Frank Sorenson
2016-03-02 19:01 ` [PATCH 3/5] fs: add trace events for freeze_super() and thaw_super() Frank Sorenson
2016-03-02 20:12 ` Al Viro
2016-03-02 19:01 ` [PATCH 4/5] fs/block_dev.c: add trace events for freeze_bdev() and thaw_bdev() Frank Sorenson
2016-03-02 19:01 ` [PATCH 5/5] fs: enable filesystem freeze/thaw events Frank Sorenson
2016-03-02 20:15 ` Al Viro
2016-03-02 21:47 ` [PATCH 0/5] Add trace events for " Al Viro
2016-03-02 22:47 ` Dave Chinner
2016-03-02 23:22 ` Al Viro
2016-03-02 23:52 ` Dave Chinner
2016-03-03 11:18 ` Dave Wysochanski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456945319-16283-2-git-send-email-sorenson@redhat.com \
--to=sorenson@redhat.com \
--cc=dwysocha@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=lvaz@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).