aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-04 20:07:19 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:18 -0400
commit2430e72f42778a9448ff386686856b61b49f5074 (patch)
treee24bdbedd9ff95a5c6d165e5feceeae4094d3440 /fs
parent92d2ec10926d2ba8c38ba0ecada69cfd7a4dd3c4 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/bcachefs_format.h3
-rw-r--r--fs/bcachefs/journal.c5
-rw-r--r--fs/bcachefs/journal_io.c2
-rw-r--r--fs/bcachefs/journal_reclaim.c5
-rw-r--r--fs/bcachefs/journal_types.h2
-rw-r--r--fs/bcachefs/opts.h12
-rw-r--r--fs/bcachefs/super.c9
-rw-r--r--fs/bcachefs/sysfs.c20
8 files changed, 28 insertions, 30 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index 7c2846791286..bef924ab12a8 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -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:
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index 56c477bbce0f..24d2ca676cad 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -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);
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 0cd5ad3118e9..680ddba1889d 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -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);
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
index 3f417af16e59..4462beb52461 100644
--- a/fs/bcachefs/journal_reclaim.c
+++ b/fs/bcachefs/journal_reclaim.c
@@ -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))
diff --git a/fs/bcachefs/journal_types.h b/fs/bcachefs/journal_types.h
index 0fc6569ef149..9f59e4889f52 100644
--- a/fs/bcachefs/journal_types.h
+++ b/fs/bcachefs/journal_types.h
@@ -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;
diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h
index 896b8c9c1180..187cb37cba2a 100644
--- a/fs/bcachefs/opts.h
+++ b/fs/bcachefs/opts.h
@@ -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(), \
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index b24e64317a73..22dbbf77d687 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -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);
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index 864be8601868..fae2356061b0 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -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,