Commit ac10a961 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent b564513c
...@@ -1672,7 +1672,7 @@ struct bkey_packed *bch2_btree_node_iter_prev_filter(struct btree_node_iter *ite ...@@ -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 bkey_packed *orig_pos = bch2_btree_node_iter_peek_all(iter, b);
struct btree_node_iter_set *set; struct btree_node_iter_set *set;
struct bset_tree *t; struct bset_tree *t;
unsigned end; unsigned end = 0;
bch2_btree_node_iter_verify(iter, b); bch2_btree_node_iter_verify(iter, b);
......
...@@ -1881,7 +1881,8 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, ...@@ -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); 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, REQ_OP_WRITE|REQ_META|REQ_FUA,
GFP_NOIO, GFP_NOIO,
&c->btree_bio), &c->btree_bio),
......
...@@ -429,7 +429,6 @@ static int journal_read_bucket(struct bch_dev *ca, ...@@ -429,7 +429,6 @@ static int journal_read_bucket(struct bch_dev *ca,
{ {
struct bch_fs *c = ca->fs; struct bch_fs *c = ca->fs;
struct journal_device *ja = &ca->journal; struct journal_device *ja = &ca->journal;
struct bio *bio = ja->bio;
struct jset *j = NULL; struct jset *j = NULL;
unsigned sectors, sectors_read = 0; unsigned sectors, sectors_read = 0;
u64 offset = bucket_to_sector(ca, ja->buckets[bucket]), u64 offset = bucket_to_sector(ca, ja->buckets[bucket]),
...@@ -441,15 +440,22 @@ static int journal_read_bucket(struct bch_dev *ca, ...@@ -441,15 +440,22 @@ static int journal_read_bucket(struct bch_dev *ca,
while (offset < end) { while (offset < end) {
if (!sectors_read) { 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); 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_sector = offset;
bio->bi_iter.bi_size = sectors_read << 9; bio->bi_iter.bi_size = sectors_read << 9;
bch2_bio_map(bio, buf->data); bch2_bio_map(bio, buf->data);
ret = submit_bio_wait(bio); ret = submit_bio_wait(bio);
kfree(bio);
if (bch2_dev_io_err_on(ret, ca, if (bch2_dev_io_err_on(ret, ca,
"journal read from sector %llu", "journal read from sector %llu",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment