On 6/22/21 7:04 PM, Hannes Reinecke wrote: > On 6/15/21 7:49 AM, Coly Li wrote: >> This patch implements two methods to read jset from media for journal >> replay, >> - __jnl_rd_bkt() for block device >> This is the legacy method to read jset via block device interface. >> - __jnl_rd_nvm_bkt() for NVDIMM >> This is the method to read jset from NVDIMM memory interface, a.k.a >> memcopy() from NVDIMM pages to DRAM pages. >> >> If BCH_FEATURE_INCOMPAT_NVDIMM_META is set in incompat feature set, >> during running cache set, journal_read_bucket() will read the journal >> content from NVDIMM by __jnl_rd_nvm_bkt(). The linear addresses of >> NVDIMM pages to read jset are stored in sb.d[SB_JOURNAL_BUCKETS], which >> were initialized and maintained in previous runs of the cache set. >> >> A thing should be noticed is, when bch_journal_read() is called, the >> linear address of NVDIMM pages is not loaded and initialized yet, it >> is necessary to call __bch_journal_nvdimm_init() before reading the jset >> from NVDIMM pages. >> >> Signed-off-by: Coly Li <colyli@xxxxxxx> >> Cc: Jianpeng Ma <jianpeng.ma@xxxxxxxxx> >> Cc: Qiaowei Ren <qiaowei.ren@xxxxxxxxx> >> --- >> drivers/md/bcache/journal.c | 93 +++++++++++++++++++++++++++---------- >> 1 file changed, 69 insertions(+), 24 deletions(-) >> >> diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c >> index 03ecedf813b0..23e5ccf125df 100644 >> --- a/drivers/md/bcache/journal.c >> +++ b/drivers/md/bcache/journal.c >> @@ -34,60 +34,96 @@ static void journal_read_endio(struct bio *bio) >> closure_put(cl); >> } >> >> +static struct jset *__jnl_rd_bkt(struct cache *ca, unsigned int bkt_idx, >> + unsigned int len, unsigned int offset, >> + struct closure *cl) >> +{ >> + sector_t bucket = bucket_to_sector(ca->set, ca->sb.d[bkt_idx]); >> + struct bio *bio = &ca->journal.bio; >> + struct jset *data = ca->set->journal.w[0].data; >> + >> + bio_reset(bio); >> + bio->bi_iter.bi_sector = bucket + offset; >> + bio_set_dev(bio, ca->bdev); >> + bio->bi_iter.bi_size = len << 9; >> + bio->bi_end_io = journal_read_endio; >> + bio->bi_private = cl; >> + bio_set_op_attrs(bio, REQ_OP_READ, 0); >> + bch_bio_map(bio, data); >> + >> + closure_bio_submit(ca->set, bio, cl); >> + closure_sync(cl); >> + >> + /* Indeed journal.w[0].data */ >> + return data; >> +} >> + >> +#if defined(CONFIG_BCACHE_NVM_PAGES) >> + >> +static struct jset *__jnl_rd_nvm_bkt(struct cache *ca, unsigned int bkt_idx, >> + unsigned int len, unsigned int offset) >> +{ >> + void *jset_addr = (void *)ca->sb.d[bkt_idx] + (offset << 9); >> + struct jset *data = ca->set->journal.w[0].data; >> + >> + memcpy(data, jset_addr, len << 9); >> + >> + /* Indeed journal.w[0].data */ >> + return data; >> +} >> + >> +#else /* CONFIG_BCACHE_NVM_PAGES */ >> + >> +static struct jset *__jnl_rd_nvm_bkt(struct cache *ca, unsigned int bkt_idx, >> + unsigned int len, unsigned int offset) >> +{ >> + return NULL; >> +} >> + >> +#endif /* CONFIG_BCACHE_NVM_PAGES */ >> + >> static int journal_read_bucket(struct cache *ca, struct list_head *list, >> - unsigned int bucket_index) >> + unsigned int bucket_idx) > This renaming is pointless. Copied, will revert this in next post. Thanks for your review. Coly Li