bcachefs: bch2_journal_log_msg()
This adds bch2_journal_log_msg(), which just logs a message to the journal, and uses it to mark startup and when journal replay finishes. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
a9bae40fda
commit
d5d3be7dc5
@ -630,31 +630,6 @@ int bch2_journal_flush_seq(struct journal *j, u64 seq)
|
||||
return ret ?: ret2 < 0 ? ret2 : 0;
|
||||
}
|
||||
|
||||
int bch2_journal_meta(struct journal *j)
|
||||
{
|
||||
struct journal_buf *buf;
|
||||
struct journal_res res;
|
||||
int ret;
|
||||
|
||||
memset(&res, 0, sizeof(res));
|
||||
|
||||
ret = bch2_journal_res_get(j, &res, jset_u64s(0), 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
buf = j->buf + (res.seq & JOURNAL_BUF_MASK);
|
||||
buf->must_flush = true;
|
||||
|
||||
if (!buf->flush_time) {
|
||||
buf->flush_time = local_clock() ?: 1;
|
||||
buf->expires = jiffies;
|
||||
}
|
||||
|
||||
bch2_journal_res_put(j, &res);
|
||||
|
||||
return bch2_journal_flush_seq(j, res.seq);
|
||||
}
|
||||
|
||||
/*
|
||||
* bch2_journal_flush_async - if there is an open journal entry, or a journal
|
||||
* still being written, write it and wait for the write to complete
|
||||
@ -707,6 +682,64 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bch2_journal_meta(struct journal *j)
|
||||
{
|
||||
struct journal_buf *buf;
|
||||
struct journal_res res;
|
||||
int ret;
|
||||
|
||||
memset(&res, 0, sizeof(res));
|
||||
|
||||
ret = bch2_journal_res_get(j, &res, jset_u64s(0), 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
buf = j->buf + (res.seq & JOURNAL_BUF_MASK);
|
||||
buf->must_flush = true;
|
||||
|
||||
if (!buf->flush_time) {
|
||||
buf->flush_time = local_clock() ?: 1;
|
||||
buf->expires = jiffies;
|
||||
}
|
||||
|
||||
bch2_journal_res_put(j, &res);
|
||||
|
||||
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)
|
||||
|
@ -478,6 +478,7 @@ int bch2_journal_flush_seq(struct journal *, u64);
|
||||
int bch2_journal_flush(struct journal *);
|
||||
bool bch2_journal_noflush_seq(struct journal *, u64);
|
||||
int bch2_journal_meta(struct journal *);
|
||||
int bch2_journal_log_msg(struct journal *, const char *, ...);
|
||||
|
||||
void bch2_journal_halt(struct journal *);
|
||||
|
||||
|
@ -578,6 +578,9 @@ static int bch2_journal_replay(struct bch_fs *c)
|
||||
bch2_journal_set_replay_done(j);
|
||||
bch2_journal_flush_all_pins(j);
|
||||
ret = bch2_journal_error(j);
|
||||
|
||||
if (keys->nr && !ret)
|
||||
bch2_journal_log_msg(&c->journal, "journal replay finished");
|
||||
err:
|
||||
kvfree(keys_sorted);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user