All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: Boris Burkov <boris@bur.io>
Subject: [PATCH v5 04/10] btrfs: clear oneshot options on mount and remount
Date: Tue, 27 Oct 2020 14:07:58 -0700	[thread overview]
Message-ID: <7b316bb772e15d62df1553c50c8bb4c50cc63c51.1603828718.git.boris@bur.io> (raw)
In-Reply-To: <cover.1603828718.git.boris@bur.io>

Some options only apply during mount time and are cleared at the end
of mount. For now, the example is USEBACKUPROOT, but CLEAR_CACHE also
fits the bill, and this is a preparation patch for also clearing that
option.

One subtlety is that the current code only resets USEBACKUPROOT on rw
mounts, but the option is meaningfully "consumed" by a ro mount, so it
feels appropriate to clear in that case as well. A subsequent read-write
remount would not go through open_ctree, which is the only place that
checks the option, so the change should be benign.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 fs/btrfs/disk-io.c | 20 +++++++++++++-------
 fs/btrfs/disk-io.h |  1 +
 fs/btrfs/super.c   |  1 +
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 5fe0a2640c8a..987e40e12bb4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2814,6 +2814,16 @@ static int btrfs_check_uuid_tree(struct btrfs_fs_info *fs_info)
 	return 0;
 }
 
+/*
+ * Some options only have meaning at mount time and shouldn't persist across
+ * remounts, or be displayed. Clear these at the end of mount and remount
+ * code paths.
+ */
+void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info)
+{
+	btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT);
+}
+
 /*
  * Mounting logic specific to read-write file systems. Shared by open_ctree
  * and btrfs_remount when remounting from read-only to read-write.
@@ -3293,7 +3303,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 	}
 
 	if (sb_rdonly(sb))
-		return 0;
+		goto clear_oneshot;
 
 	if (btrfs_test_opt(fs_info, CLEAR_CACHE) &&
 	    btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
@@ -3337,12 +3347,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 	}
 	set_bit(BTRFS_FS_OPEN, &fs_info->flags);
 
-	/*
-	 * backuproot only affect mount behavior, and if open_ctree succeeded,
-	 * no need to keep the flag
-	 */
-	btrfs_clear_opt(fs_info->mount_opt, USEBACKUPROOT);
-
+clear_oneshot:
+	btrfs_clear_oneshot_options(fs_info);
 	return 0;
 
 fail_qgroup:
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index b3ee9c19be0c..02bee384f744 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -50,6 +50,7 @@ struct extent_buffer *btrfs_find_create_tree_block(
 						struct btrfs_fs_info *fs_info,
 						u64 bytenr);
 void btrfs_clean_tree_block(struct extent_buffer *buf);
+void btrfs_clear_oneshot_options(struct btrfs_fs_info *fs_info);
 int btrfs_mount_rw(struct btrfs_fs_info *fs_info);
 int __cold open_ctree(struct super_block *sb,
 	       struct btrfs_fs_devices *fs_devices,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 56bfa23bc52f..85a0cf56cec5 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1945,6 +1945,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 
 	wake_up_process(fs_info->transaction_kthread);
 	btrfs_remount_cleanup(fs_info, old_opts);
+	btrfs_clear_oneshot_options(fs_info);
 	clear_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state);
 
 	return 0;
-- 
2.24.1


  parent reply	other threads:[~2020-10-27 21:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 21:07 Boris Burkov
2020-10-27 21:07 ` [PATCH v5 01/10] btrfs: lift rw mount setup from mount and remount Boris Burkov
2020-10-28 14:08   ` Josef Bacik
2020-10-27 21:07 ` [PATCH v5 02/10] btrfs: cleanup all orphan inodes on ro->rw remount Boris Burkov
2020-10-28 13:52   ` Josef Bacik
2020-10-27 21:07 ` [PATCH v5 03/10] btrfs: create free space tree " Boris Burkov
2020-10-27 21:07 ` Boris Burkov [this message]
2020-10-28 13:58   ` [PATCH v5 04/10] btrfs: clear oneshot options on mount and remount Josef Bacik
2020-10-27 21:07 ` [PATCH v5 05/10] btrfs: clear free space tree on ro->rw remount Boris Burkov
2020-10-27 21:08 ` [PATCH v5 06/10] btrfs: keep sb cache_generation consistent with space_cache Boris Burkov
2020-10-27 21:08 ` [PATCH v5 07/10] btrfs: use sb state to print space_cache mount option Boris Burkov
2020-10-27 21:08 ` [PATCH v5 08/10] btrfs: warn when remount will not change the free space tree Boris Burkov
2020-10-27 21:08 ` [PATCH v5 09/10] btrfs: remove free space items when disabling space cache v1 Boris Burkov
2020-10-29 11:07   ` Wang Yugui
2020-10-29 12:25     ` Wang Yugui
2020-10-27 21:08 ` [PATCH v5 10/10] btrfs: skip space_cache v1 setup when not using it Boris Burkov

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=7b316bb772e15d62df1553c50c8bb4c50cc63c51.1603828718.git.boris@bur.io \
    --to=boris@bur.io \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@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.