diff options
author | Jacob Malevich <jam@daterainc.com> | 2014-09-22 19:00:50 -0700 |
---|---|---|
committer | Jacob Malevich <jam@daterainc.com> | 2014-10-27 12:14:44 -0700 |
commit | 0fca0e5502bf31385adeaaa8c72d60e665ee0547 (patch) | |
tree | 3ddec5ad830630291ade100610fc7c3ef68fad80 | |
parent | ee44c4f509667aa1bce20b44dcd459b1bc3eea99 (diff) |
Add multiple bucket_sizes to make-bcache
This is needed since libbcache expects an array of bucket sizes to be passed in. This is just so the tests can continue to use make-bcache until we can change them over to bcacheadm.
Change-Id: I1002e3d8355d45ffa914e6577569a5adfd1d6ccf
Signed-off-by: Jacob Malevich <jam@daterainc.com>
-rw-r--r-- | make-bcache.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/make-bcache.c b/make-bcache.c index b47cd9f..35bfc8c 100644 --- a/make-bcache.c +++ b/make-bcache.c @@ -59,7 +59,9 @@ int main(int argc, char **argv) int c, bdev = -1; size_t i, nr_backing_devices = 0; - unsigned block_size = 0, bucket_size = 1024; + unsigned block_size = 0; + unsigned bucket_sizes[argc]; + int num_bucket_sizes = 0; int writeback = 0, discard = 0, wipe_bcache = 0; unsigned replication_set = 0, tier = 0, replacement_policy = 0; uint64_t data_offset = BDEV_DATA_START_DEFAULT; @@ -112,6 +114,7 @@ int main(int argc, char **argv) SET_CACHE_PREFERRED_CSUM_TYPE(cache_set_sb, BCH_CSUM_CRC32C); SET_CACHE_SET_META_REPLICAS_WANT(cache_set_sb, 1); SET_CACHE_SET_DATA_REPLICAS_WANT(cache_set_sb, 1); + bucket_sizes[0] = 1024; while ((c = getopt_long(argc, argv, "-hCBU:w:b:l:", @@ -142,7 +145,8 @@ int main(int argc, char **argv) break; case 'b': - bucket_size = hatoi_validate(optarg, "bucket size"); + bucket_sizes[num_bucket_sizes] = hatoi_validate(optarg, "bucket size"); + num_bucket_sizes++; break; case 'w': block_size = hatoi_validate(optarg, "block size"); @@ -212,10 +216,14 @@ int main(int argc, char **argv) usage(); } - if (bucket_size < block_size) { - fprintf(stderr, "Bucket size cannot be smaller than block size\n"); - exit(EXIT_FAILURE); - } + i = 0; + do { + if (bucket_sizes[i] < block_size) { + fprintf(stderr, "Bucket size cannot be smaller than block size\n"); + exit(EXIT_FAILURE); + } + i++; + } while (i < num_bucket_sizes); if (!block_size) { for (i = 0; i < cache_set_sb->nr_in_set; i++) @@ -233,11 +241,12 @@ int main(int argc, char **argv) for (i = 0; i < nr_backing_devices; i++) backing_dev_fd[i] = dev_open(backing_devices[i], wipe_bcache); - write_cache_sbs(cache_dev_fd, cache_set_sb, block_size, bucket_size); + write_cache_sbs(cache_dev_fd, cache_set_sb, block_size, + bucket_sizes, num_bucket_sizes); for (i = 0; i < nr_backing_devices; i++) write_backingdev_sb(backing_dev_fd[i], - block_size, bucket_size, + block_size, bucket_sizes, writeback, data_offset, backing_dev_labels[i], cache_set_sb->set_uuid); |