Skip to content

Commit 5342fd4

Browse files
Coly Liaxboe
authored andcommitted
bcache: set bcache device into read-only mode for BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET
If BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET is set in incompat feature set, it means the cache device is created with obsoleted layout with obso_bucket_site_hi. Now bcache does not support this feature bit, a new BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE incompat feature bit is added for a better layout to support large bucket size. For the legacy compatibility purpose, if a cache device created with obsoleted BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET feature bit, all bcache devices attached to this cache set should be set to read-only. Then the dirty data can be written back to backing device before re-create the cache device with BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE feature bit by the latest bcache-tools. This patch checks BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET feature bit when running a cache set and attach a bcache device to the cache set. If this bit is set, - When run a cache set, print an error kernel message to indicate all following attached bcache device will be read-only. - When attach a bcache device, print an error kernel message to indicate the attached bcache device will be read-only, and ask users to update to latest bcache-tools. Such change is only for cache device whose bucket size >= 32MB, this is for the zoned SSD and almost nobody uses such large bucket size at this moment. If you don't explicit set a large bucket size for a zoned SSD, such change is totally transparent to your bcache device. Fixes: ffa4703 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket") Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b16671e commit 5342fd4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/md/bcache/super.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,12 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
13321332
bcache_device_link(&dc->disk, c, "bdev");
13331333
atomic_inc(&c->attached_dev_nr);
13341334

1335+
if (bch_has_feature_obso_large_bucket(&(c->cache->sb))) {
1336+
pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");
1337+
pr_err("Please update to the latest bcache-tools to create the cache device\n");
1338+
set_disk_ro(dc->disk.disk, 1);
1339+
}
1340+
13351341
/* Allow the writeback thread to proceed */
13361342
up_write(&dc->writeback_lock);
13371343

@@ -1554,6 +1560,12 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
15541560

15551561
bcache_device_link(d, c, "volume");
15561562

1563+
if (bch_has_feature_obso_large_bucket(&c->cache->sb)) {
1564+
pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");
1565+
pr_err("Please update to the latest bcache-tools to create the cache device\n");
1566+
set_disk_ro(d->disk, 1);
1567+
}
1568+
15571569
return 0;
15581570
err:
15591571
kobject_put(&d->kobj);
@@ -2113,6 +2125,9 @@ static int run_cache_set(struct cache_set *c)
21132125
c->cache->sb.last_mount = (u32)ktime_get_real_seconds();
21142126
bcache_write_super(c);
21152127

2128+
if (bch_has_feature_obso_large_bucket(&c->cache->sb))
2129+
pr_err("Detect obsoleted large bucket layout, all attached bcache device will be read-only\n");
2130+
21162131
list_for_each_entry_safe(dc, t, &uncached_devices, list)
21172132
bch_cached_dev_attach(dc, c, NULL);
21182133

0 commit comments

Comments
 (0)