summaryrefslogtreecommitdiff
path: root/make-bcache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2010-05-14 08:54:26 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2010-05-14 08:54:26 -0800
commit11a1a3ca520aa3bfbb45b0d41b3336fef51844f0 (patch)
tree7e9ceee2efafb81bf3c1018e56d9e5204a681802 /make-bcache.c
parent5936daea2689afcb225b93c0f27fe7364d33f9a5 (diff)
Checksum test
Diffstat (limited to 'make-bcache.c')
-rw-r--r--make-bcache.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/make-bcache.c b/make-bcache.c
index 38a4d43..7bf10b0 100644
--- a/make-bcache.c
+++ b/make-bcache.c
@@ -45,7 +45,7 @@ long getblocks(int fd)
perror("stat error\n");
exit(EXIT_FAILURE);
}
- ret = statbuf.st_blocks;
+ ret = statbuf.st_size / 512;
if (S_ISBLK(statbuf.st_mode))
if (ioctl(fd, BLKGETSIZE, &ret)) {
perror("ioctl error");
@@ -77,7 +77,7 @@ long hatoi(const char *s)
int main(int argc, char **argv)
{
- int64_t nblocks, bucketsize = 1024, blocksize = 8;
+ int64_t nblocks, bucketsize = 32, blocksize = 8;
int fd, i, c;
struct cache_sb sb;
@@ -100,6 +100,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}
nblocks = getblocks(fd);
+ printf("device is %li sectors\n", nblocks);
if (bucketsize < blocksize ||
bucketsize > nblocks / 8) {
@@ -114,8 +115,7 @@ int main(int argc, char **argv)
sb.nbuckets = nblocks / sb.bucket_size;
do
- sb.first_bucket = ((--sb.nbuckets * sizeof(struct bucket_disk))
- + 4096 * 3) / (sb.bucket_size * 512) + 1;
+ sb.first_bucket = ((--sb.nbuckets * sizeof(struct bucket_disk)) + (24 << 9)) / (sb.bucket_size << 9) + 1;
while ((sb.nbuckets + sb.first_bucket) * sb.bucket_size > nblocks);
sb.journal_start = sb.first_bucket;