summaryrefslogtreecommitdiff
path: root/bcache-super-show.c
diff options
context:
space:
mode:
authorGabriel <g2p.code@gmail.com>2013-05-01 19:15:18 +0200
committerGabriel <g2p.code@gmail.com>2013-05-08 09:40:46 +0200
commit315ab92e58e3984351df8650527986b2b950e189 (patch)
tree0d196745be071547392d4867377a3a22cfcd75a2 /bcache-super-show.c
parentaf6e3f1c7421e8517e0b9e1a99a88c9e2b34236d (diff)
super-show: print cache mode (writethrough, writeback, writearound, none)
Diffstat (limited to 'bcache-super-show.c')
-rw-r--r--bcache-super-show.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/bcache-super-show.c b/bcache-super-show.c
index 95e54d4..1607a67 100644
--- a/bcache-super-show.c
+++ b/bcache-super-show.c
@@ -137,20 +137,39 @@ int main(int argc, char **argv)
sb.bucket_size * sb.nbuckets,
CACHE_DISCARD(&sb) ? "yes" : "no",
sb.nr_this_dev);
- } else if (sb.version == BCACHE_SB_VERSION_BDEV) {
- printf("dev.data.first_sector\t%u\n"
- "dev.data.writeback\t%s\n",
- BDEV_DATA_START_DEFAULT,
- BDEV_WRITEBACK(&sb) ? "yes" : "no");
- } else if (sb.version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET) {
- if (sb.keys == 1 || sb.d[0]) {
- fprintf(stderr, "Possible experimental format detected, bailing\n");
- exit(3);
+ } else {
+ uint64_t first_sector;
+ if (sb.version == BCACHE_SB_VERSION_BDEV) {
+ first_sector = BDEV_DATA_START_DEFAULT;
+ } else {
+ if (sb.keys == 1 || sb.d[0]) {
+ fprintf(stderr,
+ "Possible experimental format detected, bailing\n");
+ exit(3);
+ }
+ first_sector = sb.data_offset;
+ }
+ printf("dev.data.first_sector\t%ju\n"
+ "dev.data.cache_mode\t%ju",
+ first_sector,
+ BDEV_CACHE_MODE(&sb));
+
+ switch (BDEV_CACHE_MODE(&sb)) {
+ case CACHE_MODE_WRITETHROUGH:
+ printf(" [writethrough]\n");
+ break;
+ case CACHE_MODE_WRITEBACK:
+ printf(" [writeback]\n");
+ break;
+ case CACHE_MODE_WRITEAROUND:
+ printf(" [writearound]\n");
+ break;
+ case CACHE_MODE_NONE:
+ printf(" [no caching]\n");
+ break;
+ default:
+ putchar('\n');
}
- printf("dev.data.first_sector\t%lu\n"
- "dev.data.writeback\t%s\n",
- sb.data_offset,
- BDEV_WRITEBACK(&sb) ? "yes" : "no");
}
putchar('\n');