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

Commit 6dc4f100 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe
Browse files

block: allow bio_for_each_segment_all() to iterate over multi-page bvec



This patch introduces one extra iterator variable to bio_for_each_segment_all(),
then we can allow bio_for_each_segment_all() to iterate over multi-page bvec.

Given it is just one mechannical & simple change on all bio_for_each_segment_all()
users, this patch does tree-wide change in one single patch, so that we can
avoid to use a temporary helper for this conversion.

Reviewed-by: default avatarOmar Sandoval <osandov@fb.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 2e1f4f4d
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -1072,8 +1072,9 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter)
{
	int i;
	struct bio_vec *bvec;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		ssize_t ret;

		ret = copy_page_from_iter(bvec->bv_page,
@@ -1103,8 +1104,9 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)
{
	int i;
	struct bio_vec *bvec;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		ssize_t ret;

		ret = copy_page_to_iter(bvec->bv_page,
@@ -1126,8 +1128,9 @@ void bio_free_pages(struct bio *bio)
{
	struct bio_vec *bvec;
	int i;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i)
	bio_for_each_segment_all(bvec, bio, i, iter_all)
		__free_page(bvec->bv_page);
}
EXPORT_SYMBOL(bio_free_pages);
@@ -1295,6 +1298,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
	struct bio *bio;
	int ret;
	struct bio_vec *bvec;
	struct bvec_iter_all iter_all;

	if (!iov_iter_count(iter))
		return ERR_PTR(-EINVAL);
@@ -1368,7 +1372,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
	return bio;

 out_unmap:
	bio_for_each_segment_all(bvec, bio, j) {
	bio_for_each_segment_all(bvec, bio, j, iter_all) {
		put_page(bvec->bv_page);
	}
	bio_put(bio);
@@ -1379,11 +1383,12 @@ static void __bio_unmap_user(struct bio *bio)
{
	struct bio_vec *bvec;
	int i;
	struct bvec_iter_all iter_all;

	/*
	 * make sure we dirty pages we wrote to
	 */
	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		if (bio_data_dir(bio) == READ)
			set_page_dirty_lock(bvec->bv_page);

@@ -1475,8 +1480,9 @@ static void bio_copy_kern_endio_read(struct bio *bio)
	char *p = bio->bi_private;
	struct bio_vec *bvec;
	int i;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		memcpy(p, page_address(bvec->bv_page), bvec->bv_len);
		p += bvec->bv_len;
	}
@@ -1585,8 +1591,9 @@ void bio_set_pages_dirty(struct bio *bio)
{
	struct bio_vec *bvec;
	int i;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		if (!PageCompound(bvec->bv_page))
			set_page_dirty_lock(bvec->bv_page);
	}
@@ -1596,8 +1603,9 @@ static void bio_release_pages(struct bio *bio)
{
	struct bio_vec *bvec;
	int i;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i)
	bio_for_each_segment_all(bvec, bio, i, iter_all)
		put_page(bvec->bv_page);
}

@@ -1644,8 +1652,9 @@ void bio_check_pages_dirty(struct bio *bio)
	struct bio_vec *bvec;
	unsigned long flags;
	int i;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page))
			goto defer;
	}
+4 −2
Original line number Diff line number Diff line
@@ -165,11 +165,12 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool)
	struct bio_vec *bvec, orig_vec;
	int i;
	struct bvec_iter orig_iter = bio_orig->bi_iter;
	struct bvec_iter_all iter_all;

	/*
	 * free up bounce indirect pages used
	 */
	bio_for_each_segment_all(bvec, bio, i) {
	bio_for_each_segment_all(bvec, bio, i, iter_all) {
		orig_vec = bio_iter_iovec(bio_orig, orig_iter);
		if (bvec->bv_page != orig_vec.bv_page) {
			dec_zone_page_state(bvec->bv_page, NR_BOUNCE);
@@ -294,6 +295,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
	bool bounce = false;
	int sectors = 0;
	bool passthrough = bio_is_passthrough(*bio_orig);
	struct bvec_iter_all iter_all;

	bio_for_each_segment(from, *bio_orig, iter) {
		if (i++ < BIO_MAX_PAGES)
@@ -313,7 +315,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
	bio = bounce_clone_bio(*bio_orig, GFP_NOIO, passthrough ? NULL :
			&bounce_bio_set);

	bio_for_each_segment_all(to, bio, i) {
	bio_for_each_segment_all(to, bio, i, iter_all) {
		struct page *page = to->bv_page;

		if (page_to_pfn(page) <= q->limits.bounce_pfn)
+2 −1
Original line number Diff line number Diff line
@@ -432,8 +432,9 @@ static void do_btree_node_write(struct btree *b)
		int j;
		struct bio_vec *bv;
		void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
		struct bvec_iter_all iter_all;

		bio_for_each_segment_all(bv, b->bio, j)
		bio_for_each_segment_all(bv, b->bio, j, iter_all)
			memcpy(page_address(bv->bv_page),
			       base + j * PAGE_SIZE, PAGE_SIZE);

+2 −1
Original line number Diff line number Diff line
@@ -1447,8 +1447,9 @@ static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone)
{
	unsigned int i;
	struct bio_vec *bv;
	struct bvec_iter_all iter_all;

	bio_for_each_segment_all(bv, clone, i) {
	bio_for_each_segment_all(bv, clone, i, iter_all) {
		BUG_ON(!bv->bv_page);
		mempool_free(bv->bv_page, &cc->page_pool);
	}
+2 −1
Original line number Diff line number Diff line
@@ -2112,13 +2112,14 @@ static void process_checks(struct r1bio *r1_bio)
		struct page **spages = get_resync_pages(sbio)->pages;
		struct bio_vec *bi;
		int page_len[RESYNC_PAGES] = { 0 };
		struct bvec_iter_all iter_all;

		if (sbio->bi_end_io != end_sync_read)
			continue;
		/* Now we can 'fixup' the error value */
		sbio->bi_status = 0;

		bio_for_each_segment_all(bi, sbio, j)
		bio_for_each_segment_all(bi, sbio, j, iter_all)
			page_len[j] = bi->bv_len;

		if (!status) {
Loading