mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-03-10 00:00:04 +03:00
bcacheadm: add --writearound flag for testing, probably not useful
Change-Id: Ia4a2125a50d7b102791b8fc64b48bd102d8cdc89
This commit is contained in:
parent
15c8235aa4
commit
34c87b0e98
6
bcache.c
6
bcache.c
@ -452,7 +452,7 @@ static void do_write_sb(int fd, struct cache_sb *sb)
|
||||
}
|
||||
|
||||
void write_backingdev_sb(int fd, unsigned block_size, unsigned *bucket_sizes,
|
||||
bool writeback, uint64_t data_offset,
|
||||
unsigned mode, uint64_t data_offset,
|
||||
const char *label,
|
||||
uuid_le set_uuid)
|
||||
{
|
||||
@ -474,9 +474,7 @@ void write_backingdev_sb(int fd, unsigned block_size, unsigned *bucket_sizes,
|
||||
if (label)
|
||||
memcpy(sb.label, label, SB_LABEL_SIZE);
|
||||
|
||||
SET_BDEV_CACHE_MODE(&sb, writeback
|
||||
? CACHE_MODE_WRITEBACK
|
||||
: CACHE_MODE_WRITETHROUGH);
|
||||
SET_BDEV_CACHE_MODE(&sb, mode);
|
||||
|
||||
if (data_offset != BDEV_DATA_START_DEFAULT) {
|
||||
sb.version = BCACHE_SB_VERSION_BDEV_WITH_OFFSET;
|
||||
|
2
bcache.h
2
bcache.h
@ -46,7 +46,7 @@ uint64_t bch_checksum(unsigned, const void *, size_t);
|
||||
uint64_t getblocks(int);
|
||||
uint64_t hatoi(const char *);
|
||||
unsigned hatoi_validate(const char *, const char *);
|
||||
void write_backingdev_sb(int, unsigned, unsigned *, bool, uint64_t,
|
||||
void write_backingdev_sb(int, unsigned, unsigned *, unsigned, uint64_t,
|
||||
const char *, uuid_le);
|
||||
int dev_open(const char *, bool);
|
||||
void write_cache_sbs(int *, struct cache_sb *, unsigned, unsigned *, int);
|
||||
|
14
bcacheadm.c
14
bcacheadm.c
@ -48,7 +48,7 @@ size_t i, nr_backing_devices = 0, nr_cache_devices = 0;
|
||||
unsigned block_size = 0;
|
||||
unsigned bucket_sizes[MAX_DEVS];
|
||||
int num_bucket_sizes = 0;
|
||||
int writeback = 0, discard = 0, wipe_bcache = 0;
|
||||
int writeback = 0, writearound = 0, discard = 0, wipe_bcache = 0;
|
||||
unsigned replication_set = 0;
|
||||
char *replacement_policy = 0;
|
||||
uint64_t data_offset = BDEV_DATA_START_DEFAULT;
|
||||
@ -204,6 +204,7 @@ static NihOption make_bcache_options[] = {
|
||||
{0, "wipe-bcache", N_("destroy existing bcache data if present"), NULL, NULL, &wipe_bcache, NULL},
|
||||
{0, "discard", N_("enable discards"), NULL, NULL, &discard, NULL},
|
||||
{0, "writeback", N_("enable writeback"), NULL, NULL, &writeback, NULL},
|
||||
{0, "writearound", N_("enable writearound"), NULL, NULL, &writearound, NULL},
|
||||
|
||||
NIH_OPTION_LAST
|
||||
};
|
||||
@ -291,6 +292,8 @@ int make_bcache(NihCommand *command, char *const *args)
|
||||
|
||||
int backing_dev_fd[devs];
|
||||
|
||||
unsigned cache_mode;
|
||||
|
||||
cache_set_sb = calloc(1, sizeof(*cache_set_sb) +
|
||||
sizeof(struct cache_member) * devs);
|
||||
|
||||
@ -380,10 +383,17 @@ int make_bcache(NihCommand *command, char *const *args)
|
||||
write_cache_sbs(cache_dev_fd, cache_set_sb, block_size,
|
||||
bucket_sizes, num_bucket_sizes);
|
||||
|
||||
if (writeback)
|
||||
cache_mode = CACHE_MODE_WRITEBACK;
|
||||
else if (writearound)
|
||||
cache_mode = CACHE_MODE_WRITEAROUND;
|
||||
else
|
||||
cache_mode = CACHE_MODE_WRITETHROUGH;
|
||||
|
||||
for (i = 0; i < nr_backing_devices; i++)
|
||||
write_backingdev_sb(backing_dev_fd[i],
|
||||
block_size, bucket_sizes,
|
||||
writeback, data_offset,
|
||||
cache_mode, data_offset,
|
||||
backing_dev_labels[i],
|
||||
cache_set_sb->set_uuid);
|
||||
|
||||
|
@ -247,7 +247,10 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i < nr_backing_devices; i++)
|
||||
write_backingdev_sb(backing_dev_fd[i],
|
||||
block_size, bucket_sizes,
|
||||
writeback, data_offset,
|
||||
writeback
|
||||
? CACHE_MODE_WRITEBACK
|
||||
: CACHE_MODE_WRITETHROUGH,
|
||||
data_offset,
|
||||
backing_dev_labels[i],
|
||||
cache_set_sb->set_uuid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user