summaryrefslogtreecommitdiff
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
parentaf6e3f1c7421e8517e0b9e1a99a88c9e2b34236d (diff)
super-show: print cache mode (writethrough, writeback, writearound, none)
-rw-r--r--bcache-super-show.c45
-rw-r--r--bcache.h21
-rw-r--r--make-bcache.c3
3 files changed, 51 insertions, 18 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');
diff --git a/bcache.h b/bcache.h
index bd87121..ac1633c 100644
--- a/bcache.h
+++ b/bcache.h
@@ -91,10 +91,23 @@ static inline bool SB_IS_BDEV(const struct cache_sb *sb)
|| sb->version == BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
}
-BITMASK(BDEV_WRITEBACK, struct cache_sb, flags, 0, 1);
-
-BITMASK(CACHE_DISCARD, struct cache_sb, flags, 1, 1);
-BITMASK(CACHE_REPLACEMENT, struct cache_sb, flags, 2, 3);
+BITMASK(CACHE_SYNC, struct cache_sb, flags, 0, 1);
+BITMASK(CACHE_DISCARD, struct cache_sb, flags, 1, 1);
+BITMASK(CACHE_REPLACEMENT, struct cache_sb, flags, 2, 3);
+#define CACHE_REPLACEMENT_LRU 0U
+#define CACHE_REPLACEMENT_FIFO 1U
+#define CACHE_REPLACEMENT_RANDOM 2U
+
+BITMASK(BDEV_CACHE_MODE, struct cache_sb, flags, 0, 4);
+#define CACHE_MODE_WRITETHROUGH 0U
+#define CACHE_MODE_WRITEBACK 1U
+#define CACHE_MODE_WRITEAROUND 2U
+#define CACHE_MODE_NONE 3U
+BITMASK(BDEV_STATE, struct cache_sb, flags, 61, 2);
+#define BDEV_STATE_NONE 0U
+#define BDEV_STATE_CLEAN 1U
+#define BDEV_STATE_DIRTY 2U
+#define BDEV_STATE_STALE 3U
inline uint64_t crc64(const void *_data, size_t len);
diff --git a/make-bcache.c b/make-bcache.c
index 0a47c0c..2a5124b 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -192,7 +192,8 @@ static void write_sb(char *dev, unsigned block_size, unsigned bucket_size,
uuid_unparse(sb.set_uuid, set_uuid_str);
if (SB_IS_BDEV(&sb)) {
- SET_BDEV_WRITEBACK(&sb, writeback);
+ SET_BDEV_CACHE_MODE(
+ &sb, writeback ? CACHE_MODE_WRITEBACK : CACHE_MODE_WRITETHROUGH);
if (data_offset != BDEV_DATA_START_DEFAULT) {
sb.version = BCACHE_SB_VERSION_BDEV_WITH_OFFSET;