summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel <g2p.code@gmail.com>2013-03-09 15:51:17 +0100
committerGabriel <g2p.code@gmail.com>2013-03-09 15:51:17 +0100
commit3b6ae63e496d5e7c1ebbbf570ce26379ca55499d (patch)
tree7b03328ebfb1d46830187b8502ef9e9bd6f0fff7
parent865a3b1f0b3093ffbdf1ac91076f1c7ac7d22238 (diff)
Fix offsets, cache and backing are two different cases.
-rw-r--r--bcache-super-show.c28
-rw-r--r--bcache.h2
-rw-r--r--make-bcache.c8
3 files changed, 24 insertions, 14 deletions
diff --git a/bcache-super-show.c b/bcache-super-show.c
index 6f9f6a7..97154cd 100644
--- a/bcache-super-show.c
+++ b/bcache-super-show.c
@@ -97,12 +97,12 @@ int main(int argc, char **argv)
printf("sb.version\t\t%" PRIu64, sb.version);
switch (sb.version) {
- case 1:
- printf(" [backing device]\n");
+ case 0:
+ printf(" [cache device]\n");
break;
- case 2:
- printf(" [cache device]\n");
+ case CACHE_BACKING_DEV: // 1
+ printf(" [backing device]\n");
break;
case 3:
@@ -125,15 +125,23 @@ int main(int argc, char **argv)
"dev.sectors_per_block\t%u\n"
"dev.sectors_per_bucket\t%u\n"
"dev.bucket_count\t%ju\n"
- "dev.cache_count\t\t%u\n" // expect version == 2 ? 1 : 0
- "dev.data.first_bucket\t%u\n",
+ "dev.cache_count\t\t%u\n", // expect version == 0 ? 1 : 0
sb.block_size,
sb.bucket_size,
sb.nbuckets,
- sb.nr_this_dev,
- sb.first_bucket);
-
- printf("dev.data.first_sector\t%u\n", sb.bucket_size * sb.first_bucket);
+ sb.nr_this_dev);
+
+ if (sb.version == 0) {
+ printf(
+ "dev.cache.first_bucket\t%u\n"
+ "dev.cache.first_sector\t%u\n",
+ sb.first_bucket,
+ sb.bucket_size * sb.first_bucket);
+ } else if (sb.version == CACHE_BACKING_DEV) {
+ printf(
+ "dev.data.first_sector\t%u\n",
+ BDEV_DATA_START);
+ }
putchar('\n');
uuid_unparse(sb.set_uuid, uuid);
diff --git a/bcache.h b/bcache.h
index 8087092..2e01549 100644
--- a/bcache.h
+++ b/bcache.h
@@ -25,6 +25,8 @@ static const char bcache_magic[] = {
#define SB_SECTOR 8
#define SB_LABEL_SIZE 32
+#define BDEV_DATA_START 16 /* sectors */
+
struct cache_sb {
uint64_t csum;
diff --git a/make-bcache.c b/make-bcache.c
index e20a7cf..5f4ebcc 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -154,7 +154,7 @@ const char * const cache_replacement_policies[] = {
int writeback;
int discard;
unsigned cache_replacement_policy;
-uint64_t data_offset = 16;
+uint64_t data_offset = BDEV_DATA_START;
struct option opts[] = {
{ "cache", 0, NULL, 'C' },
@@ -194,7 +194,7 @@ void write_sb(char *dev, struct cache_sb *sb)
if (SB_BDEV(sb)) {
SET_BDEV_WRITEBACK(sb, writeback);
- if (data_offset != 16) {
+ if (data_offset != BDEV_DATA_START) {
sb->version = BCACHE_SB_BDEV_VERSION;
sb->keys = 1;
sb->d[0] = data_offset;
@@ -288,8 +288,8 @@ int main(int argc, char **argv)
break;
case 'o':
data_offset = atoll(optarg);
- if (sb.d[0] < 16) {
- printf("Bad data offset; minimum 16 sectors\n");
+ if (sb.d[0] < BDEV_DATA_START) {
+ printf("Bad data offset; minimum %d sectors\n", BDEV_DATA_START);
exit(EXIT_FAILURE);
}
break;