bcachefs: Handle ec_buf not being page aligned when allocating bio

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2019-08-22 16:41:50 -04:00 committed by Kent Overstreet
parent 21629f5368
commit 16e671037a

View file

@ -461,7 +461,10 @@ static struct bio *bch2_write_bio_alloc(struct bch_fs *c,
struct bio *bio;
unsigned output_available =
min(wp->sectors_free << 9, src->bi_iter.bi_size);
unsigned pages = DIV_ROUND_UP(output_available, PAGE_SIZE);
unsigned pages = DIV_ROUND_UP(output_available +
(buf
? ((unsigned long) buf & (PAGE_SIZE - 1))
: 0), PAGE_SIZE);
bio = bio_alloc_bioset(NULL, pages, 0,
GFP_NOIO, &c->bio_write);