Commit 2430e72f authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 92d2ec10
...@@ -1440,6 +1440,9 @@ LE64_BITMASK(BCH_SB_ERASURE_CODE, struct bch_sb, flags[3], 0, 16); ...@@ -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_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_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_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: * Features:
......
...@@ -310,7 +310,7 @@ static int journal_entry_open(struct journal *j) ...@@ -310,7 +310,7 @@ static int journal_entry_open(struct journal *j)
mod_delayed_work(c->io_complete_wq, mod_delayed_work(c->io_complete_wq,
&j->write_work, &j->write_work,
msecs_to_jiffies(j->write_delay_ms)); msecs_to_jiffies(c->opts.journal_flush_delay));
journal_wake(j); journal_wake(j);
return 0; return 0;
} }
...@@ -1103,9 +1103,6 @@ int bch2_fs_journal_init(struct journal *j) ...@@ -1103,9 +1103,6 @@ int bch2_fs_journal_init(struct journal *j)
lockdep_init_map(&j->res_map, "journal res", &res_key, 0); 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, atomic64_set(&j->reservations.counter,
((union journal_res_state) ((union journal_res_state)
{ .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v); { .cur_entry_offset = JOURNAL_ENTRY_CLOSED_VAL }).v);
......
...@@ -1395,7 +1395,7 @@ void bch2_journal_write(struct closure *cl) ...@@ -1395,7 +1395,7 @@ void bch2_journal_write(struct closure *cl)
spin_lock(&j->lock); spin_lock(&j->lock);
if (c->sb.features & (1ULL << BCH_FEATURE_journal_no_flush) && if (c->sb.features & (1ULL << BCH_FEATURE_journal_no_flush) &&
!w->must_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)) { test_bit(JOURNAL_MAY_SKIP_FLUSH, &j->flags)) {
w->noflush = true; w->noflush = true;
SET_JSET_NO_FLUSH(jset, true); SET_JSET_NO_FLUSH(jset, true);
......
...@@ -637,7 +637,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct) ...@@ -637,7 +637,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct)
* make sure to flush at least one journal pin: * make sure to flush at least one journal pin:
*/ */
if (time_after(jiffies, j->last_flushed + 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; min_nr = 1;
if (j->prereserved.reserved * 4 > j->prereserved.remaining) if (j->prereserved.reserved * 4 > j->prereserved.remaining)
...@@ -683,6 +683,7 @@ int bch2_journal_reclaim(struct journal *j) ...@@ -683,6 +683,7 @@ int bch2_journal_reclaim(struct journal *j)
static int bch2_journal_reclaim_thread(void *arg) static int bch2_journal_reclaim_thread(void *arg)
{ {
struct journal *j = arg; struct journal *j = arg;
struct bch_fs *c = container_of(j, struct bch_fs, journal);
unsigned long delay, now; unsigned long delay, now;
int ret = 0; int ret = 0;
...@@ -700,7 +701,7 @@ static int bch2_journal_reclaim_thread(void *arg) ...@@ -700,7 +701,7 @@ static int bch2_journal_reclaim_thread(void *arg)
mutex_unlock(&j->reclaim_lock); mutex_unlock(&j->reclaim_lock);
now = jiffies; 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; j->next_reclaim = j->last_flushed + delay;
if (!time_in_range(j->next_reclaim, now, now + delay)) if (!time_in_range(j->next_reclaim, now, now + delay))
......
...@@ -262,8 +262,6 @@ struct journal { ...@@ -262,8 +262,6 @@ struct journal {
struct mutex discard_lock; struct mutex discard_lock;
bool can_discard; bool can_discard;
unsigned write_delay_ms;
unsigned reclaim_delay_ms;
unsigned long last_flush_write; unsigned long last_flush_write;
u64 res_get_blocked_start; u64 res_get_blocked_start;
......
...@@ -257,13 +257,23 @@ enum opt_type { ...@@ -257,13 +257,23 @@ enum opt_type {
OPT_BOOL(), \ OPT_BOOL(), \
NO_SB_OPT, false, \ NO_SB_OPT, false, \
NULL, "Extra debugging information during mount/recovery")\ 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, \ x(journal_flush_disabled, u8, \
OPT_MOUNT|OPT_RUNTIME, \ OPT_MOUNT|OPT_RUNTIME, \
OPT_BOOL(), \ OPT_BOOL(), \
NO_SB_OPT, false, \ BCH_SB_JOURNAL_FLUSH_DISABLED,false, \
NULL, "Disable journal flush on sync/fsync\n" \ NULL, "Disable journal flush on sync/fsync\n" \
"If enabled, writes can be lost, but only since the\n"\ "If enabled, writes can be lost, but only since the\n"\
"last journal write (default 1 second)") \ "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, \ x(fsck, u8, \
OPT_MOUNT, \ OPT_MOUNT, \
OPT_BOOL(), \ OPT_BOOL(), \
......
...@@ -752,6 +752,15 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts) ...@@ -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); 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; c->opts = bch2_opts_default;
bch2_opts_apply(&c->opts, bch2_opts_from_sb(sb)); bch2_opts_apply(&c->opts, bch2_opts_from_sb(sb));
bch2_opts_apply(&c->opts, opts); bch2_opts_apply(&c->opts, opts);
......
...@@ -140,8 +140,6 @@ rw_attribute(gc_gens_pos); ...@@ -140,8 +140,6 @@ rw_attribute(gc_gens_pos);
read_attribute(uuid); read_attribute(uuid);
read_attribute(minor); read_attribute(minor);
read_attribute(bucket_size); read_attribute(bucket_size);
read_attribute(block_size);
read_attribute(btree_node_size);
read_attribute(first_bucket); read_attribute(first_bucket);
read_attribute(nbuckets); read_attribute(nbuckets);
read_attribute(durability); read_attribute(durability);
...@@ -178,9 +176,6 @@ read_attribute(read_realloc_races); ...@@ -178,9 +176,6 @@ read_attribute(read_realloc_races);
read_attribute(extent_migrate_done); read_attribute(extent_migrate_done);
read_attribute(extent_migrate_raced); read_attribute(extent_migrate_raced);
rw_attribute(journal_write_delay_ms);
rw_attribute(journal_reclaim_delay_ms);
rw_attribute(discard); rw_attribute(discard);
rw_attribute(cache_replacement_policy); rw_attribute(cache_replacement_policy);
rw_attribute(label); rw_attribute(label);
...@@ -357,11 +352,6 @@ SHOW(bch2_fs) ...@@ -357,11 +352,6 @@ SHOW(bch2_fs)
sysfs_print(minor, c->minor); sysfs_print(minor, c->minor);
sysfs_printf(internal_uuid, "%pU", c->sb.uuid.b); 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_cache_size, bch2_btree_cache_size(c));
sysfs_hprint(btree_avg_write_size, bch2_btree_avg_write_size(c)); sysfs_hprint(btree_avg_write_size, bch2_btree_avg_write_size(c));
...@@ -475,9 +465,6 @@ STORE(bch2_fs) ...@@ -475,9 +465,6 @@ STORE(bch2_fs)
{ {
struct bch_fs *c = container_of(kobj, struct bch_fs, kobj); 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) { if (attr == &sysfs_btree_gc_periodic) {
ssize_t ret = strtoul_safe(buf, c->btree_gc_periodic) ssize_t ret = strtoul_safe(buf, c->btree_gc_periodic)
?: (ssize_t) size; ?: (ssize_t) size;
...@@ -564,14 +551,9 @@ SYSFS_OPS(bch2_fs); ...@@ -564,14 +551,9 @@ SYSFS_OPS(bch2_fs);
struct attribute *bch2_fs_files[] = { struct attribute *bch2_fs_files[] = {
&sysfs_minor, &sysfs_minor,
&sysfs_block_size,
&sysfs_btree_node_size,
&sysfs_btree_cache_size, &sysfs_btree_cache_size,
&sysfs_btree_avg_write_size, &sysfs_btree_avg_write_size,
&sysfs_journal_write_delay_ms,
&sysfs_journal_reclaim_delay_ms,
&sysfs_promote_whole_extents, &sysfs_promote_whole_extents,
&sysfs_compression_stats, &sysfs_compression_stats,
...@@ -846,7 +828,6 @@ SHOW(bch2_dev) ...@@ -846,7 +828,6 @@ SHOW(bch2_dev)
sysfs_printf(uuid, "%pU\n", ca->uuid.b); sysfs_printf(uuid, "%pU\n", ca->uuid.b);
sysfs_print(bucket_size, bucket_bytes(ca)); sysfs_print(bucket_size, bucket_bytes(ca));
sysfs_print(block_size, block_bytes(c));
sysfs_print(first_bucket, ca->mi.first_bucket); sysfs_print(first_bucket, ca->mi.first_bucket);
sysfs_print(nbuckets, ca->mi.nbuckets); sysfs_print(nbuckets, ca->mi.nbuckets);
sysfs_print(durability, ca->mi.durability); sysfs_print(durability, ca->mi.durability);
...@@ -978,7 +959,6 @@ SYSFS_OPS(bch2_dev); ...@@ -978,7 +959,6 @@ SYSFS_OPS(bch2_dev);
struct attribute *bch2_dev_files[] = { struct attribute *bch2_dev_files[] = {
&sysfs_uuid, &sysfs_uuid,
&sysfs_bucket_size, &sysfs_bucket_size,
&sysfs_block_size,
&sysfs_first_bucket, &sysfs_first_bucket,
&sysfs_nbuckets, &sysfs_nbuckets,
&sysfs_durability, &sysfs_durability,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment