mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Stuff
This commit is contained in:
parent
04a54144fd
commit
0b4b6fe2d3
8
Makefile
8
Makefile
@ -13,8 +13,8 @@ install: make-bcache probe-bcache
|
|||||||
# install -m0755 bcache-test ${PREFIX}/sbin/
|
# install -m0755 bcache-test ${PREFIX}/sbin/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f make-bcache bcache-test *.o
|
rm -f make-bcache probe-bcache bcache-test *.o
|
||||||
|
|
||||||
bcache-test: LDFLAGS += -lm -lssl -lcrypto
|
bcache-test: LDLIBS += -lm -lssl -lcrypto
|
||||||
make-bcache: LDFLAGS += -luuid
|
make-bcache: LDLIBS += -luuid
|
||||||
probe-bcache: LDFLAGS += -luuid
|
probe-bcache: LDLIBS += -luuid
|
||||||
|
24
README
Normal file
24
README
Normal file
@ -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.
|
26
make-bcache.8
Normal file
26
make-bcache.8
Normal file
@ -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.
|
@ -70,14 +70,14 @@ void usage()
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
bool cache = false, backingdev = false;
|
bool cache = false, backingdev = false;
|
||||||
int64_t nblocks, bucketsize = 0, blocksize = 8;
|
int64_t nblocks;
|
||||||
int fd, i, c;
|
int fd, i, c;
|
||||||
struct cache_sb sb;
|
|
||||||
char uuid[40];
|
char uuid[40];
|
||||||
|
struct cache_sb sb = { .block_size = 8, .bucket_size = 0 };
|
||||||
|
|
||||||
uuid_generate(sb.uuid);
|
uuid_generate(sb.uuid);
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "CBU:b:")) != -1)
|
while ((c = getopt(argc, argv, "CBU:w:b:")) != -1)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'C':
|
case 'C':
|
||||||
cache = true;
|
cache = true;
|
||||||
@ -86,7 +86,10 @@ int main(int argc, char **argv)
|
|||||||
backingdev = true;
|
backingdev = true;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
bucketsize = hatoi(optarg) / 512;
|
sb.bucket_size = hatoi(optarg) / 512;
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
sb.block_size = hatoi(optarg) / 512;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
if (uuid_parse(optarg, sb.uuid)) {
|
if (uuid_parse(optarg, sb.uuid)) {
|
||||||
@ -96,8 +99,8 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bucketsize)
|
if (!sb.bucket_size)
|
||||||
bucketsize = cache ? 256 : 8192;
|
sb.bucket_size = cache ? 256 : 8192;
|
||||||
|
|
||||||
if (cache == backingdev) {
|
if (cache == backingdev) {
|
||||||
printf("Must specify one of -C or -B\n");
|
printf("Must specify one of -C or -B\n");
|
||||||
@ -117,16 +120,14 @@ int main(int argc, char **argv)
|
|||||||
nblocks = getblocks(fd);
|
nblocks = getblocks(fd);
|
||||||
printf("device is %li sectors\n", nblocks);
|
printf("device is %li sectors\n", nblocks);
|
||||||
|
|
||||||
if (bucketsize < blocksize ||
|
if (sb.bucket_size < sb.block_size ||
|
||||||
bucketsize > nblocks / 8) {
|
sb.bucket_size > nblocks / 8) {
|
||||||
printf("Bad bucket size %li\n", bucketsize);
|
printf("Bad bucket size %i\n", sb.bucket_size);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(sb.magic, bcache_magic, 16);
|
memcpy(sb.magic, bcache_magic, 16);
|
||||||
sb.version = backingdev ? CACHE_BACKING_DEVICE : 0;
|
sb.version = backingdev ? CACHE_BACKING_DEVICE : 0;
|
||||||
sb.block_size = blocksize;
|
|
||||||
sb.bucket_size = bucketsize;
|
|
||||||
sb.nbuckets = nblocks / sb.bucket_size;
|
sb.nbuckets = nblocks / sb.bucket_size;
|
||||||
uuid_unparse(sb.uuid, uuid);
|
uuid_unparse(sb.uuid, uuid);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user