Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a83f467 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe
Browse files

block: bio: pass bvec table to bio_init()



Some drivers often use external bvec table, so introduce
this helper for this case. It is always safe to access the
bio->bi_io_vec in this way for this case.

After converting to this usage, it will becomes a bit easier
to evaluate the remaining direct access to bio->bi_io_vec,
so it can help to prepare for the following multipage bvec
support.

Signed-off-by: default avatarMing Lei <tom.leiming@gmail.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>

Fixed up the new O_DIRECT cases.

Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 9a794fb9
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -270,11 +270,15 @@ static void bio_free(struct bio *bio)
	}
}

void bio_init(struct bio *bio)
void bio_init(struct bio *bio, struct bio_vec *table,
	      unsigned short max_vecs)
{
	memset(bio, 0, sizeof(*bio));
	atomic_set(&bio->__bi_remaining, 1);
	atomic_set(&bio->__bi_cnt, 1);

	bio->bi_io_vec = table;
	bio->bi_max_vecs = max_vecs;
}
EXPORT_SYMBOL(bio_init);

@@ -480,7 +484,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
		return NULL;

	bio = p + front_pad;
	bio_init(bio);
	bio_init(bio, NULL, 0);

	if (nr_iovecs > inline_vecs) {
		unsigned long idx = 0;
+1 −2
Original line number Diff line number Diff line
@@ -3806,8 +3806,7 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive)

	cbdata.drive = drive;

	bio_init(&bio);
	bio.bi_io_vec = &bio_vec;
	bio_init(&bio, &bio_vec, 1);
	bio_vec.bv_page = page;
	bio_vec.bv_len = size;
	bio_vec.bv_offset = 0;
+1 −3
Original line number Diff line number Diff line
@@ -24,9 +24,7 @@ struct bio *bch_bbio_alloc(struct cache_set *c)
	struct bbio *b = mempool_alloc(c->bio_meta, GFP_NOIO);
	struct bio *bio = &b->bio;

	bio_init(bio);
	bio->bi_max_vecs	 = bucket_pages(c);
	bio->bi_io_vec		 = bio->bi_inline_vecs;
	bio_init(bio, bio->bi_inline_vecs, bucket_pages(c));

	return bio;
}
+1 −3
Original line number Diff line number Diff line
@@ -448,13 +448,11 @@ static void do_journal_discard(struct cache *ca)

		atomic_set(&ja->discard_in_flight, DISCARD_IN_FLIGHT);

		bio_init(bio);
		bio_init(bio, bio->bi_inline_vecs, 1);
		bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
		bio->bi_iter.bi_sector	= bucket_to_sector(ca->set,
						ca->sb.d[ja->discard_idx]);
		bio->bi_bdev		= ca->bdev;
		bio->bi_max_vecs	= 1;
		bio->bi_io_vec		= bio->bi_inline_vecs;
		bio->bi_iter.bi_size	= bucket_bytes(ca);
		bio->bi_end_io		= journal_discard_endio;

+2 −4
Original line number Diff line number Diff line
@@ -77,15 +77,13 @@ static void moving_init(struct moving_io *io)
{
	struct bio *bio = &io->bio.bio;

	bio_init(bio);
	bio_init(bio, bio->bi_inline_vecs,
		 DIV_ROUND_UP(KEY_SIZE(&io->w->key), PAGE_SECTORS));
	bio_get(bio);
	bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));

	bio->bi_iter.bi_size	= KEY_SIZE(&io->w->key) << 9;
	bio->bi_max_vecs	= DIV_ROUND_UP(KEY_SIZE(&io->w->key),
					       PAGE_SECTORS);
	bio->bi_private		= &io->cl;
	bio->bi_io_vec		= bio->bi_inline_vecs;
	bch_bio_map(bio, NULL);
}

Loading