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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);

+2 −1
Original line number Diff line number Diff line
@@ -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),
+9 −3
Original line number Diff line number Diff line
@@ -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",