[PATCH 2/4] bcache-tools: only set/display sb.bucket_size for cache devices

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

 



bucket_size of struct cached_dev is not shared between cache devices
and backing devices. Currently make-bcache.c assigns bucket_size to
backing devices, and bcache-super-show.c displays bucket_size for
backing devices, all these are incorrect.

This patch fixes it by only set and display sb.bucket_size for cache
device super block.

Signed-off-by: Coly Li <colyli@xxxxxxx>
---
 bcache-super-show.c | 9 ++++-----
 make-bcache.c       | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/bcache-super-show.c b/bcache-super-show.c
index 26cc40e..515c596 100644
--- a/bcache-super-show.c
+++ b/bcache-super-show.c
@@ -160,20 +160,19 @@ int main(int argc, char **argv)
 	uuid_unparse(sb.uuid, uuid);
 	printf("dev.uuid\t\t%s\n", uuid);
 
-	printf("dev.sectors_per_block\t%u\n"
-	       "dev.sectors_per_bucket\t%u\n",
-	       sb.block_size,
-	       sb.bucket_size);
+	printf("dev.sectors_per_block\t%u\n", sb.block_size);
 
 	if (!SB_IS_BDEV(&sb)) {
 		// total_sectors includes the superblock;
-		printf("dev.cache.first_sector\t%u\n"
+		printf("dev.sectors_per_block\t%u\n"
+		       "dev.cache.first_sector\t%u\n"
 		       "dev.cache.cache_sectors\t%ju\n"
 		       "dev.cache.total_sectors\t%ju\n"
 		       "dev.cache.ordered\t%s\n"
 		       "dev.cache.discard\t%s\n"
 		       "dev.cache.pos\t\t%u\n"
 		       "dev.cache.replacement\t%ju",
+		       sb.bucket_size,
 		       sb.bucket_size * sb.first_bucket,
 		       sb.bucket_size * (sb.nbuckets - sb.first_bucket),
 		       sb.bucket_size * sb.nbuckets,
diff --git a/make-bcache.c b/make-bcache.c
index c626eae..14c605d 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -217,7 +217,6 @@ static void write_sb(char *dev, unsigned block_size, unsigned bucket_size,
 	uuid_generate(sb.uuid);
 	memcpy(sb.set_uuid, set_uuid, sizeof(sb.set_uuid));
 
-	sb.bucket_size	= bucket_size;
 	sb.block_size	= block_size;
 
 	uuid_unparse(sb.uuid, uuid_str);
@@ -242,6 +241,7 @@ static void write_sb(char *dev, unsigned block_size, unsigned bucket_size,
 		       sb.block_size,
 		       data_offset);
 	} else {
+		sb.bucket_size		= bucket_size;
 		sb.nbuckets		= getblocks(fd) / sb.bucket_size;
 		sb.nr_in_set		= 1;
 		sb.first_bucket		= (23 / sb.bucket_size) + 1;
-- 
2.16.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