]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcache: drop discard sysfs interface
authorColy Li <colyli@fnnas.com>
Thu, 13 Nov 2025 05:36:24 +0000 (13:36 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Nov 2025 16:18:06 +0000 (09:18 -0700)
Since discard code is removed, now the sysfs interface to enable discard
is useless. This patch removes the corresponding sysfs entry, and remove
bool variable 'discard' from struct cache as well.

Signed-off-by: Coly Li <colyli@fnnas.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/bcache.h
drivers/md/bcache/super.c
drivers/md/bcache/sysfs.c
drivers/md/bcache/writeback.c

index 1d33e40d26ea51f6e433978315df0213259a38ef..b8bd6d4a4298659b5771eedc6728994de1a8ad63 100644 (file)
@@ -447,8 +447,7 @@ struct cache {
         * free_inc: Incoming buckets - these are buckets that currently have
         * cached data in them, and we can't reuse them until after we write
         * their new gen to disk. After prio_write() finishes writing the new
-        * gens/prios, they'll be moved to the free list (and possibly discarded
-        * in the process)
+        * gens/prios, they'll be moved to the free list.
         */
        DECLARE_FIFO(long, free)[RESERVE_NR];
        DECLARE_FIFO(long, free_inc);
@@ -467,8 +466,6 @@ struct cache {
         */
        unsigned int            invalidate_needs_gc;
 
-       bool                    discard; /* Get rid of? */
-
        struct journal_device   journal;
 
        /* The rest of this all shows up in sysfs */
index 6d250e366412c71169be651b3251afa87d3c3856..91a98ebc3f8016cbdb4ef28fbbcacc80a3718a10 100644 (file)
@@ -2382,9 +2382,6 @@ static int register_cache(struct cache_sb *sb, struct cache_sb_disk *sb_disk,
        ca->bdev = file_bdev(bdev_file);
        ca->sb_disk = sb_disk;
 
-       if (bdev_max_discard_sectors(file_bdev(bdev_file)))
-               ca->discard = CACHE_DISCARD(&ca->sb);
-
        ret = cache_alloc(ca);
        if (ret != 0) {
                if (ret == -ENOMEM)
index 826b14cae4e58e72ebb24478be227662354854c3..72f38e5b6f5c74c52262fb2858e5a26aef6dce42 100644 (file)
@@ -134,7 +134,6 @@ read_attribute(partial_stripes_expensive);
 rw_attribute(synchronous);
 rw_attribute(journal_delay_ms);
 rw_attribute(io_disable);
-rw_attribute(discard);
 rw_attribute(running);
 rw_attribute(label);
 rw_attribute(errors);
@@ -1036,7 +1035,6 @@ SHOW(__bch_cache)
        sysfs_hprint(bucket_size,       bucket_bytes(ca));
        sysfs_hprint(block_size,        block_bytes(ca));
        sysfs_print(nbuckets,           ca->sb.nbuckets);
-       sysfs_print(discard,            ca->discard);
        sysfs_hprint(written, atomic_long_read(&ca->sectors_written) << 9);
        sysfs_hprint(btree_written,
                     atomic_long_read(&ca->btree_sectors_written) << 9);
@@ -1142,18 +1140,6 @@ STORE(__bch_cache)
        if (bcache_is_reboot)
                return -EBUSY;
 
-       if (attr == &sysfs_discard) {
-               bool v = strtoul_or_return(buf);
-
-               if (bdev_max_discard_sectors(ca->bdev))
-                       ca->discard = v;
-
-               if (v != CACHE_DISCARD(&ca->sb)) {
-                       SET_CACHE_DISCARD(&ca->sb, v);
-                       bcache_write_super(ca->set);
-               }
-       }
-
        if (attr == &sysfs_cache_replacement_policy) {
                v = __sysfs_match_string(cache_replacement_policies, -1, buf);
                if (v < 0)
@@ -1185,7 +1171,6 @@ static struct attribute *bch_cache_attrs[] = {
        &sysfs_block_size,
        &sysfs_nbuckets,
        &sysfs_priority_stats,
-       &sysfs_discard,
        &sysfs_written,
        &sysfs_btree_written,
        &sysfs_metadata_written,
index 6ba73dc1a3dff175482ce06cbd09e6dcabd83b2f..cffef33b4acf3455b51efc85d5ba45e30c5bdc0c 100644 (file)
@@ -805,8 +805,7 @@ static int bch_writeback_thread(void *arg)
                         * may set BCH_ENABLE_AUTO_GC via sysfs, then when
                         * BCH_DO_AUTO_GC is set, garbage collection thread
                         * will be wake up here. After moving gc, the shrunk
-                        * btree and discarded free buckets SSD space may be
-                        * helpful for following write requests.
+                        * btree may be helpful for following write requests.
                         */
                        if (c->gc_after_writeback ==
                            (BCH_ENABLE_AUTO_GC|BCH_DO_AUTO_GC)) {