summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-14 18:39:04 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:48 +0300
commit5bbe3f2d0e1e52c03f32cb40cc749e1ace6453d0 (patch)
tree561949ed10a4c50bf1727f0f8b294ae56f22f688 /fs/bcachefs/journal.c
parent9d7f2a4111be34eac6b23ed62271efb12f36815f (diff)
downloadlinux-5bbe3f2d0e1e52c03f32cb40cc749e1ace6453d0.tar.xz
bcachefs: Log more messages in the journal
This patch - Adds a mechanism for queuing up journal entries prior to the journal being started, which will be used for early journal log messages - Adds bch2_fs_log_msg() and improves bch2_trans_log_msg(), which now take format strings. bch2_fs_log_msg() can be used before or after the journal has been started, and will use the appropriate mechanism. - Deletes the now obsolete bch2_journal_log_msg() - And adds more log messages to the recovery path - messages for journal/filesystem started, journal entries being blacklisted, and journal replay starting/finishing. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal.c')
-rw-r--r--fs/bcachefs/journal.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index ed3ed3072db1..c7a7b9cd20f0 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -249,7 +249,7 @@ static int journal_entry_open(struct journal *j)
journal_entry_overhead(j);
u64s = clamp_t(int, u64s, 0, JOURNAL_ENTRY_CLOSED_VAL - 1);
- if (u64s <= 0)
+ if (u64s <= (ssize_t) j->early_journal_entries.nr)
return JOURNAL_ERR_journal_full;
if (fifo_empty(&j->pin) && j->reclaim_thread)
@@ -274,6 +274,12 @@ static int journal_entry_open(struct journal *j)
buf->data->seq = cpu_to_le64(journal_cur_seq(j));
buf->data->u64s = 0;
+ if (j->early_journal_entries.nr) {
+ memcpy(buf->data->_data, j->early_journal_entries.data,
+ j->early_journal_entries.nr * sizeof(u64));
+ le32_add_cpu(&buf->data->u64s, j->early_journal_entries.nr);
+ }
+
/*
* Must be set before marking the journal entry as open:
*/
@@ -290,7 +296,9 @@ static int journal_entry_open(struct journal *j)
BUG_ON(new.idx != (journal_cur_seq(j) & JOURNAL_BUF_MASK));
journal_state_inc(&new);
- new.cur_entry_offset = 0;
+
+ /* Handle any already added entries */
+ new.cur_entry_offset = le32_to_cpu(buf->data->u64s);
} while ((v = atomic64_cmpxchg(&j->reservations.counter,
old.v, new.v)) != old.v);
@@ -303,6 +311,9 @@ static int journal_entry_open(struct journal *j)
&j->write_work,
msecs_to_jiffies(c->opts.journal_flush_delay));
journal_wake(j);
+
+ if (j->early_journal_entries.nr)
+ darray_exit(&j->early_journal_entries);
return 0;
}
@@ -719,39 +730,6 @@ int bch2_journal_meta(struct journal *j)
return bch2_journal_flush_seq(j, res.seq);
}
-int bch2_journal_log_msg(struct journal *j, const char *fmt, ...)
-{
- struct jset_entry_log *entry;
- struct journal_res res = { 0 };
- unsigned msglen, u64s;
- va_list args;
- int ret;
-
- va_start(args, fmt);
- msglen = vsnprintf(NULL, 0, fmt, args) + 1;
- va_end(args);
-
- u64s = jset_u64s(DIV_ROUND_UP(msglen, sizeof(u64)));
-
- ret = bch2_journal_res_get(j, &res, u64s, 0);
- if (ret)
- return ret;
-
- entry = container_of(journal_res_entry(j, &res),
- struct jset_entry_log, entry);
- memset(entry, 0, u64s * sizeof(u64));
- entry->entry.type = BCH_JSET_ENTRY_log;
- entry->entry.u64s = u64s - 1;
-
- va_start(args, fmt);
- vsnprintf(entry->d, INT_MAX, fmt, args);
- va_end(args);
-
- bch2_journal_res_put(j, &res);
-
- return bch2_journal_flush_seq(j, res.seq);
-}
-
/* block/unlock the journal: */
void bch2_journal_unblock(struct journal *j)
@@ -1197,6 +1175,8 @@ void bch2_fs_journal_exit(struct journal *j)
{
unsigned i;
+ darray_exit(&j->early_journal_entries);
+
for (i = 0; i < ARRAY_SIZE(j->buf); i++)
kvpfree(j->buf[i].data, j->buf[i].buf_size);
free_fifo(&j->pin);