summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/journal.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-05-25 14:57:06 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:40 -0400
commit00b8ccf7074fddb5607a26673f331ceac2ecd319 (patch)
tree2d8468865754bd7075b2370706423c4fcf70b450 /fs/bcachefs/journal.h
parentc823c3390bd2f325f78bab493f84ea8a84f5ddc2 (diff)
downloadlinux-00b8ccf7074fddb5607a26673f331ceac2ecd319.tar.gz
linux-00b8ccf7074fddb5607a26673f331ceac2ecd319.tar.bz2
linux-00b8ccf7074fddb5607a26673f331ceac2ecd319.zip
bcachefs: Interior btree updates are now fully transactional
We now update the alloc info (bucket sector counts) atomically with journalling the update to the interior btree nodes, and we also set new btree roots atomically with the journalled part of the btree update. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal.h')
-rw-r--r--fs/bcachefs/journal.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h
index 6630db6ecc14..2c55f74522e2 100644
--- a/fs/bcachefs/journal.h
+++ b/fs/bcachefs/journal.h
@@ -200,33 +200,40 @@ bch2_journal_add_entry_noreservation(struct journal_buf *buf, size_t u64s)
}
static inline struct jset_entry *
-bch2_journal_reservation_entry(struct journal *j, struct journal_res *res)
+journal_res_entry(struct journal *j, struct journal_res *res)
{
return vstruct_idx(j->buf[res->idx].data, res->offset);
}
+static inline unsigned journal_entry_set(struct jset_entry *entry, unsigned type,
+ enum btree_id id, unsigned level,
+ const void *data, unsigned u64s)
+{
+ entry->u64s = cpu_to_le16(u64s);
+ entry->btree_id = id;
+ entry->level = level;
+ entry->type = type;
+ entry->pad[0] = 0;
+ entry->pad[1] = 0;
+ entry->pad[2] = 0;
+ memcpy_u64s_small(entry->_data, data, u64s);
+
+ return jset_u64s(u64s);
+}
+
static inline void bch2_journal_add_entry(struct journal *j, struct journal_res *res,
unsigned type, enum btree_id id,
unsigned level,
const void *data, unsigned u64s)
{
- struct jset_entry *entry = bch2_journal_reservation_entry(j, res);
- unsigned actual = jset_u64s(u64s);
+ unsigned actual = journal_entry_set(journal_res_entry(j, res),
+ type, id, level, data, u64s);
EBUG_ON(!res->ref);
EBUG_ON(actual > res->u64s);
res->offset += actual;
res->u64s -= actual;
-
- entry->u64s = cpu_to_le16(u64s);
- entry->btree_id = id;
- entry->level = level;
- entry->type = type;
- entry->pad[0] = 0;
- entry->pad[1] = 0;
- entry->pad[2] = 0;
- memcpy_u64s_small(entry->_data, data, u64s);
}
static inline void bch2_journal_add_keys(struct journal *j, struct journal_res *res,