From: Kent Overstreet Date: Thu, 22 Aug 2019 20:41:50 +0000 (-0400) Subject: bcachefs: Handle ec_buf not being page aligned when allocating bio X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=16e671037a4ca9d695134151d9bc58069d24b094;p=linux.git bcachefs: Handle ec_buf not being page aligned when allocating bio Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 5db83374403b8..117d1faa99f2e 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -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);