bcachefs: bch_member.last_journal_bucket
On recovery from clean shutdown we don't typically read the journal, but we still want to avoid overwriting existing entries in the journal for list_journal debugging. Thus, add some fields to the member info section so we can remember where we left off. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
c749541353
commit
45150765d3
|
@ -589,6 +589,13 @@ struct bch_member {
|
|||
__le64 errors_reset_time;
|
||||
__le64 seq;
|
||||
__le64 btree_allocated_bitmap;
|
||||
/*
|
||||
* On recovery from a clean shutdown we don't normally read the journal,
|
||||
* but we still want to resume writing from where we left off so we
|
||||
* don't overwrite more than is necessary, for list journal debugging:
|
||||
*/
|
||||
__le32 last_journal_bucket;
|
||||
__le32 last_journal_bucket_offset;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,6 +17,34 @@
|
|||
#include "sb-clean.h"
|
||||
#include "trace.h"
|
||||
|
||||
void bch2_journal_pos_from_member_info_set(struct bch_fs *c)
|
||||
{
|
||||
lockdep_assert_held(&c->sb_lock);
|
||||
|
||||
for_each_member_device(c, ca) {
|
||||
struct bch_member *m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx);
|
||||
|
||||
m->last_journal_bucket = cpu_to_le32(ca->journal.cur_idx);
|
||||
m->last_journal_bucket_offset = cpu_to_le32(ca->mi.bucket_size - ca->journal.sectors_free);
|
||||
}
|
||||
}
|
||||
|
||||
void bch2_journal_pos_from_member_info_resume(struct bch_fs *c)
|
||||
{
|
||||
mutex_lock(&c->sb_lock);
|
||||
for_each_member_device(c, ca) {
|
||||
struct bch_member m = bch2_sb_member_get(c->disk_sb.sb, ca->dev_idx);
|
||||
|
||||
unsigned idx = le32_to_cpu(m.last_journal_bucket);
|
||||
if (idx < ca->journal.nr)
|
||||
ca->journal.cur_idx = idx;
|
||||
unsigned offset = le32_to_cpu(m.last_journal_bucket_offset);
|
||||
if (offset <= ca->mi.bucket_size)
|
||||
ca->journal.sectors_free = ca->mi.bucket_size - offset;
|
||||
}
|
||||
mutex_unlock(&c->sb_lock);
|
||||
}
|
||||
|
||||
void bch2_journal_ptrs_to_text(struct printbuf *out, struct bch_fs *c,
|
||||
struct journal_replay *j)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#include "darray.h"
|
||||
|
||||
void bch2_journal_pos_from_member_info_set(struct bch_fs *);
|
||||
void bch2_journal_pos_from_member_info_resume(struct bch_fs *);
|
||||
|
||||
struct journal_ptr {
|
||||
bool csum_good;
|
||||
u8 dev;
|
||||
|
|
|
@ -670,6 +670,8 @@ int bch2_fs_recovery(struct bch_fs *c)
|
|||
goto err;
|
||||
}
|
||||
|
||||
bch2_journal_pos_from_member_info_resume(c);
|
||||
|
||||
if (!c->sb.clean || c->opts.retain_recovery_info) {
|
||||
struct genradix_iter iter;
|
||||
struct journal_replay **i;
|
||||
|
|
|
@ -390,6 +390,8 @@ void bch2_fs_mark_clean(struct bch_fs *c)
|
|||
goto out;
|
||||
}
|
||||
|
||||
bch2_journal_pos_from_member_info_set(c);
|
||||
|
||||
bch2_write_super(c);
|
||||
out:
|
||||
mutex_unlock(&c->sb_lock);
|
||||
|
|
Loading…
Reference in New Issue