From: David Sterba <dsterba@suse.cz>
To: Tal Zussman <tz2294@columbia.edu>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 01/17] btrfs: stop enabling the v1 space cache from the on-disk state
Date: Fri, 18 Sep 2026 11:57:57 +0200 [thread overview]
Message-ID: <20260918095757.GX54722@suse.cz> (raw)
In-Reply-To: <20260917041202.74A691F00893@smtp.kernel.org>
On Thu, Sep 17, 2026 at 04:12:02AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] btrfs: FREE_SPACE_TREE option leaks on invalid RO remounts
> --
>
> commit 6751f883b4d1cad106e74cd1b62922302a1c3544
> Author: Tal Zussman <tz2294@columbia.edu>
>
> btrfs: stop enabling the v1 space cache from the on-disk state
>
> This commit prevents the v1 space cache from being automatically enabled
> based on the on-disk state. Remounts of read-only filesystems with an old
> cache no longer start a transaction, and space cache cleanup happens
> unconditionally upon a read-write mount.
>
> > diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> > index 464129b1b0d4c..77443ded6db39 100644
> > --- a/fs/btrfs/super.c
> > +++ b/fs/btrfs/super.c
> [ ... ]
> > @@ -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;
>
> [Severity: Medium]
> Does removing the v1 space cache check here allow the FREE_SPACE_TREE option
> to leak on invalid read-only remounts?
>
> If a user with a filesystem using the v1 space cache attempts a read-only
> remount with "space_cache=v2", the kernel emits a warning that this is only
> supported on a read-write remount and intends to reject it.
>
> However, because the v1_active check that previously reverted the
> FREE_SPACE_TREE option was removed without an unconditional fallback, the
> option appears to silently leak into fs_info->mount_opt in
> btrfs_reconfigure().
>
> If the user later performs a standard read-write remount, could the kernel
> see the leaked option and unexpectedly create the v2 free space tree?
This looks valid, though the consequences are not disatrous but still
unexpected to create FST.
next prev parent reply other threads:[~2026-09-18 9:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 3:59 [PATCH v3 00/17] btrfs: remove the v1 space cache Tal Zussman
2026-09-17 3:59 ` [PATCH v3 01/17] btrfs: stop enabling the v1 space cache from the on-disk state Tal Zussman
[not found] ` <20260917041202.74A691F00893@smtp.kernel.org>
2026-09-18 9:57 ` David Sterba [this message]
2026-09-22 1:43 ` Tal Zussman
2026-09-17 3:59 ` [PATCH v3 02/17] btrfs: remove the v1 space cache writeout from the transaction commit Tal Zussman
2026-09-17 3:59 ` [PATCH v3 03/17] btrfs: remove the free space cache endio workqueue Tal Zussman
2026-09-17 4:00 ` [PATCH v3 04/17] btrfs: remove the v1 space cache write path Tal Zussman
2026-09-17 4:00 ` [PATCH v3 05/17] btrfs: rename cache_write_mutex to dirty_bgs_update_mutex Tal Zussman
2026-09-17 4:00 ` [PATCH v3 06/17] btrfs: drop the transaction handle from the prealloc helpers Tal Zussman
2026-09-17 4:00 ` [PATCH v3 07/17] btrfs: remove the v1 space cache load path Tal Zussman
2026-09-17 4:00 ` [PATCH v3 08/17] btrfs: remove btrfs_disk_cache_state Tal Zussman
2026-09-17 4:00 ` [PATCH v3 09/17] btrfs: remove the SPACE_CACHE mount option flag Tal Zussman
2026-09-17 4:00 ` [PATCH v3 10/17] btrfs: replace btrfs_set_free_space_cache_v1_active() with a cleanup helper Tal Zussman
2026-09-17 4:00 ` [PATCH v3 11/17] btrfs: remove the free space cache trimming ranges Tal Zussman
2026-09-17 4:00 ` [PATCH v3 12/17] btrfs: remove BTRFS_RESERVE_FLUSH_FREE_SPACE_INODE Tal Zussman
2026-09-17 4:00 ` [PATCH v3 13/17] btrfs: remove the free space inode ordered extent special cases Tal Zussman
2026-09-17 4:00 ` [PATCH v3 14/17] btrfs: remove the free space inode special cases from the COW paths Tal Zussman
2026-09-17 4:00 ` [PATCH v3 15/17] btrfs: stop special-casing free space inodes in the delalloc accounting Tal Zussman
2026-09-17 4:00 ` [PATCH v3 16/17] btrfs: stop reading free space inodes from the commit root Tal Zussman
2026-09-17 4:00 ` [PATCH v3 17/17] 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=20260918095757.GX54722@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.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