bcachefs: Convert journal sysfs params to regular options
This converts journal_write_delay, journal_flush_disabled, and journal_reclaim_delay to normal filesystems options, and also adds them to the superblock. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
92d2ec1092
commit
2430e72f42
@ -1440,6 +1440,9 @@ LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16);
|
||||
LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28);
|
||||
LE64_BITMASK(BCH_SB_SHARD_INUMS, struct bch_sb, flags[3], 28, 29);
|
||||
LE64_BITMASK(BCH_SB_INODES_USE_KEY_CACHE,struct bch_sb, flags[3], 29, 30);
|
||||
LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DELAY,struct bch_sb, flags[3], 30, 62);
|
||||
LE64_BITMASK(BCH_SB_JOURNAL_FLUSH_DISABLED,struct bch_sb, flags[3], 62, 63);
|
||||
LE64_BITMASK(BCH_SB_JOURNAL_RECLAIM_DELAY,struct bch_sb, flags[4], 0, 32);
|
||||
|
||||
/*
|
||||
* Features:
|
||||
|
@ -310,7 +310,7 @@ static int journal_entry_open(struct journal *j)
|
||||
|
||||
mod_delayed_work(c->io_complete_wq,
|
||||
&j->write_work,
|
||||
msecs_to_jiffies(j->write_delay_ms));
|
||||
msecs_to_jiffies(c->opts.journal_flush_delay));
|
||||
journal_wake(j);
|
||||
return 0;
|
||||
}
|
||||
@ -1103,9 +1103,6 @@ int bch2_fs_journal_init(struct journal *j)
|
||||
|
||||
lockdep_init_map(&j->res_map, "journal res", &res_key, 0);
|
||||
|
||||
j->write_delay_ms = 1000;
|
||||
j->reclaim_delay_ms = 100;
|
||||
|
||||
atomic64_set(&j->reservations.counter,
|
||||
((union journal_res_state)
|
||||
{ .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v);
|
||||
|
@ -1395,7 +1395,7 @@ void bch2_journal_write(struct closure *cl)
|
||||
spin_lock(&j->lock);
|
||||
if (c->sb.features & (1ULL << BCH_FEATURE_journal_no_flush) &&
|
||||
!w->must_flush &&
|
||||
(jiffies - j->last_flush_write) < msecs_to_jiffies(j->write_delay_ms) &&
|
||||
(jiffies - j->last_flush_write) < msecs_to_jiffies(c->opts.journal_flush_delay) &&
|
||||
test_bit(JOURNAL_MAY_SKIP_FLUSH, &j->flags)) {
|
||||
w->noflush = true;
|
||||
SET_JSET_NO_FLUSH(jset, true);
|
||||
|
@ -637,7 +637,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct)
|
||||
* make sure to flush at least one journal pin:
|
||||
*/
|
||||
if (time_after(jiffies, j->last_flushed +
|
||||
msecs_to_jiffies(j->reclaim_delay_ms)))
|
||||
msecs_to_jiffies(c->opts.journal_reclaim_delay)))
|
||||
min_nr = 1;
|
||||
|
||||
if (j->prereserved.reserved * 4 > j->prereserved.remaining)
|
||||
@ -683,6 +683,7 @@ int bch2_journal_reclaim(struct journal *j)
|
||||
static int bch2_journal_reclaim_thread(void *arg)
|
||||
{
|
||||
struct journal *j = arg;
|
||||
struct bch_fs *c = container_of(j, struct bch_fs, journal);
|
||||
unsigned long delay, now;
|
||||
int ret = 0;
|
||||
|
||||
@ -700,7 +701,7 @@ static int bch2_journal_reclaim_thread(void *arg)
|
||||
mutex_unlock(&j->reclaim_lock);
|
||||
|
||||
now = jiffies;
|
||||
delay = msecs_to_jiffies(j->reclaim_delay_ms);
|
||||
delay = msecs_to_jiffies(c->opts.journal_reclaim_delay);
|
||||
j->next_reclaim = j->last_flushed + delay;
|
||||
|
||||
if (!time_in_range(j->next_reclaim, now, now + delay))
|
||||
|
@ -262,8 +262,6 @@ struct journal {
|
||||
struct mutex discard_lock;
|
||||
bool can_discard;
|
||||
|
||||
unsigned write_delay_ms;
|
||||
unsigned reclaim_delay_ms;
|
||||
unsigned long last_flush_write;
|
||||
|
||||
u64 res_get_blocked_start;
|
||||
|
@ -257,13 +257,23 @@ enum opt_type {
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false, \
|
||||
NULL, "Extra debugging information during mount/recovery")\
|
||||
x(journal_flush_delay, u32, \
|
||||
OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_UINT(0, U32_MAX), \
|
||||
BCH_SB_JOURNAL_FLUSH_DELAY, 1000, \
|
||||
NULL, "Delay in milliseconds before automatic journal commits")\
|
||||
x(journal_flush_disabled, u8, \
|
||||
OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_BOOL(), \
|
||||
NO_SB_OPT, false, \
|
||||
BCH_SB_JOURNAL_FLUSH_DISABLED,false, \
|
||||
NULL, "Disable journal flush on sync/fsync\n" \
|
||||
"If enabled, writes can be lost, but only since the\n"\
|
||||
"last journal write (default 1 second)") \
|
||||
x(journal_reclaim_delay, u32, \
|
||||
OPT_MOUNT|OPT_RUNTIME, \
|
||||
OPT_UINT(0, U32_MAX), \
|
||||
BCH_SB_JOURNAL_RECLAIM_DELAY, 100, \
|
||||
NULL, "Delay in milliseconds before automatic journal reclaim")\
|
||||
x(fsck, u8, \
|
||||
OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
|
@ -752,6 +752,15 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||
|
||||
scnprintf(c->name, sizeof(c->name), "%pU", &c->sb.user_uuid);
|
||||
|
||||
/* Compat: */
|
||||
if (sb->version <= bcachefs_metadata_version_inode_v2 &&
|
||||
!BCH_SB_JOURNAL_FLUSH_DELAY(sb))
|
||||
SET_BCH_SB_JOURNAL_FLUSH_DELAY(sb, 1000);
|
||||
|
||||
if (sb->version <= bcachefs_metadata_version_inode_v2 &&
|
||||
!BCH_SB_JOURNAL_RECLAIM_DELAY(sb))
|
||||
SET_BCH_SB_JOURNAL_RECLAIM_DELAY(sb, 100);
|
||||
|
||||
c->opts = bch2_opts_default;
|
||||
bch2_opts_apply(&c->opts, bch2_opts_from_sb(sb));
|
||||
bch2_opts_apply(&c->opts, opts);
|
||||
|
@ -140,8 +140,6 @@ rw_attribute(gc_gens_pos);
|
||||
read_attribute(uuid);
|
||||
read_attribute(minor);
|
||||
read_attribute(bucket_size);
|
||||
read_attribute(block_size);
|
||||
read_attribute(btree_node_size);
|
||||
read_attribute(first_bucket);
|
||||
read_attribute(nbuckets);
|
||||
read_attribute(durability);
|
||||
@ -178,9 +176,6 @@ read_attribute(read_realloc_races);
|
||||
read_attribute(extent_migrate_done);
|
||||
read_attribute(extent_migrate_raced);
|
||||
|
||||
rw_attribute(journal_write_delay_ms);
|
||||
rw_attribute(journal_reclaim_delay_ms);
|
||||
|
||||
rw_attribute(discard);
|
||||
rw_attribute(cache_replacement_policy);
|
||||
rw_attribute(label);
|
||||
@ -357,11 +352,6 @@ SHOW(bch2_fs)
|
||||
sysfs_print(minor, c->minor);
|
||||
sysfs_printf(internal_uuid, "%pU", c->sb.uuid.b);
|
||||
|
||||
sysfs_print(journal_write_delay_ms, c->journal.write_delay_ms);
|
||||
sysfs_print(journal_reclaim_delay_ms, c->journal.reclaim_delay_ms);
|
||||
|
||||
sysfs_print(block_size, block_bytes(c));
|
||||
sysfs_print(btree_node_size, btree_bytes(c));
|
||||
sysfs_hprint(btree_cache_size, bch2_btree_cache_size(c));
|
||||
sysfs_hprint(btree_avg_write_size, bch2_btree_avg_write_size(c));
|
||||
|
||||
@ -475,9 +465,6 @@ STORE(bch2_fs)
|
||||
{
|
||||
struct bch_fs *c = container_of(kobj, struct bch_fs, kobj);
|
||||
|
||||
sysfs_strtoul(journal_write_delay_ms, c->journal.write_delay_ms);
|
||||
sysfs_strtoul(journal_reclaim_delay_ms, c->journal.reclaim_delay_ms);
|
||||
|
||||
if (attr == &sysfs_btree_gc_periodic) {
|
||||
ssize_t ret = strtoul_safe(buf, c->btree_gc_periodic)
|
||||
?: (ssize_t) size;
|
||||
@ -564,14 +551,9 @@ SYSFS_OPS(bch2_fs);
|
||||
|
||||
struct attribute *bch2_fs_files[] = {
|
||||
&sysfs_minor,
|
||||
&sysfs_block_size,
|
||||
&sysfs_btree_node_size,
|
||||
&sysfs_btree_cache_size,
|
||||
&sysfs_btree_avg_write_size,
|
||||
|
||||
&sysfs_journal_write_delay_ms,
|
||||
&sysfs_journal_reclaim_delay_ms,
|
||||
|
||||
&sysfs_promote_whole_extents,
|
||||
|
||||
&sysfs_compression_stats,
|
||||
@ -846,7 +828,6 @@ SHOW(bch2_dev)
|
||||
sysfs_printf(uuid, "%pU\n", ca->uuid.b);
|
||||
|
||||
sysfs_print(bucket_size, bucket_bytes(ca));
|
||||
sysfs_print(block_size, block_bytes(c));
|
||||
sysfs_print(first_bucket, ca->mi.first_bucket);
|
||||
sysfs_print(nbuckets, ca->mi.nbuckets);
|
||||
sysfs_print(durability, ca->mi.durability);
|
||||
@ -978,7 +959,6 @@ SYSFS_OPS(bch2_dev);
|
||||
struct attribute *bch2_dev_files[] = {
|
||||
&sysfs_uuid,
|
||||
&sysfs_bucket_size,
|
||||
&sysfs_block_size,
|
||||
&sysfs_first_bucket,
|
||||
&sysfs_nbuckets,
|
||||
&sysfs_durability,
|
||||
|
Loading…
Reference in New Issue
Block a user