mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Fix offsets, cache and backing are two different cases.
This commit is contained in:
parent
865a3b1f0b
commit
3b6ae63e49
@ -97,12 +97,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
printf("sb.version\t\t%" PRIu64, sb.version);
|
printf("sb.version\t\t%" PRIu64, sb.version);
|
||||||
switch (sb.version) {
|
switch (sb.version) {
|
||||||
case 1:
|
case 0:
|
||||||
printf(" [backing device]\n");
|
printf(" [cache device]\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case CACHE_BACKING_DEV: // 1
|
||||||
printf(" [cache device]\n");
|
printf(" [backing device]\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -125,15 +125,23 @@ int main(int argc, char **argv)
|
|||||||
"dev.sectors_per_block\t%u\n"
|
"dev.sectors_per_block\t%u\n"
|
||||||
"dev.sectors_per_bucket\t%u\n"
|
"dev.sectors_per_bucket\t%u\n"
|
||||||
"dev.bucket_count\t%ju\n"
|
"dev.bucket_count\t%ju\n"
|
||||||
"dev.cache_count\t\t%u\n" // expect version == 2 ? 1 : 0
|
"dev.cache_count\t\t%u\n", // expect version == 0 ? 1 : 0
|
||||||
"dev.data.first_bucket\t%u\n",
|
|
||||||
sb.block_size,
|
sb.block_size,
|
||||||
sb.bucket_size,
|
sb.bucket_size,
|
||||||
sb.nbuckets,
|
sb.nbuckets,
|
||||||
sb.nr_this_dev,
|
sb.nr_this_dev);
|
||||||
sb.first_bucket);
|
|
||||||
|
|
||||||
printf("dev.data.first_sector\t%u\n", sb.bucket_size * sb.first_bucket);
|
if (sb.version == 0) {
|
||||||
|
printf(
|
||||||
|
"dev.cache.first_bucket\t%u\n"
|
||||||
|
"dev.cache.first_sector\t%u\n",
|
||||||
|
sb.first_bucket,
|
||||||
|
sb.bucket_size * sb.first_bucket);
|
||||||
|
} else if (sb.version == CACHE_BACKING_DEV) {
|
||||||
|
printf(
|
||||||
|
"dev.data.first_sector\t%u\n",
|
||||||
|
BDEV_DATA_START);
|
||||||
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
|
||||||
uuid_unparse(sb.set_uuid, uuid);
|
uuid_unparse(sb.set_uuid, uuid);
|
||||||
|
2
bcache.h
2
bcache.h
@ -25,6 +25,8 @@ static const char bcache_magic[] = {
|
|||||||
|
|
||||||
#define SB_SECTOR 8
|
#define SB_SECTOR 8
|
||||||
#define SB_LABEL_SIZE 32
|
#define SB_LABEL_SIZE 32
|
||||||
|
#define BDEV_DATA_START 16 /* sectors */
|
||||||
|
|
||||||
|
|
||||||
struct cache_sb {
|
struct cache_sb {
|
||||||
uint64_t csum;
|
uint64_t csum;
|
||||||
|
@ -154,7 +154,7 @@ const char * const cache_replacement_policies[] = {
|
|||||||
int writeback;
|
int writeback;
|
||||||
int discard;
|
int discard;
|
||||||
unsigned cache_replacement_policy;
|
unsigned cache_replacement_policy;
|
||||||
uint64_t data_offset = 16;
|
uint64_t data_offset = BDEV_DATA_START;
|
||||||
|
|
||||||
struct option opts[] = {
|
struct option opts[] = {
|
||||||
{ "cache", 0, NULL, 'C' },
|
{ "cache", 0, NULL, 'C' },
|
||||||
@ -194,7 +194,7 @@ void write_sb(char *dev, struct cache_sb *sb)
|
|||||||
if (SB_BDEV(sb)) {
|
if (SB_BDEV(sb)) {
|
||||||
SET_BDEV_WRITEBACK(sb, writeback);
|
SET_BDEV_WRITEBACK(sb, writeback);
|
||||||
|
|
||||||
if (data_offset != 16) {
|
if (data_offset != BDEV_DATA_START) {
|
||||||
sb->version = BCACHE_SB_BDEV_VERSION;
|
sb->version = BCACHE_SB_BDEV_VERSION;
|
||||||
sb->keys = 1;
|
sb->keys = 1;
|
||||||
sb->d[0] = data_offset;
|
sb->d[0] = data_offset;
|
||||||
@ -288,8 +288,8 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
data_offset = atoll(optarg);
|
data_offset = atoll(optarg);
|
||||||
if (sb.d[0] < 16) {
|
if (sb.d[0] < BDEV_DATA_START) {
|
||||||
printf("Bad data offset; minimum 16 sectors\n");
|
printf("Bad data offset; minimum %d sectors\n", BDEV_DATA_START);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user