summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2011-05-24 14:12:00 -0700
committerKent Overstreet <koverstreet@google.com>2011-05-24 14:12:00 -0700
commit9e6daaffa76bd44bbd60290e0e3bf1a9fb0f82bb (patch)
treeac36553a987fd236f66e6ca4d34066b302161a6c
parenteb9054a32e22d04c8ff3c7521084c0632ed80e70 (diff)
Don't overwrite priorities that aren't there on a backing device
-rw-r--r--bcache.h2
-rw-r--r--make-bcache.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/bcache.h b/bcache.h
index deadbe3..6e62b6b 100644
--- a/bcache.h
+++ b/bcache.h
@@ -35,6 +35,8 @@ struct cache_sb {
uint16_t nr_in_set;
uint16_t nr_this_dev;
uint16_t _pad[1];
+#define SB_LABEL_SIZE 32
+ uint8_t label[SB_LABEL_SIZE];
};
struct bucket_disk {
diff --git a/make-bcache.c b/make-bcache.c
index 02fe405..b6034fe 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -63,6 +63,8 @@ void usage()
" -C Format a cache device\n"
" -B Format a backing device\n"
" -b bucket size\n"
+ " -w block size (hard sector size of SSD, often 2k)\n"
+ " -j journal size, in buckets\n"
" -U UUID\n");
exit(EXIT_FAILURE);
}
@@ -113,7 +115,7 @@ int main(int argc, char **argv)
if (cache == backingdev) {
printf("Must specify one of -C or -B\n");
- exit(EXIT_FAILURE);
+ usage();
}
if (argc <= optind) {
@@ -159,11 +161,13 @@ int main(int argc, char **argv)
sb.nbuckets,
uuid, set_uuid);
- /* Zero out priorities */
- lseek(fd, 4096, SEEK_SET);
- for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
- if (write(fd, zero, 512) != 512)
- goto err;
+ if (!backingdev) {
+ /* Zero out priorities */
+ lseek(fd, 4096, SEEK_SET);
+ for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
+ if (write(fd, zero, 512) != 512)
+ goto err;
+ }
if (pwrite(fd, &sb, sizeof(sb), 4096) != sizeof(sb))
goto err;