[PATCH 4/6] fs: move !SB_BORN check early on freeze and add for thaw

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

 



The SB_BORN flag added on vfs_get_tree() when a filesystem is about to be
mounted. If a super_block lacks this flag there's nothing to do for that
filesystem in terms of freezing or thawing.

In subsequent patches support will be added to allow detecting failures for
iterating over all super_blocks and freezing or thawing. Although that
functionality will be be skipped when sb->s_bdi == &noop_backing_dev_info,
and so SB_BORN will not be set, since we already check for SB_BORN on
freeze just move that up earlier and to be consistent do the same on
thaw too. We do this as these are user facing APIs, and although it
would be incorrect to issue a freeze on a non-mounted sb, it is even
stranger to get -EBUSY.

Be consistent about this and bail early for !SB_BORN for freeze and thaw
without failing.

Signed-off-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
---
 fs/super.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index 16ccbb9dd230..28c633b81f8f 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1678,12 +1678,13 @@ int freeze_super(struct super_block *sb, bool usercall)
 	if (!usercall && sb_is_frozen(sb))
 		return 0;
 
+	/* If the filesystem was not going to be mounted there is nothing to do */
+	if (!(sb->s_flags & SB_BORN))
+		return 0;
+
 	if (!sb_is_unfrozen(sb))
 		return -EBUSY;
 
-	if (!(sb->s_flags & SB_BORN))
-		return 0;	/* sic - it's "nothing to do" */
-
 	if (sb_rdonly(sb)) {
 		/* Nothing to do really... */
 		sb->s_writers.frozen = SB_FREEZE_COMPLETE;
@@ -1761,6 +1762,10 @@ int thaw_super(struct super_block *sb, bool usercall)
 			return 0;
 	}
 
+	/* If the filesystem was not going to be mounted there is nothing to do */
+	if (!(sb->s_flags & SB_BORN))
+		return 0;
+
 	if (!sb_is_frozen(sb))
 		return -EINVAL;
 
-- 
2.39.2


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux