]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: journal path now uses discard_opt_enabled()
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 16 May 2025 21:18:27 +0000 (17:18 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:15:01 +0000 (20:15 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/bcachefs.h
fs/bcachefs/journal_reclaim.c

index daf23d471d4f1ceebe1f6fb32f5a89d567080e9e..5934104af7e6b73a745c1521f1cf257e21e0e0a1 100644 (file)
@@ -1798,19 +1798,6 @@ struct discard_buckets_state {
        u64             discarded;
 };
 
-/*
- * This is needed because discard is both a filesystem option and a device
- * option, and mount options are supposed to apply to that mount and not be
- * persisted, i.e. if it's set as a mount option we can't propagate it to the
- * device.
- */
-static inline bool discard_opt_enabled(struct bch_fs *c, struct bch_dev *ca)
-{
-       return test_bit(BCH_FS_discard_mount_opt_set, &c->flags)
-               ? c->opts.discard
-               : ca->mi.discard;
-}
-
 static int bch2_discard_one_bucket(struct btree_trans *trans,
                                   struct bch_dev *ca,
                                   struct btree_iter *need_discard_iter,
@@ -1874,7 +1861,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
                s->discarded++;
                *discard_pos_done = iter.pos;
 
-               if (discard_opt_enabled(c, ca) && !c->opts.nochanges) {
+               if (bch2_discard_opt_enabled(c, ca) && !c->opts.nochanges) {
                        /*
                         * This works without any other locks because this is the only
                         * thread that removes items from the need_discard tree
index 27c025c05f8e19ef58eb6f2784c87369d24175d1..252fc1eaa0dc7090d2d73b2401be0304850850d3 100644 (file)
@@ -452,6 +452,7 @@ BCH_DEBUG_PARAMS_ALL()
        x(btree_node_compact)                   \
        x(btree_node_merge)                     \
        x(btree_node_sort)                      \
+       x(btree_node_get)                       \
        x(btree_node_read)                      \
        x(btree_node_read_done)                 \
        x(btree_node_write)                     \
@@ -459,6 +460,10 @@ BCH_DEBUG_PARAMS_ALL()
        x(btree_interior_update_total)          \
        x(btree_gc)                             \
        x(data_write)                           \
+       x(data_write_to_submit)                 \
+       x(data_write_to_queue)                  \
+       x(data_write_to_btree_update)           \
+       x(data_write_btree_update)              \
        x(data_read)                            \
        x(data_promote)                         \
        x(journal_flush_write)                  \
@@ -1272,4 +1277,17 @@ static inline unsigned data_replicas_required(struct bch_fs *c)
 #define BKEY_PADDED_ONSTACK(key, pad)                          \
        struct { struct bkey_i key; __u64 key ## _pad[pad]; }
 
+/*
+ * This is needed because discard is both a filesystem option and a device
+ * option, and mount options are supposed to apply to that mount and not be
+ * persisted, i.e. if it's set as a mount option we can't propagate it to the
+ * device.
+ */
+static inline bool bch2_discard_opt_enabled(struct bch_fs *c, struct bch_dev *ca)
+{
+       return test_bit(BCH_FS_discard_mount_opt_set, &c->flags)
+               ? c->opts.discard
+               : ca->mi.discard;
+}
+
 #endif /* _BCACHEFS_H */
index ce9e0bd7ec4fa9f0311954daffc2b119bbc40f33..70f36f6bc4820a775087a843d2fa6eea281d4999 100644 (file)
@@ -300,7 +300,7 @@ void bch2_journal_do_discards(struct journal *j)
 
                while (should_discard_bucket(j, ja)) {
                        if (!c->opts.nochanges &&
-                           ca->mi.discard &&
+                           bch2_discard_opt_enabled(c, ca) &&
                            bdev_max_discard_sectors(ca->disk_sb.bdev))
                                blkdev_issue_discard(ca->disk_sb.bdev,
                                        bucket_to_sector(ca,
@@ -701,6 +701,7 @@ static int __bch2_journal_reclaim(struct journal *j, bool direct, bool kicked)
                if (ret)
                        break;
 
+               /* XXX shove journal discards off to another thread */
                bch2_journal_do_discards(j);
 
                seq_to_flush = journal_seq_to_flush(j);