summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2011-02-13 07:01:10 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2011-02-13 07:01:10 -0800
commit0b4b6fe2d3d668ace37f44e5a2297bb0ab51dafe (patch)
treed0d25c9d4e3cd1cf6d178f73a9c4d9a8d45131ce
parent04a54144fd304cfd8b4d54c72bdfa076b18d57b2 (diff)
Stuff
-rw-r--r--Makefile8
-rw-r--r--README24
-rw-r--r--make-bcache.826
-rw-r--r--make-bcache.c23
4 files changed, 66 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index a85a807..3ce2553 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,8 @@ install: make-bcache probe-bcache
# install -m0755 bcache-test ${PREFIX}/sbin/
clean:
- rm -f make-bcache bcache-test *.o
+ rm -f make-bcache probe-bcache bcache-test *.o
-bcache-test: LDFLAGS += -lm -lssl -lcrypto
-make-bcache: LDFLAGS += -luuid
-probe-bcache: LDFLAGS += -luuid
+bcache-test: LDLIBS += -lm -lssl -lcrypto
+make-bcache: LDLIBS += -luuid
+probe-bcache: LDLIBS += -luuid
diff --git a/README b/README
new file mode 100644
index 0000000..3aa525f
--- /dev/null
+++ b/README
@@ -0,0 +1,24 @@
+These are the userspace tools required for bcache.
+
+Bcache is a patch for the Linux kernel to use SSDs to cache other block
+devices. For more information, see http://bcache.evilpiepirate.org.
+Documentation for the run time interface is included in the kernel tree, in
+Documentantion/bcache.txt.
+
+Included tools:
+
+make-bcache
+Formats a block device for use with bcache. A device can be formatted for use
+as a cache or as a backing device (requires yet to be implemented kernel
+support). The most important option is for specifying the bucket size.
+Allocation is done in terms of buckets, and cache hits are counted per bucket;
+thus a smaller bucket size will give better cache utilization, but poorer write
+performance. The bucket size is intended to be equal to the size of your SSD's
+erase blocks, which seems to be 128k-512k for most SSDs; feel free to
+experiment.
+
+probe-bcache
+Only necessary until support for the bcache superblock is included
+in blkid; in the meantime, provides just enough functionality for a udev script
+to create the /dev/disk/by-uuid symlink. The arguments it does support are the
+same as for blkid.
diff --git a/make-bcache.8 b/make-bcache.8
new file mode 100644
index 0000000..337a414
--- /dev/null
+++ b/make-bcache.8
@@ -0,0 +1,26 @@
+.TH make-bcache 8
+.SH NAME
+make-bcache \- create a cache device
+.SH SYNOPSIS
+.B make-bcache
+[\fB \-U\ \fIUUID\fR ]
+[\fB \-b\ \fIbucket-size\fR ]
+.I device
+.SH OPTIONS
+.TP
+.BR \-C
+Create a cache
+.TP
+.BR \-B
+Create a backing device (kernel functionality not yet implemented)
+.TP
+.BR \-U\ \fIUUID
+Create a cache device with the specified UUID
+.TP
+.BR \-b\ \fIbucket-size
+Spcifies the bucket size. Allocation is done in terms of buckets, and cache
+hits are counted per bucket; thus a smaller bucket size will give better cache
+utilization, but poorer write performance. The bucket size is intended to be
+equal to the size of your SSD's erase blocks, which seems to be 128k-512k for
+most SSDs. Must be a power of two; accepts human readable units. Defaults to
+128k.
diff --git a/make-bcache.c b/make-bcache.c
index 9b9b0a1..adc90ac 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -70,14 +70,14 @@ void usage()
int main(int argc, char **argv)
{
bool cache = false, backingdev = false;
- int64_t nblocks, bucketsize = 0, blocksize = 8;
+ int64_t nblocks;
int fd, i, c;
- struct cache_sb sb;
char uuid[40];
+ struct cache_sb sb = { .block_size = 8, .bucket_size = 0 };
uuid_generate(sb.uuid);
- while ((c = getopt(argc, argv, "CBU:b:")) != -1)
+ while ((c = getopt(argc, argv, "CBU:w:b:")) != -1)
switch (c) {
case 'C':
cache = true;
@@ -86,7 +86,10 @@ int main(int argc, char **argv)
backingdev = true;
break;
case 'b':
- bucketsize = hatoi(optarg) / 512;
+ sb.bucket_size = hatoi(optarg) / 512;
+ break;
+ case 'w':
+ sb.block_size = hatoi(optarg) / 512;
break;
case 'U':
if (uuid_parse(optarg, sb.uuid)) {
@@ -96,8 +99,8 @@ int main(int argc, char **argv)
break;
}
- if (!bucketsize)
- bucketsize = cache ? 256 : 8192;
+ if (!sb.bucket_size)
+ sb.bucket_size = cache ? 256 : 8192;
if (cache == backingdev) {
printf("Must specify one of -C or -B\n");
@@ -117,16 +120,14 @@ int main(int argc, char **argv)
nblocks = getblocks(fd);
printf("device is %li sectors\n", nblocks);
- if (bucketsize < blocksize ||
- bucketsize > nblocks / 8) {
- printf("Bad bucket size %li\n", bucketsize);
+ if (sb.bucket_size < sb.block_size ||
+ sb.bucket_size > nblocks / 8) {
+ printf("Bad bucket size %i\n", sb.bucket_size);
exit(EXIT_FAILURE);
}
memcpy(sb.magic, bcache_magic, 16);
sb.version = backingdev ? CACHE_BACKING_DEVICE : 0;
- sb.block_size = blocksize;
- sb.bucket_size = bucketsize;
sb.nbuckets = nblocks / sb.bucket_size;
uuid_unparse(sb.uuid, uuid);