[03/11] fs: move __get_super() out of loop
diff mbox series

Message ID 20190814121834.13983-4-s.hauer@pengutronix.de
State Changes Requested
Headers show
Series
  • Add quota support to UBIFS
Related show

Commit Message

Sascha Hauer Aug. 14, 2019, 12:18 p.m. UTC
__get_super_thawed() calls __get_super() multiple times. I can't see a case
where __get_super() would return another valid superblock when called
again, so move the call to __get_super() out of the loop. This is done in
preparation for the next patch.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/super.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Al Viro Aug. 14, 2019, 11:32 p.m. UTC | #1
On Wed, Aug 14, 2019 at 02:18:26PM +0200, Sascha Hauer wrote:
> __get_super_thawed() calls __get_super() multiple times. I can't see a case
> where __get_super() would return another valid superblock when called
> again, so move the call to __get_super() out of the loop. This is done in
> preparation for the next patch.

How about "someone has come and unmounted the sucker under us"?

Patch
diff mbox series

diff --git a/fs/super.c b/fs/super.c
index 5960578a4076..f85d1ea194ae 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -786,17 +786,26 @@  EXPORT_SYMBOL(get_super);
 static struct super_block *__get_super_thawed(struct block_device *bdev,
 					      bool excl)
 {
+	struct super_block *s = __get_super(bdev, excl);
+	if (!s)
+		return NULL;
+
 	while (1) {
-		struct super_block *s = __get_super(bdev, excl);
-		if (!s || s->s_writers.frozen == SB_UNFROZEN)
+		if (s->s_writers.frozen == SB_UNFROZEN)
 			return s;
+
 		if (!excl)
 			up_read(&s->s_umount);
 		else
 			up_write(&s->s_umount);
+
 		wait_event(s->s_writers.wait_unfrozen,
 			   s->s_writers.frozen == SB_UNFROZEN);
-		put_super(s);
+
+		if (!excl)
+			down_read(&sb->s_umount);
+		else
+			down_write(&sb->s_umount);
 	}
 }