return cmp_int(l->journal_seq, r->journal_seq);
}
-static int bch2_journal_replay(struct bch_fs *c)
+static int bch2_journal_replay(struct bch_fs *c, u64 start_seq, u64 end_seq)
{
struct journal_keys *keys = &c->journal_keys;
struct journal_key **keys_sorted, *k;
sizeof(keys_sorted[0]),
journal_sort_seq_cmp, NULL);
+ if (keys->nr) {
+ ret = bch2_fs_log_msg(c, "Starting journal replay (%zu keys in entries %llu-%llu)",
+ keys->nr, start_seq, end_seq);
+ if (ret)
+ goto err;
+ }
+
for (i = 0; i < keys->nr; i++) {
k = keys_sorted[i];
ret = bch2_journal_error(j);
if (keys->nr && !ret)
- bch2_journal_log_msg(&c->journal, "journal replay finished");
+ bch2_fs_log_msg(c, "journal replay finished");
err:
kvfree(keys_sorted);
return ret;
const char *err = "cannot allocate memory";
struct bch_sb_field_clean *clean = NULL;
struct jset *last_journal_entry = NULL;
- u64 blacklist_seq, journal_seq;
+ u64 last_seq, blacklist_seq, journal_seq;
bool write_sb = false;
int ret = 0;
struct journal_replay **i;
bch_verbose(c, "starting journal read");
- ret = bch2_journal_read(c, &blacklist_seq, &journal_seq);
+ ret = bch2_journal_read(c, &last_seq, &blacklist_seq, &journal_seq);
if (ret)
goto err;
if (!last_journal_entry) {
fsck_err_on(!c->sb.clean, c, "no journal entries found");
- goto use_clean;
+ if (clean)
+ goto use_clean;
+
+ genradix_for_each_reverse(&c->journal_entries, iter, i)
+ if (*i) {
+ last_journal_entry = &(*i)->j;
+ (*i)->ignore = false;
+ break;
+ }
}
ret = journal_keys_sort(c);
journal_seq += 8;
if (blacklist_seq != journal_seq) {
- ret = bch2_journal_seq_blacklist_add(c,
+ ret = bch2_fs_log_msg(c, "blacklisting entries %llu-%llu",
+ blacklist_seq, journal_seq) ?:
+ bch2_journal_seq_blacklist_add(c,
blacklist_seq, journal_seq);
if (ret) {
bch_err(c, "error creating new journal seq blacklist entry");
}
}
- ret = bch2_fs_journal_start(&c->journal, journal_seq);
+ ret = bch2_fs_log_msg(c, "starting journal at entry %llu, replaying %llu-%llu",
+ journal_seq, last_seq, blacklist_seq - 1) ?:
+ bch2_fs_journal_start(&c->journal, journal_seq);
if (ret)
goto err;
bch_info(c, "starting journal replay, %zu keys", c->journal_keys.nr);
err = "journal replay failed";
- ret = bch2_journal_replay(c);
+ ret = bch2_journal_replay(c, last_seq, blacklist_seq - 1);
if (ret)
goto err;
if (c->opts.verbose || !c->sb.clean)
bch_verbose(c, "starting journal replay, %zu keys", c->journal_keys.nr);
err = "journal replay failed";
- ret = bch2_journal_replay(c);
+ ret = bch2_journal_replay(c, last_seq, blacklist_seq - 1);
if (ret)
goto err;
if (c->opts.verbose || !c->sb.clean)