diff options
author | Coly Li <colyli@suse.de> | 2021-01-03 23:35:50 +0800 |
---|---|---|
committer | Coly Li <colyli@suse.de> | 2021-01-04 00:12:22 +0800 |
commit | 0c6e42ef568cece1c041fea5dcd0178d403b517b (patch) | |
tree | c5721b68c2e7df7d3c6ea91890d31e44078edd96 | |
parent | 40cf747541aea3905c328ff351e88cc6ad9a66bf (diff) | |
download | bcache-tools-0c6e42ef568cece1c041fea5dcd0178d403b517b.tar.gz |
bcache-tools: recover the missing sb.csum for showing bcache device super block
Commit 2891723d7075 ("bcache-tools: define separated super block for
in-memory and on-disk format") does following change in detail_base(),
strcpy(base->name, devname);
base->magic = "ok";
base->first_sector = SB_SECTOR;
- base->csum = sb.csum;
base->version = sb.version;
because sb (in type struct cache_sb) doesn't have csum of the on-disk
super block anymore. The aftermath is base.csum was missing, and the
"show" command always display sb.csum as 0.
This patch recovers the csum value setting for base.csum, then command
"bcache show -d" may display the correct super block check sum.
Fixes: 2891723d7075 ("bcache-tools: define separated super block for in-memory and on-disk format")
Signed-off-by: Coly Li <colyli@suse.de>
-rw-r--r-- | lib.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -487,6 +487,7 @@ int detail_dev(char *devname, struct bdev *bd, struct cdev *cd, int *type) sb.version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET || sb.version == BCACHE_SB_VERSION_BDEV_WITH_FEATURES) { detail_base(devname, sb, &bd->base); + bd->base.csum = expected_csum; bd->first_sector = BDEV_DATA_START_DEFAULT; bd->cache_mode = BDEV_CACHE_MODE(&sb); bd->cache_state = BDEV_STATE(&sb); @@ -494,6 +495,7 @@ int detail_dev(char *devname, struct bdev *bd, struct cdev *cd, int *type) sb.version == BCACHE_SB_VERSION_CDEV_WITH_UUID || sb.version == BCACHE_SB_VERSION_CDEV_WITH_FEATURES) { detail_base(devname, sb, &cd->base); + cd->base.csum = expected_csum; cd->first_sector = sb.bucket_size * sb.first_bucket; cd->cache_sectors = sb.bucket_size * (sb.nbuckets - sb.first_bucket); |