All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Klara Modin <klarasmodin@gmail.com>
Subject: [PATCH v2] btrfs_get_tree_subvol(): switch from fc_mount() to vfs_create_mount()
Date: Tue, 6 May 2025 20:34:05 +0100	[thread overview]
Message-ID: <20250506193405.GS2023217@ZenIV> (raw)
In-Reply-To: <20250505030345.GD2023217@ZenIV>

it's simpler to do btrfs_reconfigure_for_mount() right after vfs_get_tree() -
no need to mess with ->s_umount.
    
[fix for braino(s) folded in - kudos to Klara Modin <klarasmodin@gmail.com>]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7121d8c7a318..75934b25ff47 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1984,17 +1984,13 @@ static int btrfs_get_tree_super(struct fs_context *fc)
  * btrfs or not, setting the whole super block RO.  To make per-subvolume mounting
  * work with different options work we need to keep backward compatibility.
  */
-static int btrfs_reconfigure_for_mount(struct fs_context *fc, struct vfsmount *mnt)
+static int btrfs_reconfigure_for_mount(struct fs_context *fc)
 {
 	int ret = 0;
 
-	if (fc->sb_flags & SB_RDONLY)
-		return ret;
-
-	down_write(&mnt->mnt_sb->s_umount);
-	if (!(fc->sb_flags & SB_RDONLY) && (mnt->mnt_sb->s_flags & SB_RDONLY))
+	if (!(fc->sb_flags & SB_RDONLY) && (fc->root->d_sb->s_flags & SB_RDONLY))
 		ret = btrfs_reconfigure(fc);
-	up_write(&mnt->mnt_sb->s_umount);
+
 	return ret;
 }
 
@@ -2047,17 +2043,18 @@ static int btrfs_get_tree_subvol(struct fs_context *fc)
 	security_free_mnt_opts(&fc->security);
 	fc->security = NULL;
 
-	mnt = fc_mount(dup_fc);
-	if (IS_ERR(mnt)) {
-		put_fs_context(dup_fc);
-		return PTR_ERR(mnt);
+	ret = vfs_get_tree(dup_fc);
+	if (!ret) {
+		ret = btrfs_reconfigure_for_mount(dup_fc);
+		up_write(&fc->root->d_sb->s_umount);
 	}
-	ret = btrfs_reconfigure_for_mount(dup_fc, mnt);
+	if (!ret)
+		mnt = vfs_create_mount(dup_fc);
+	else
+		mnt = ERR_PTR(ret);
 	put_fs_context(dup_fc);
-	if (ret) {
-		mntput(mnt);
-		return ret;
-	}
+	if (IS_ERR(mnt))
+		return PTR_ERR(mnt);
 
 	/*
 	 * This free's ->subvol_name, because if it isn't set we have to

  parent reply	other threads:[~2025-05-06 19:34 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05  3:03 [RFC][PATCH] btrfs_get_tree_subvol(): switch from fc_mount() to vfs_create_mount() Al Viro
2025-05-05 17:58 ` David Sterba
2025-05-05 19:21   ` Al Viro
2025-05-06 13:36 ` Klara Modin
2025-05-06 16:43   ` Al Viro
2025-05-06 16:48     ` Klara Modin
2025-05-06 17:25   ` Al Viro
2025-05-06 17:47     ` Klara Modin
2025-05-06 17:51       ` Al Viro
2025-05-06 17:54         ` Klara Modin
2025-05-06 18:16           ` Al Viro
2025-05-06 18:34             ` Klara Modin
2025-05-06 19:05               ` Al Viro
2025-05-06 19:20                 ` Klara Modin
2025-05-06 19:48                   ` Al Viro
2025-05-06 18:58             ` Klara Modin
2025-05-06 19:33               ` Al Viro
2025-05-06 19:44                 ` Klara Modin
2025-05-06 19:34 ` Al Viro [this message]
2025-05-06 19:52   ` [PATCH v2] " Klara Modin
2025-05-06 20:00     ` Al Viro
2025-05-06 19:58   ` [PATCH v3] " Al Viro
2025-05-08  9:29     ` Qu Wenruo
2025-06-03  7:59       ` David Sterba
2025-06-03  9:23         ` Qu Wenruo
2025-06-03 19:38           ` David Sterba

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=20250506193405.GS2023217@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=klarasmodin@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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.