mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Don't overwrite priorities that aren't there on a backing device
This commit is contained in:
parent
eb9054a32e
commit
9e6daaffa7
2
bcache.h
2
bcache.h
@ -35,6 +35,8 @@ struct cache_sb {
|
|||||||
uint16_t nr_in_set;
|
uint16_t nr_in_set;
|
||||||
uint16_t nr_this_dev;
|
uint16_t nr_this_dev;
|
||||||
uint16_t _pad[1];
|
uint16_t _pad[1];
|
||||||
|
#define SB_LABEL_SIZE 32
|
||||||
|
uint8_t label[SB_LABEL_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bucket_disk {
|
struct bucket_disk {
|
||||||
|
@ -63,6 +63,8 @@ void usage()
|
|||||||
" -C Format a cache device\n"
|
" -C Format a cache device\n"
|
||||||
" -B Format a backing device\n"
|
" -B Format a backing device\n"
|
||||||
" -b bucket size\n"
|
" -b bucket size\n"
|
||||||
|
" -w block size (hard sector size of SSD, often 2k)\n"
|
||||||
|
" -j journal size, in buckets\n"
|
||||||
" -U UUID\n");
|
" -U UUID\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -113,7 +115,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (cache == backingdev) {
|
if (cache == backingdev) {
|
||||||
printf("Must specify one of -C or -B\n");
|
printf("Must specify one of -C or -B\n");
|
||||||
exit(EXIT_FAILURE);
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc <= optind) {
|
if (argc <= optind) {
|
||||||
@ -159,11 +161,13 @@ int main(int argc, char **argv)
|
|||||||
sb.nbuckets,
|
sb.nbuckets,
|
||||||
uuid, set_uuid);
|
uuid, set_uuid);
|
||||||
|
|
||||||
|
if (!backingdev) {
|
||||||
/* Zero out priorities */
|
/* Zero out priorities */
|
||||||
lseek(fd, 4096, SEEK_SET);
|
lseek(fd, 4096, SEEK_SET);
|
||||||
for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
|
for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
|
||||||
if (write(fd, zero, 512) != 512)
|
if (write(fd, zero, 512) != 512)
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
if (pwrite(fd, &sb, sizeof(sb), 4096) != sizeof(sb))
|
if (pwrite(fd, &sb, sizeof(sb), 4096) != sizeof(sb))
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
Reference in New Issue
Block a user