diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-11-03 20:04:54 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:10 -0400 |
commit | ac10a9611d8794c849092a777a5febc4f69788ae (patch) | |
tree | da4c85073189dedbe2076e81eb7f70425fa7de49 /fs/bcachefs/journal_io.c | |
parent | b564513cf990d2d30305ac63a72a013fc197e7da (diff) | |
download | lwn-ac10a9611d8794c849092a777a5febc4f69788ae.tar.gz lwn-ac10a9611d8794c849092a777a5febc4f69788ae.zip |
bcachefs: Some fixes for building in userspace
userspace allocators don't align allocations as nicely as kernel
allocators, which meant that in some cases we weren't allocating big
enough bvec arrays - just make the calculations more rigorous and
explicit to fix it.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 3dc24b39022f..0bcc4346285c 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -429,7 +429,6 @@ static int journal_read_bucket(struct bch_dev *ca, { struct bch_fs *c = ca->fs; struct journal_device *ja = &ca->journal; - struct bio *bio = ja->bio; struct jset *j = NULL; unsigned sectors, sectors_read = 0; u64 offset = bucket_to_sector(ca, ja->buckets[bucket]), @@ -441,15 +440,22 @@ static int journal_read_bucket(struct bch_dev *ca, while (offset < end) { if (!sectors_read) { -reread: sectors_read = min_t(unsigned, + struct bio *bio; + unsigned nr_bvecs; +reread: + sectors_read = min_t(unsigned, end - offset, buf->size >> 9); + nr_bvecs = buf_pages(buf->data, sectors_read << 9); + + bio = bio_kmalloc(nr_bvecs, GFP_KERNEL); + bio_init(bio, ca->disk_sb.bdev, bio->bi_inline_vecs, nr_bvecs, REQ_OP_READ); - bio_reset(bio, ca->disk_sb.bdev, REQ_OP_READ); bio->bi_iter.bi_sector = offset; bio->bi_iter.bi_size = sectors_read << 9; bch2_bio_map(bio, buf->data); ret = submit_bio_wait(bio); + kfree(bio); if (bch2_dev_io_err_on(ret, ca, "journal read from sector %llu", |