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 | |
parent | b564513cf990d2d30305ac63a72a013fc197e7da (diff) |
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>
-rw-r--r-- | fs/bcachefs/bset.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 3 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 12 |
3 files changed, 12 insertions, 5 deletions
diff --git a/fs/bcachefs/bset.c b/fs/bcachefs/bset.c index 74d8871528a6..7fc8fb85069f 100644 --- a/fs/bcachefs/bset.c +++ b/fs/bcachefs/bset.c @@ -1672,7 +1672,7 @@ struct bkey_packed *bch2_btree_node_iter_prev_filter(struct btree_node_iter *ite struct bkey_packed *orig_pos = bch2_btree_node_iter_peek_all(iter, b); struct btree_node_iter_set *set; struct bset_tree *t; - unsigned end; + unsigned end = 0; bch2_btree_node_iter_verify(iter, b); diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index c8809a59a765..1036b72f1ae6 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1881,7 +1881,8 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, trace_btree_write(b, bytes_to_write, sectors_to_write); - wbio = container_of(bio_alloc_bioset(NULL, 1 << order, + wbio = container_of(bio_alloc_bioset(NULL, + buf_pages(data, sectors_to_write << 9), REQ_OP_WRITE|REQ_META|REQ_FUA, GFP_NOIO, &c->btree_bio), 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", |