mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
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>
This commit is contained in:
parent
b564513cf9
commit
ac10a9611d
@ -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);
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user