bcache: Fix flash_dev_cache_miss() for real this time
The code was using sectors to count the number of sectors it was zeroing... but then it passed it to bio_advance()... after it had been set to 0. Amusing... Signed-off-by: Kent Overstreet <kmo@daterainc.com>
This commit is contained in:
parent
85cbe1f88c
commit
1b4eaf3d38
1 changed files with 5 additions and 14 deletions
|
@ -1203,22 +1203,13 @@ void bch_cached_dev_request_init(struct cached_dev *dc)
|
||||||
static int flash_dev_cache_miss(struct btree *b, struct search *s,
|
static int flash_dev_cache_miss(struct btree *b, struct search *s,
|
||||||
struct bio *bio, unsigned sectors)
|
struct bio *bio, unsigned sectors)
|
||||||
{
|
{
|
||||||
struct bio_vec bv;
|
unsigned bytes = min(sectors, bio_sectors(bio)) << 9;
|
||||||
struct bvec_iter iter;
|
|
||||||
|
|
||||||
/* Zero fill bio */
|
swap(bio->bi_iter.bi_size, bytes);
|
||||||
|
zero_fill_bio(bio);
|
||||||
|
swap(bio->bi_iter.bi_size, bytes);
|
||||||
|
|
||||||
bio_for_each_segment(bv, bio, iter) {
|
bio_advance(bio, bytes);
|
||||||
unsigned j = min(bv.bv_len >> 9, sectors);
|
|
||||||
|
|
||||||
void *p = kmap(bv.bv_page);
|
|
||||||
memset(p + bv.bv_offset, 0, j << 9);
|
|
||||||
kunmap(bv.bv_page);
|
|
||||||
|
|
||||||
sectors -= j;
|
|
||||||
}
|
|
||||||
|
|
||||||
bio_advance(bio, min(sectors << 9, bio->bi_iter.bi_size));
|
|
||||||
|
|
||||||
if (!bio->bi_iter.bi_size)
|
if (!bio->bi_iter.bi_size)
|
||||||
return MAP_DONE;
|
return MAP_DONE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue