mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +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_this_dev;
|
||||
uint16_t _pad[1];
|
||||
#define SB_LABEL_SIZE 32
|
||||
uint8_t label[SB_LABEL_SIZE];
|
||||
};
|
||||
|
||||
struct bucket_disk {
|
||||
|
@ -63,6 +63,8 @@ void usage()
|
||||
" -C Format a cache device\n"
|
||||
" -B Format a backing device\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");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -113,7 +115,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (cache == backingdev) {
|
||||
printf("Must specify one of -C or -B\n");
|
||||
exit(EXIT_FAILURE);
|
||||
usage();
|
||||
}
|
||||
|
||||
if (argc <= optind) {
|
||||
@ -159,11 +161,13 @@ int main(int argc, char **argv)
|
||||
sb.nbuckets,
|
||||
uuid, set_uuid);
|
||||
|
||||
/* Zero out priorities */
|
||||
lseek(fd, 4096, SEEK_SET);
|
||||
for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
|
||||
if (write(fd, zero, 512) != 512)
|
||||
goto err;
|
||||
if (!backingdev) {
|
||||
/* Zero out priorities */
|
||||
lseek(fd, 4096, SEEK_SET);
|
||||
for (i = 8; i < sb.first_bucket * sb.bucket_size; i++)
|
||||
if (write(fd, zero, 512) != 512)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (pwrite(fd, &sb, sizeof(sb), 4096) != sizeof(sb))
|
||||
goto err;
|
||||
|
Loading…
Reference in New Issue
Block a user