From: Luis Chamberlain <mcgrof@kernel.org>
To: rafael@kernel.org, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org,
jeyu@kernel.org, ebiederm@xmission.com
Cc: mchehab@kernel.org, keescook@chromium.org,
linux-fsdevel@vger.kernel.org, kernel@tuxforce.de,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFC v2 3/6] fs: add a helper for thaw_super_locked() which does not unlock
Date: Sat, 17 Apr 2021 00:10:23 +0000 [thread overview]
Message-ID: <20210417001026.23858-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20210417001026.23858-1-mcgrof@kernel.org>
The thaw_super_locked() expects the caller to hold the sb->s_umount
semaphore. It also handles the unlocking of the semaphore for you.
Allow for cases where the caller will do the unlocking of the semaphore.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
fs/super.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 72b445a69a45..744b2399a272 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1730,14 +1730,13 @@ int freeze_super(struct super_block *sb)
}
EXPORT_SYMBOL(freeze_super);
-static int thaw_super_locked(struct super_block *sb)
+/* Caller deals with the sb->s_umount */
+static int __thaw_super_locked(struct super_block *sb)
{
int error;
- if (!sb_is_frozen(sb)) {
- up_write(&sb->s_umount);
+ if (!sb_is_frozen(sb))
return -EINVAL;
- }
if (sb_rdonly(sb)) {
sb->s_writers.frozen = SB_UNFROZEN;
@@ -1752,7 +1751,6 @@ static int thaw_super_locked(struct super_block *sb)
printk(KERN_ERR
"VFS:Filesystem thaw failed\n");
lockdep_sb_freeze_release(sb);
- up_write(&sb->s_umount);
return error;
}
}
@@ -1761,10 +1759,25 @@ static int thaw_super_locked(struct super_block *sb)
sb_freeze_unlock(sb);
out:
wake_up(&sb->s_writers.wait_unfrozen);
- deactivate_locked_super(sb);
return 0;
}
+/* Handles unlocking of sb->s_umount for you */
+static int thaw_super_locked(struct super_block *sb)
+{
+ int error;
+
+ error = __thaw_super_locked(sb);
+ if (error) {
+ up_write(&sb->s_umount);
+ return error;
+ }
+
+ deactivate_locked_super(sb);
+
+ return 0;
+ }
+
/**
* thaw_super -- unlock filesystem
* @sb: the super to thaw
--
2.29.2
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org>
To: rafael@kernel.org, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk, jack@suse.cz, bvanassche@acm.org,
jeyu@kernel.org, ebiederm@xmission.com
Cc: mchehab@kernel.org, keescook@chromium.org,
linux-fsdevel@vger.kernel.org, kernel@tuxforce.de,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFC v2 3/6] fs: add a helper for thaw_super_locked() which does not unlock
Date: Sat, 17 Apr 2021 00:10:23 +0000 [thread overview]
Message-ID: <20210417001026.23858-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20210417001026.23858-1-mcgrof@kernel.org>
The thaw_super_locked() expects the caller to hold the sb->s_umount
semaphore. It also handles the unlocking of the semaphore for you.
Allow for cases where the caller will do the unlocking of the semaphore.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
fs/super.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index 72b445a69a45..744b2399a272 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1730,14 +1730,13 @@ int freeze_super(struct super_block *sb)
}
EXPORT_SYMBOL(freeze_super);
-static int thaw_super_locked(struct super_block *sb)
+/* Caller deals with the sb->s_umount */
+static int __thaw_super_locked(struct super_block *sb)
{
int error;
- if (!sb_is_frozen(sb)) {
- up_write(&sb->s_umount);
+ if (!sb_is_frozen(sb))
return -EINVAL;
- }
if (sb_rdonly(sb)) {
sb->s_writers.frozen = SB_UNFROZEN;
@@ -1752,7 +1751,6 @@ static int thaw_super_locked(struct super_block *sb)
printk(KERN_ERR
"VFS:Filesystem thaw failed\n");
lockdep_sb_freeze_release(sb);
- up_write(&sb->s_umount);
return error;
}
}
@@ -1761,10 +1759,25 @@ static int thaw_super_locked(struct super_block *sb)
sb_freeze_unlock(sb);
out:
wake_up(&sb->s_writers.wait_unfrozen);
- deactivate_locked_super(sb);
return 0;
}
+/* Handles unlocking of sb->s_umount for you */
+static int thaw_super_locked(struct super_block *sb)
+{
+ int error;
+
+ error = __thaw_super_locked(sb);
+ if (error) {
+ up_write(&sb->s_umount);
+ return error;
+ }
+
+ deactivate_locked_super(sb);
+
+ return 0;
+ }
+
/**
* thaw_super -- unlock filesystem
* @sb: the super to thaw
--
2.29.2
next prev parent reply other threads:[~2021-04-17 0:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-17 0:10 [RFC v2 0/6] vfs: provide automatic kernel freeze / resume Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 1/6] fs: provide unlocked helper for freeze_super() Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-20 12:03 ` Christoph Hellwig
2021-04-20 12:03 ` Christoph Hellwig
2021-04-17 0:10 ` [RFC v2 2/6] fs: add frozen sb state helpers Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain [this message]
2021-04-17 0:10 ` [RFC v2 3/6] fs: add a helper for thaw_super_locked() which does not unlock Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 4/6] fs: distinguish between user initiated freeze and kernel initiated freeze Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-20 12:46 ` Christoph Hellwig
2021-04-20 12:46 ` Christoph Hellwig
2021-04-17 0:10 ` [RFC v2 5/6] fs: add iterate_supers_excl() and iterate_supers_reverse_excl() Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-17 0:10 ` [RFC v2 6/6] fs: add automatic kernel fs freeze / thaw and remove kthread freezing Luis Chamberlain
2021-04-17 0:10 ` Luis Chamberlain
2021-04-20 12:59 ` Christoph Hellwig
2021-04-20 12:59 ` Christoph Hellwig
2021-04-20 18:47 ` Luis Chamberlain
2021-04-20 18:47 ` Luis Chamberlain
2023-01-10 2:11 ` Luis Chamberlain
2023-01-10 2:11 ` Luis Chamberlain
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=20210417001026.23858-4-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=bvanassche@acm.org \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=kernel@tuxforce.de \
--cc=kexec@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rafael@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.