linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v6 08/10] btrfs: warn when remount will not change the free space tree
Date: Thu, 29 Oct 2020 16:57:55 -0700	[thread overview]
Message-ID: <a36a1c2acfa645af6d021c512b61c943f1f534d7.1604015464.git.boris@bur.io> (raw)
In-Reply-To: <cover.1604015464.git.boris@bur.io>

If the remount is ro->ro, rw->ro, or rw->rw, we will not create or
clear the free space tree. This can be surprising, so print a warning
to dmesg to make the failure more visible. It is also important to
ensure that the space cache options (SPACE_CACHE, FREE_SPACE_TREE) are
consistent, so ensure those are set to properly match the current on
disk state (which won't be changing).

Signed-off-by: Boris Burkov <boris@bur.io>
---
 fs/btrfs/super.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 527ab305ac68..ed5c80f92f78 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1914,6 +1914,24 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 	btrfs_resize_thread_pool(fs_info,
 		fs_info->thread_pool_size, old_thread_pool_size);
 
+	if (btrfs_test_opt(fs_info, FREE_SPACE_TREE) !=
+	    btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) &&
+	    ((!sb_rdonly(sb) || *flags & SB_RDONLY))) {
+		btrfs_warn(fs_info,
+	   "remount supports changing free space tree only from ro to rw");
+		/*
+		 * Make sure free space cache options match the state on disk
+		 */
+		if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
+			btrfs_set_opt(fs_info->mount_opt, FREE_SPACE_TREE);
+			btrfs_clear_opt(fs_info->mount_opt, SPACE_CACHE);
+		}
+		if (btrfs_free_space_cache_v1_active(fs_info)) {
+			btrfs_clear_opt(fs_info->mount_opt, FREE_SPACE_TREE);
+			btrfs_set_opt(fs_info->mount_opt, SPACE_CACHE);
+		}
+	}
+
 	if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
 		goto out;
 
-- 
2.24.1


  parent reply	other threads:[~2020-10-29 23:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 23:57 [PATCH v6 00/10] btrfs: free space tree mounting fixes Boris Burkov
2020-10-29 23:57 ` [PATCH v6 01/10] btrfs: lift rw mount setup from mount and remount Boris Burkov
2020-10-29 23:57 ` [PATCH v6 02/10] btrfs: cleanup all orphan inodes on ro->rw remount Boris Burkov
2020-10-29 23:57 ` [PATCH v6 03/10] btrfs: create free space tree " Boris Burkov
2020-10-29 23:57 ` [PATCH v6 04/10] btrfs: clear oneshot options on mount and remount Boris Burkov
2020-10-29 23:57 ` [PATCH v6 05/10] btrfs: clear free space tree on ro->rw remount Boris Burkov
2020-10-29 23:57 ` [PATCH v6 06/10] btrfs: keep sb cache_generation consistent with space_cache Boris Burkov
2020-10-29 23:57 ` [PATCH v6 07/10] btrfs: use sb state to print space_cache mount option Boris Burkov
2020-10-29 23:57 ` Boris Burkov [this message]
2020-10-29 23:57 ` [PATCH v6 09/10] btrfs: remove free space items when disabling space cache v1 Boris Burkov
2020-10-29 23:57 ` [PATCH v6 10/10] btrfs: skip space_cache v1 setup when not using it Boris Burkov
2020-11-06 16:39 ` [PATCH v6 00/10] btrfs: free space tree mounting fixes Josef Bacik

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=a36a1c2acfa645af6d021c512b61c943f1f534d7.1604015464.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).