]> git.hungrycats.org Git - linux/commitdiff
btrfs: remove the SPACE_CACHE mount option flag
authorTal Zussman <tz2294@columbia.edu>
Thu, 17 Sep 2026 04:00:05 +0000 (00:00 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 17 Sep 2026 17:49:48 +0000 (19:49 +0200)
Nothing sets BTRFS_MOUNT_SPACE_CACHE anymore, so every test of it is
false. Remove the flag, the checks rejecting the v1 cache on zoned
filesystems and for sector sizes other than the page size, and the
deprecation warning. Show a read-only filesystem that still has an old
cache as nospace_cache, since that's what's in effect. space_cache and
space_cache=v1 keep falling back to no space cache with a warning.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c
fs/btrfs/fs.h
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/zoned.c

index 140577a7f7974f90642c89056c04703499f37f77..2563e06f29d1b1eedaa76e636cec9c5ba78600d4 100644 (file)
@@ -3069,7 +3069,6 @@ static int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info)
 int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info)
 {
        int ret;
-       const bool cache_opt = btrfs_test_opt(fs_info, SPACE_CACHE);
        bool rebuild_free_space_tree = false;
 
        if (btrfs_test_opt(fs_info, CLEAR_CACHE) &&
@@ -3164,8 +3163,8 @@ int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info)
                }
        }
 
-       if (cache_opt != btrfs_free_space_cache_v1_active(fs_info)) {
-               ret = btrfs_set_free_space_cache_v1_active(fs_info, cache_opt);
+       if (btrfs_free_space_cache_v1_active(fs_info)) {
+               ret = btrfs_set_free_space_cache_v1_active(fs_info, false);
                if (ret)
                        return ret;
        }
@@ -3281,20 +3280,6 @@ int btrfs_check_features(struct btrfs_fs_info *fs_info, bool is_rw_mount)
                return -EINVAL;
        }
 
-       /*
-        * Subpage/bs > ps runtime limitation on v1 cache.
-        *
-        * V1 space cache still has some hard coded PAGE_SIZE usage, while
-        * we're already defaulting to v2 cache, no need to bother v1 as it's
-        * going to be deprecated anyway.
-        */
-       if (fs_info->sectorsize != PAGE_SIZE && btrfs_test_opt(fs_info, SPACE_CACHE)) {
-               btrfs_warn(fs_info,
-       "v1 space cache is not supported for page size %lu with sectorsize %u",
-                          PAGE_SIZE, fs_info->sectorsize);
-               return -EINVAL;
-       }
-
        /* This can be called by remount, we need to protect the super block. */
        spin_lock(&fs_info->super_lock);
        btrfs_set_super_incompat_flags(disk_super, incompat);
index 441b315e8a989325da568a83a2b6cae765e5921d..79d0828c51c7d7c327d0d2d59ff4a2ad95316b76 100644 (file)
@@ -259,7 +259,6 @@ enum {
        BTRFS_MOUNT_NOSSD                       = (1ULL << 9),
        BTRFS_MOUNT_DISCARD_SYNC                = (1ULL << 10),
        BTRFS_MOUNT_FORCE_COMPRESS              = (1ULL << 11),
-       BTRFS_MOUNT_SPACE_CACHE                 = (1ULL << 12),
        BTRFS_MOUNT_CLEAR_CACHE                 = (1ULL << 13),
        BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED      = (1ULL << 14),
        BTRFS_MOUNT_ENOSPC_DEBUG                = (1ULL << 15),
index b44b16970a6233cba406f20845cd93ed1afbef4a..6ddb7b35216625b3d64d742f7f23f73520432b62 100644 (file)
@@ -515,7 +515,6 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
                        btrfs_warn(NULL,
                        "v1 space cache is deprecated, falling back to no space cache");
                btrfs_set_opt(ctx->mount_opt, NOSPACECACHE);
-               btrfs_clear_opt(ctx->mount_opt, SPACE_CACHE);
                btrfs_clear_opt(ctx->mount_opt, FREE_SPACE_TREE);
                break;
        case Opt_space_cache_version:
@@ -524,11 +523,9 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
                        btrfs_warn(NULL,
                        "v1 space cache is deprecated, falling back to no space cache");
                        btrfs_set_opt(ctx->mount_opt, NOSPACECACHE);
-                       btrfs_clear_opt(ctx->mount_opt, SPACE_CACHE);
                        btrfs_clear_opt(ctx->mount_opt, FREE_SPACE_TREE);
                        break;
                case Opt_space_cache_v2:
-                       btrfs_clear_opt(ctx->mount_opt, SPACE_CACHE);
                        btrfs_set_opt(ctx->mount_opt, FREE_SPACE_TREE);
                        break;
                default:
@@ -705,13 +702,6 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
        if (btrfs_check_mountopts_zoned(info, mount_opt))
                ret = false;
 
-       if (!test_bit(BTRFS_FS_STATE_REMOUNTING, &info->fs_state)) {
-               if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
-                       btrfs_warn(info,
-"space cache v1 is being deprecated and will be removed in a future release, please use -o space_cache=v2");
-               }
-       }
-
        return ret;
 }
 
@@ -729,14 +719,6 @@ bool btrfs_check_options(const struct btrfs_fs_info *info,
  */
 void btrfs_set_free_space_cache_settings(struct btrfs_fs_info *fs_info)
 {
-       if (fs_info->sectorsize != PAGE_SIZE && btrfs_test_opt(fs_info, SPACE_CACHE)) {
-               btrfs_info(fs_info,
-                          "forcing free space tree for sector size %u with page size %lu",
-                          fs_info->sectorsize, PAGE_SIZE);
-               btrfs_clear_opt(fs_info->mount_opt, SPACE_CACHE);
-               btrfs_set_opt(fs_info->mount_opt, FREE_SPACE_TREE);
-       }
-
        /*
         * At this point our mount options are populated, so we only mess with
         * these settings if we don't have any settings already.
@@ -751,9 +733,6 @@ void btrfs_set_free_space_cache_settings(struct btrfs_fs_info *fs_info)
                return;
        }
 
-       if (btrfs_test_opt(fs_info, SPACE_CACHE))
-               return;
-
        if (btrfs_test_opt(fs_info, NOSPACECACHE))
                return;
 
@@ -1107,9 +1086,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
                seq_puts(seq, ",discard=async");
        if (!(info->sb->s_flags & SB_POSIXACL))
                seq_puts(seq, ",noacl");
-       if (btrfs_free_space_cache_v1_active(info))
-               seq_puts(seq, ",space_cache");
-       else if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE))
+       if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE))
                seq_puts(seq, ",space_cache=v2");
        else
                seq_puts(seq, ",nospace_cache");
@@ -1441,7 +1418,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
        btrfs_info_if_set(info, old, DISCARD_SYNC, "turning on sync discard");
        btrfs_info_if_set(info, old, DISCARD_ASYNC, "turning on async discard");
        btrfs_info_if_set(info, old, FREE_SPACE_TREE, "enabling free space tree");
-       btrfs_info_if_set(info, old, SPACE_CACHE, "enabling disk space caching");
        btrfs_info_if_set(info, old, CLEAR_CACHE, "force clearing of disk cache");
        btrfs_info_if_set(info, old, AUTO_DEFRAG, "enabling auto defrag");
        btrfs_info_if_set(info, old, FRAGMENT_DATA, "fragmenting data");
@@ -1459,7 +1435,6 @@ static void btrfs_emit_options(struct btrfs_fs_info *info,
        btrfs_info_if_unset(info, old, SSD_SPREAD, "not using spread ssd allocation scheme");
        btrfs_info_if_unset(info, old, NOBARRIER, "turning on barriers");
        btrfs_info_if_unset(info, old, NOTREELOG, "enabling tree log");
-       btrfs_info_if_unset(info, old, SPACE_CACHE, "disabling disk space caching");
        btrfs_info_if_unset(info, old, FREE_SPACE_TREE, "disabling free space tree");
        btrfs_info_if_unset(info, old, AUTO_DEFRAG, "disabling auto defrag");
        btrfs_info_if_unset(info, old, COMPRESS, "use no compression");
@@ -1524,10 +1499,8 @@ static int btrfs_reconfigure(struct fs_context *fc)
                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)) {
+               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);
-               }
        }
 
        ret = 0;
index 61fe4a889c9b6faa3641dd3ede5a1958523d8054..b0e38039eca184a072d5dac95ccd036168a87cf2 100644 (file)
@@ -1983,9 +1983,7 @@ static void update_super_roots(struct btrfs_fs_info *fs_info)
        super->root = root_item->bytenr;
        super->generation = root_item->generation;
        super->root_level = root_item->level;
-       if (btrfs_test_opt(fs_info, SPACE_CACHE))
-               super->cache_generation = root_item->generation;
-       else if (test_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags))
+       if (test_bit(BTRFS_FS_CLEANUP_SPACE_CACHE_V1, &fs_info->flags))
                super->cache_generation = 0;
        if (test_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags))
                super->uuid_tree_generation = root_item->generation;
index a1ef8caaacdab424e0090753d24ef40b82703bf4..c04a9955f2d39bf080319c66beea71a2cd3aef93 100644 (file)
@@ -804,15 +804,6 @@ int btrfs_check_mountopts_zoned(const struct btrfs_fs_info *info,
        if (!btrfs_is_zoned(info))
                return 0;
 
-       /*
-        * Space cache writing is not COWed. Disable that to avoid write errors
-        * in sequential zones.
-        */
-       if (btrfs_raw_test_opt(*mount_opt, SPACE_CACHE)) {
-               btrfs_err(info, "zoned: space cache v1 is not supported");
-               return -EINVAL;
-       }
-
        if (btrfs_raw_test_opt(*mount_opt, NODATACOW)) {
                btrfs_err(info, "zoned: NODATACOW not supported");
                return -EINVAL;