bcachefs: BTREE_UPDATE_NOJOURNAL
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 31 Dec 2022 05:15:23 +0000 (00:15 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:16 +0000 (17:09 -0400)
We're going to have btree updates that don't need to be journalled; add
a flag for that.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_types.h
fs/bcachefs/btree_update_leaf.c

index 14acbdf34f7b5d6edfd56018c160a3d833eed024..d8c35ba9ec8936a62718962e8a9edb666374f47f 100644 (file)
@@ -630,6 +630,7 @@ static inline bool btree_type_has_snapshots(enum btree_id id)
 
 enum btree_update_flags {
        __BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE,
+       __BTREE_UPDATE_NOJOURNAL,
 
        __BTREE_TRIGGER_NORUN,          /* Don't run triggers at all */
 
@@ -642,6 +643,7 @@ enum btree_update_flags {
 };
 
 #define BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE (1U << __BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE)
+#define BTREE_UPDATE_NOJOURNAL         (1U << __BTREE_UPDATE_NOJOURNAL)
 
 #define BTREE_TRIGGER_NORUN            (1U << __BTREE_TRIGGER_NORUN)
 
index fa6ba018378b175a8ff7022d3404f545f2c110ac..b9c93182f2de5dc95991724c7f4c8a9479813ca2 100644 (file)
@@ -356,7 +356,8 @@ static inline void do_btree_insert_one(struct btree_trans *trans,
        if (!did_work)
                return;
 
-       if (likely(!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY))) {
+       if (likely(!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY)) &&
+           !(i->flags & BTREE_UPDATE_NOJOURNAL)) {
                bch2_journal_add_keys(j, &trans->journal_res,
                                      i->btree_id,
                                      i->level,
@@ -897,7 +898,9 @@ int __bch2_trans_commit(struct btree_trans *trans)
                if (i->cached &&
                    likely(!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY)))
                        trans->journal_preres_u64s += u64s;
-               trans->journal_u64s += u64s;
+
+               if (!(i->flags & BTREE_UPDATE_NOJOURNAL))
+                       trans->journal_u64s += u64s;
        }
 
        if (trans->extra_journal_res) {