Hi Jens,
This series is not planned but necessary. The four patches from me fix
a bcache super block layout issue which was introduced in 5.9 when large
bucket (32MB-1TB size for zoned device) feature firstly introduced.
Previous code has problem on space consumption and checksum calculation.
These four patches improve and fix the problems with on-disk format
consistency. Although now almost no one (except me) uses the large
bucket code now, it should be good to have the fix as soon as possible.
This series also has a patch from Yi Li which avoid a redundant value
assignment in a two-level loop. It is cool if we may have it in 5.11.
User space bcache-tools are updated for the above kernel changes too.
Please take them for 5.11-rc3.
Thanks in advance.
Coly Li
---
Coly Li (4):
bcache: fix typo from SUUP to SUPP in features.h
bcache: check unsupported feature sets for bcache register
bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large
bucket
bcache: set bcache device into read-only mode for
BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET
Yi Li (1):
bcache: set pdev_set_uuid before scond loop iteration
drivers/md/bcache/features.c | 2 +-
drivers/md/bcache/features.h | 30 ++++++++++++++++----
drivers/md/bcache/super.c | 53 +++++++++++++++++++++++++++++++++---
include/uapi/linux/bcache.h | 2 +-
4 files changed, 76 insertions(+), 11 deletions(-)
--
2.26.2
This patch fixes the following typos,
from BCH_FEATURE_COMPAT_SUUP to BCH_FEATURE_COMPAT_SUPP
from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_INCOMPAT_SUPP
from BCH_FEATURE_INCOMPAT_SUUP to BCH_FEATURE_RO_COMPAT_SUPP
Fixes: d721a43ff69c ("bcache: increase super block version for cache device and backing device")
Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
Signed-off-by: Coly Li <redacted>
Cc: stable@vger.kernel.org # 5.9+
---
drivers/md/bcache/features.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
This patch adds the check for features which is incompatible for
current supported feature sets.
Now if the bcache device created by bcache-tools has features that
current kernel doesn't support, read_super() will fail with error
messoage. E.g. if an unsupported incompatible feature detected,
bcache register will fail with dmesg "bcache: register_bcache() error :
Unsupported incompatible feature found".
Fixes: d721a43ff69c ("bcache: increase super block version for cache device and backing device")
Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
Signed-off-by: Coly Li <redacted>
Cc: stable@vger.kernel.org # 5.9+
---
drivers/md/bcache/features.h | 15 +++++++++++++++
drivers/md/bcache/super.c | 14 ++++++++++++++
2 files changed, 29 insertions(+)
From: Yi Li <redacted>
There is no need to reassign pdev_set_uuid in the second loop iteration,
so move it to the place before second loop.
Signed-off-by: Yi Li <redacted>
Signed-off-by: Coly Li <redacted>
---
drivers/md/bcache/super.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
When large bucket feature was added, BCH_FEATURE_INCOMPAT_LARGE_BUCKET
was introduced into the incompat feature set. It used bucket_size_hi
(which was added at the tail of struct cache_sb_disk) to extend current
16bit bucket size to 32bit with existing bucket_size in struct
cache_sb_disk.
This is not a good idea, there are two obvious problems,
- Bucket size is always value power of 2, if store log2(bucket size) in
existing bucket_size of struct cache_sb_disk, it is unnecessary to add
bucket_size_hi.
- Macro csum_set() assumes d[SB_JOURNAL_BUCKETS] is the last member in
struct cache_sb_disk, bucket_size_hi was added after d[] which makes
csum_set calculate an unexpected super block checksum.
To fix the above problems, this patch introduces a new incompat feature
bit BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE, when this bit is set, it
means bucket_size in struct cache_sb_disk stores the order of power-of-2
bucket size value. When user specifies a bucket size larger than 32768
sectors, BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE will be set to
incompat feature set, and bucket_size stores log2(bucket size) more
than store the real bucket size value.
The obsoleted BCH_FEATURE_INCOMPAT_LARGE_BUCKET won't be used anymore,
it is renamed to BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET and still only
recognized by kernel driver for legacy compatible purpose. The previous
bucket_size_hi is renmaed to obso_bucket_size_hi in struct cache_sb_disk
and not used in bcache-tools anymore.
For cache device created with BCH_FEATURE_INCOMPAT_LARGE_BUCKET feature,
bcache-tools and kernel driver still recognize the feature string and
display it as "obso_large_bucket".
With this change, the unnecessary extra space extend of bcache on-disk
super block can be avoided, and csum_set() may generate expected check
sum as well.
Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
Signed-off-by: Coly Li <redacted>
Cc: stable@vger.kernel.org # 5.9+
---
drivers/md/bcache/features.c | 2 +-
drivers/md/bcache/features.h | 11 ++++++++---
drivers/md/bcache/super.c | 22 +++++++++++++++++++---
include/uapi/linux/bcache.h | 2 +-
4 files changed, 29 insertions(+), 8 deletions(-)
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: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
Signed-off-by: Coly Li <redacted>
---
drivers/md/bcache/super.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
@@ -1332,6 +1332,12 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,bcache_device_link(&dc->disk,c,"bdev");atomic_inc(&c->attached_dev_nr);+if(bch_has_feature_obso_large_bucket(&(c->cache->sb))){+pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");+pr_err("Please update to the latest bcache-tools to create the cache device\n");+set_disk_ro(dc->disk.disk,1);+}+/* Allow the writeback thread to proceed */up_write(&dc->writeback_lock);
@@ -1554,6 +1560,12 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)bcache_device_link(d,c,"volume");+if(bch_has_feature_obso_large_bucket(&c->cache->sb)){+pr_err("The obsoleted large bucket layout is unsupported, set the bcache device into read-only\n");+pr_err("Please update to the latest bcache-tools to create the cache device\n");+set_disk_ro(d->disk,1);+}+return0;err:kobject_put(&d->kobj);
@@ -2113,6 +2125,9 @@ static int run_cache_set(struct cache_set *c)c->cache->sb.last_mount=(u32)ktime_get_real_seconds();bcache_write_super(c);+if(bch_has_feature_obso_large_bucket(&c->cache->sb))+pr_err("Detect obsoleted large bucket layout, all attached bcache device will be read-only\n");+list_for_each_entry_safe(dc,t,&uncached_devices,list)bch_cached_dev_attach(dc,c,NULL);
Hi Jens,
This series is not planned but necessary. The four patches from me fix
a bcache super block layout issue which was introduced in 5.9 when large
bucket (32MB-1TB size for zoned device) feature firstly introduced.
Previous code has problem on space consumption and checksum calculation.
These four patches improve and fix the problems with on-disk format
consistency. Although now almost no one (except me) uses the large
bucket code now, it should be good to have the fix as soon as possible.
This series also has a patch from Yi Li which avoid a redundant value
assignment in a two-level loop. It is cool if we may have it in 5.11.
User space bcache-tools are updated for the above kernel changes too.
Please take them for 5.11-rc3.
Hi Jens,
Could you please to take this series for rc3?
Thanks in advance.
Coly Li
---
Coly Li (4):
bcache: fix typo from SUUP to SUPP in features.h
bcache: check unsupported feature sets for bcache register
bcache: introduce BCH_FEATURE_INCOMPAT_LOG_LARGE_BUCKET_SIZE for large
bucket
bcache: set bcache device into read-only mode for
BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET
Yi Li (1):
bcache: set pdev_set_uuid before scond loop iteration
drivers/md/bcache/features.c | 2 +-
drivers/md/bcache/features.h | 30 ++++++++++++++++----
drivers/md/bcache/super.c | 53 +++++++++++++++++++++++++++++++++---
include/uapi/linux/bcache.h | 2 +-
4 files changed, 76 insertions(+), 11 deletions(-)
Hi Jens,
This series is not planned but necessary. The four patches from me fix
a bcache super block layout issue which was introduced in 5.9 when large
bucket (32MB-1TB size for zoned device) feature firstly introduced.
Previous code has problem on space consumption and checksum calculation.
These four patches improve and fix the problems with on-disk format
consistency. Although now almost no one (except me) uses the large
bucket code now, it should be good to have the fix as soon as possible.
This series also has a patch from Yi Li which avoid a redundant value
assignment in a two-level loop. It is cool if we may have it in 5.11.
User space bcache-tools are updated for the above kernel changes too.
Please take them for 5.11-rc3.