[PATCH 1/3] bcache-tools: recover the missing sb.csum for showing bcache device super block

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 lib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib.c b/lib.c
index b005eb5..340ddf3 100644
--- a/lib.c
+++ b/lib.c
@@ -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);
-- 
2.26.2




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux