From 16e671037a4ca9d695134151d9bc58069d24b094 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 22 Aug 2019 16:41:50 -0400 Subject: [PATCH] bcachefs: Handle ec_buf not being page aligned when allocating bio Signed-off-by: Kent Overstreet --- fs/bcachefs/io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.30.2