bcachefs: Simplify resuming of journal position
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
83c38e3ef8
commit
c8bda9f20a
@ -1089,6 +1089,13 @@ reread:
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (le64_to_cpu(j->seq) > ja->highest_seq_found) {
|
||||||
|
ja->highest_seq_found = le64_to_cpu(j->seq);
|
||||||
|
ja->cur_idx = bucket;
|
||||||
|
ja->sectors_free = ca->mi.bucket_size -
|
||||||
|
bucket_remainder(ca, offset) - sectors;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This happens sometimes if we don't have discards on -
|
* This happens sometimes if we don't have discards on -
|
||||||
* when we've partially overwritten a bucket with new
|
* when we've partially overwritten a bucket with new
|
||||||
@ -1157,8 +1164,6 @@ static CLOSURE_CALLBACK(bch2_journal_read_device)
|
|||||||
struct bch_fs *c = ca->fs;
|
struct bch_fs *c = ca->fs;
|
||||||
struct journal_list *jlist =
|
struct journal_list *jlist =
|
||||||
container_of(cl->parent, struct journal_list, cl);
|
container_of(cl->parent, struct journal_list, cl);
|
||||||
struct journal_replay *r, **_r;
|
|
||||||
struct genradix_iter iter;
|
|
||||||
struct journal_read_buf buf = { NULL, 0 };
|
struct journal_read_buf buf = { NULL, 0 };
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -1178,47 +1183,6 @@ static CLOSURE_CALLBACK(bch2_journal_read_device)
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ja->sectors_free = ca->mi.bucket_size;
|
|
||||||
|
|
||||||
mutex_lock(&jlist->lock);
|
|
||||||
genradix_for_each_reverse(&c->journal_entries, iter, _r) {
|
|
||||||
r = *_r;
|
|
||||||
|
|
||||||
if (!r)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
darray_for_each(r->ptrs, i)
|
|
||||||
if (i->dev == ca->dev_idx) {
|
|
||||||
unsigned wrote = bucket_remainder(ca, i->sector) +
|
|
||||||
vstruct_sectors(&r->j, c->block_bits);
|
|
||||||
|
|
||||||
ja->cur_idx = i->bucket;
|
|
||||||
ja->sectors_free = ca->mi.bucket_size - wrote;
|
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
found:
|
|
||||||
mutex_unlock(&jlist->lock);
|
|
||||||
|
|
||||||
if (ja->bucket_seq[ja->cur_idx] &&
|
|
||||||
ja->sectors_free == ca->mi.bucket_size) {
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* Debug code for ZNS support, where we (probably) want to be
|
|
||||||
* correlated where we stopped in the journal to the zone write
|
|
||||||
* points:
|
|
||||||
*/
|
|
||||||
bch_err(c, "ja->sectors_free == ca->mi.bucket_size");
|
|
||||||
bch_err(c, "cur_idx %u/%u", ja->cur_idx, ja->nr);
|
|
||||||
for (i = 0; i < 3; i++) {
|
|
||||||
unsigned idx = (ja->cur_idx + ja->nr - 1 + i) % ja->nr;
|
|
||||||
|
|
||||||
bch_err(c, "bucket_seq[%u] = %llu", idx, ja->bucket_seq[idx]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ja->sectors_free = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set dirty_idx to indicate the entire journal is full and needs to be
|
* Set dirty_idx to indicate the entire journal is full and needs to be
|
||||||
* reclaimed - journal reclaim will immediately reclaim whatever isn't
|
* reclaimed - journal reclaim will immediately reclaim whatever isn't
|
||||||
|
@ -327,6 +327,7 @@ struct journal_device {
|
|||||||
|
|
||||||
/* for bch_journal_read_device */
|
/* for bch_journal_read_device */
|
||||||
struct closure read;
|
struct closure read;
|
||||||
|
u64 highest_seq_found;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user