Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Tal Zussman <tz2294@columbia.edu>,
	David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 01/16] btrfs: stop enabling the v1 space cache from the on-disk state
Date: Mon, 14 Sep 2026 08:43:19 +0930	[thread overview]
Message-ID: <42025eb2-da6f-4319-83db-9cbd7ac3a7b9@suse.com> (raw)
In-Reply-To: <20260913-btrfs-remove-v1-space-cache-v2-1-186767a7e106@columbia.edu>



在 2026/9/14 06:51, Tal Zussman 写道:
> Since commit 545e560a5b0f ("btrfs: disable v1 space cache") the mount
> options can no longer request the v1 space cache, but a filesystem with
> an active v1 cache and no free space tree still enables it from
> cache_generation, and remount does the same. Drop both, so SPACE_CACHE
> can never be set.

Oh, this is a bug in that commit, I intended to reject all v1 space 
cache usage, but lost the case where no "space_cache=" mount option is 
specified.
> 
> btrfs_start_pre_rw_mount() then sees the on-disk cache as active but
> unwanted and cleans it up, as -o nospace_cache does today. That covers
> the read-only to read-write remount as well, so drop the toggle in
> btrfs_remount_cleanup(), which would otherwise start a transaction on
> remounts of a read-only filesystem with an old cache.
> 
> The cleanup is now unconditional, and the first read-write mount fails
> if it fails, as it did with -o nospace_cache. This also lets an old
> filesystem mount without options when the page size is larger than the
> sector size, which btrfs_check_features() rejected once SPACE_CACHE was
> set from the superblock.
> 
> Assisted-by: Claude:claude-fable-5-1
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/super.c | 16 +++-------------
>   1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 464129b1b0d4..77443ded6db3 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -759,12 +759,12 @@ void btrfs_set_free_space_cache_settings(struct btrfs_fs_info *fs_info)
>   
>   	/*
>   	 * At this point we don't have explicit options set by the user, set
> -	 * them ourselves based on the state of the file system.
> +	 * them ourselves based on the state of the file system. An existing
> +	 * v1 space cache is no longer used and gets cleaned up once the
> +	 * filesystem is mounted read-write.
>   	 */
>   	if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE))
>   		btrfs_set_opt(fs_info->mount_opt, FREE_SPACE_TREE);
> -	else if (btrfs_free_space_cache_v1_active(fs_info))
> -		btrfs_set_opt(fs_info->mount_opt, SPACE_CACHE);
>   }
>   
>   static void set_device_specific_options(struct btrfs_fs_info *fs_info)
> @@ -1264,8 +1264,6 @@ static inline void btrfs_remount_begin(struct btrfs_fs_info *fs_info,
>   static inline void btrfs_remount_cleanup(struct btrfs_fs_info *fs_info,
>   					 unsigned long long old_opts)
>   {
> -	const bool cache_opt = btrfs_test_opt(fs_info, SPACE_CACHE);
> -
>   	/*
>   	 * We need to cleanup all defraggable inodes if the autodefragment is
>   	 * close or the filesystem is read only.
> @@ -1282,10 +1280,6 @@ static inline void btrfs_remount_cleanup(struct btrfs_fs_info *fs_info,
>   	else if (btrfs_raw_test_opt(old_opts, DISCARD_ASYNC) &&
>   		 !btrfs_test_opt(fs_info, DISCARD_ASYNC))
>   		btrfs_discard_cleanup(fs_info);
> -
> -	/* If we toggled space cache */
> -	if (cache_opt != btrfs_free_space_cache_v1_active(fs_info))
> -		btrfs_set_free_space_cache_v1_active(fs_info, cache_opt);
>   }
>   
>   static int btrfs_remount_rw(struct btrfs_fs_info *fs_info)
> @@ -1535,10 +1529,6 @@ static int btrfs_reconfigure(struct fs_context *fc)
>   			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);
> -		}
>   	}
>   
>   	ret = 0;
> 


  reply	other threads:[~2026-09-13 23:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 21:21 [PATCH v2 00/16] btrfs: remove the v1 space cache Tal Zussman
2026-09-13 21:21 ` [PATCH v2 01/16] btrfs: stop enabling the v1 space cache from the on-disk state Tal Zussman
2026-09-13 23:13   ` Qu Wenruo [this message]
2026-09-13 21:21 ` [PATCH v2 02/16] btrfs: remove the v1 space cache writeout from the transaction commit Tal Zussman
2026-09-13 21:21 ` [PATCH v2 03/16] btrfs: remove the free space cache endio workqueue Tal Zussman
2026-09-13 21:21 ` [PATCH v2 04/16] btrfs: remove the v1 space cache write path Tal Zussman
2026-09-13 21:21 ` [PATCH v2 05/16] btrfs: drop the transaction handle from the prealloc helpers Tal Zussman
2026-09-13 21:21 ` [PATCH v2 06/16] btrfs: remove the v1 space cache load path Tal Zussman
2026-09-13 21:21 ` [PATCH v2 07/16] btrfs: remove btrfs_disk_cache_state Tal Zussman
2026-09-13 21:21 ` [PATCH v2 08/16] btrfs: remove the SPACE_CACHE mount option flag Tal Zussman
2026-09-13 21:21 ` [PATCH v2 09/16] btrfs: replace btrfs_set_free_space_cache_v1_active() with a cleanup helper Tal Zussman
2026-09-13 21:21 ` [PATCH v2 10/16] btrfs: remove the free space cache trimming ranges Tal Zussman
2026-09-13 21:21 ` [PATCH v2 11/16] btrfs: remove BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE Tal Zussman
2026-09-13 21:21 ` [PATCH v2 12/16] btrfs: remove the free space inode ordered extent special cases Tal Zussman
2026-09-13 21:21 ` [PATCH v2 13/16] btrfs: remove the free space inode special cases from the COW paths Tal Zussman
2026-09-13 21:21 ` [PATCH v2 14/16] btrfs: stop special-casing free space inodes in the delalloc accounting Tal Zussman
2026-09-13 21:21 ` [PATCH v2 15/16] btrfs: stop reading free space inodes from the commit root Tal Zussman
2026-09-13 21:21 ` [PATCH v2 16/16] btrfs: remove TRANS_JOIN_NOLOCK Tal Zussman

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=42025eb2-da6f-4319-83db-9cbd7ac3a7b9@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mason@kernel.org \
    --cc=tz2294@columbia.edu \
    /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