On Tue, Jun 26, 2018 at 11:41:02PM +0800, zhiyuanme@xxxxxxxx wrote: > > Hi, > There is a doubt about the use of bcache recently. > In this scenario,current bio is going to bypass,but overlaped with > writeback_keys.then bch_keybuf_check_overlapping will delete the > overlaping bkey from writeback_keys rbtree when private (the member of > rbnode) is NULL. > > Next,s->iop.bypass will be true,current bio is written directly to the > HDD.Just at this time,the system is down for some reason,however the dirty > data in the cache(SSD) haved falled to HDD.When the system is up > again,journal will replay.the old dirty will be writeback resulting in > overlapping the last data. > > Is there consistency in data in this case? Or any other way for bcache to > deal with the problem? We don't complete the write until we also delete the dirty data from the cache. Notice that cached_dev_write _always_ calls bch_data_insert - if bypass is true, bch_data_insert discards data from the cache instead of doing a write. > Looking forward to your reply. Thank you. > > bcache version:linux-4.16.rc7 > code as follows: > static void cached_dev_write(struct cached_dev *dc, struct search *s) > { //if s->iop.bypass is true and overlapping with writeback_keys. ... > if (bch_keybuf_check_overlapping(&dc->writeback_keys, &start, &end)) //if return false { > s->iop.bypass = false; > s->iop.writeback = true; > } ... if (s->iop.bypass) { s->iop.bio = s->orig_bio; bio_get(s->iop.bio); if ((bio_op(bio) != REQ_OP_DISCARD) ||blk_queue_discard(bdev_get_queue(dc->bdev))) closure_bio_submit(bio, cl); } //system down ... closure_call(&s->iop.cl, bch_data_insert, NULL, cl); ...} > > > zhiyuanme@xxxxxxxx -- To unsubscribe from this list: send the line "unsubscribe linux-bcache" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html