]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Convert journal sysfs params to regular options
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 5 Dec 2021 01:07:19 +0000 (20:07 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:18 +0000 (17:09 -0400)
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>
fs/bcachefs/bcachefs_format.h
fs/bcachefs/journal.c
fs/bcachefs/journal_io.c
fs/bcachefs/journal_reclaim.c
fs/bcachefs/journal_types.h
fs/bcachefs/opts.h
fs/bcachefs/super.c
fs/bcachefs/sysfs.c

index 7c28467912863bf84af21df732c3a287d3b2690b..bef924ab12a8f6567a1200b7110bf0e4ffd1c3d6 100644 (file)
@@ -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:
index 56c477bbce0fbced56eaad633fa1d21d569443bd..24d2ca676cad20904f0a1679f071399039c73d68 100644 (file)
@@ -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);
index 0cd5ad3118e908c4af6d221c115085cb50d98af0..680ddba1889d635d1b4ec304c9f35b1e42c923ef 100644 (file)
@@ -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);
index 3f417af16e5900f85a6ff788ae3364a489f4d378..4462beb524619893ff77bb5dffa745c03e6bbd8e 100644 (file)
@@ -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))
index 0fc6569ef14924382bc8fbe1ba4dde3f0c9a120f..9f59e4889f5212dec9fc3ccddf70f81da5f19490 100644 (file)
@@ -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;
index 896b8c9c118046d74d8375067a6fe1428d74a01a..187cb37cba2a527dbb7a4b4e549abcaec424ba13 100644 (file)
@@ -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(),                                                   \
index b24e64317a7368115a84f1cb4480e00b8fa426ee..22dbbf77d6877fcfa18443a49ce2fb59d12826b8 100644 (file)
@@ -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);
index 864be8601868d0f2a85584b6db86f4b2c5526305..fae2356061b04961fc92f5fabdb1b0acde1fd9be 100644 (file)
@@ -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,