Commit a4ad39b1 authored by Kent Overstreet's avatar Kent Overstreet

block: Convert bio_iovec() to bvec_iter

For immutable biovecs, we'll be introducing a new bio_iovec() that uses
our new bvec iterator to construct a biovec, taking into account
bvec_iter->bi_bvec_done - this patch updates existing users for the new
usage.

Some of the existing users really do need a pointer into the bvec array
- those uses are all going to be removed, but we'll need the
functionality from immutable to remove them - so for now rename the
existing bio_iovec() -> __bio_iovec(), and it'll be removed in a couple
patches.
Signed-off-by: default avatarKent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: "Ed L. Cashin" <ecashin@coraid.com>
Cc: Alasdair Kergon <agk@redhat.com>
Cc: dm-devel@redhat.com
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
parent 75d5d815
...@@ -932,7 +932,7 @@ bufinit(struct buf *buf, struct request *rq, struct bio *bio) ...@@ -932,7 +932,7 @@ bufinit(struct buf *buf, struct request *rq, struct bio *bio)
buf->resid = bio->bi_iter.bi_size; buf->resid = bio->bi_iter.bi_size;
buf->sector = bio->bi_iter.bi_sector; buf->sector = bio->bi_iter.bi_sector;
bio_pageinc(bio); bio_pageinc(bio);
buf->bv = bio_iovec(bio); buf->bv = __bio_iovec(bio);
buf->bv_resid = buf->bv->bv_len; buf->bv_resid = buf->bv->bv_len;
WARN_ON(buf->bv_resid == 0); WARN_ON(buf->bv_resid == 0);
} }
......
...@@ -22,11 +22,12 @@ static void bch_bi_idx_hack_endio(struct bio *bio, int error) ...@@ -22,11 +22,12 @@ static void bch_bi_idx_hack_endio(struct bio *bio, int error)
static void bch_generic_make_request_hack(struct bio *bio) static void bch_generic_make_request_hack(struct bio *bio)
{ {
if (bio->bi_iter.bi_idx) { if (bio->bi_iter.bi_idx) {
int i;
struct bio_vec *bv;
struct bio *clone = bio_alloc(GFP_NOIO, bio_segments(bio)); struct bio *clone = bio_alloc(GFP_NOIO, bio_segments(bio));
memcpy(clone->bi_io_vec, bio_for_each_segment(bv, bio, i)
bio_iovec(bio), clone->bi_io_vec[clone->bi_vcnt++] = *bv;
bio_segments(bio) * sizeof(struct bio_vec));
clone->bi_iter.bi_sector = bio->bi_iter.bi_sector; clone->bi_iter.bi_sector = bio->bi_iter.bi_sector;
clone->bi_bdev = bio->bi_bdev; clone->bi_bdev = bio->bi_bdev;
...@@ -97,7 +98,7 @@ struct bio *bch_bio_split(struct bio *bio, int sectors, ...@@ -97,7 +98,7 @@ struct bio *bch_bio_split(struct bio *bio, int sectors,
if (!ret) if (!ret)
return NULL; return NULL;
memcpy(ret->bi_io_vec, bio_iovec(bio), memcpy(ret->bi_io_vec, __bio_iovec(bio),
sizeof(struct bio_vec) * vcnt); sizeof(struct bio_vec) * vcnt);
break; break;
...@@ -106,7 +107,7 @@ struct bio *bch_bio_split(struct bio *bio, int sectors, ...@@ -106,7 +107,7 @@ struct bio *bch_bio_split(struct bio *bio, int sectors,
if (!ret) if (!ret)
return NULL; return NULL;
memcpy(ret->bi_io_vec, bio_iovec(bio), memcpy(ret->bi_io_vec, __bio_iovec(bio),
sizeof(struct bio_vec) * vcnt); sizeof(struct bio_vec) * vcnt);
ret->bi_io_vec[vcnt - 1].bv_len = nbytes; ret->bi_io_vec[vcnt - 1].bv_len = nbytes;
...@@ -182,7 +183,7 @@ static unsigned bch_bio_max_sectors(struct bio *bio) ...@@ -182,7 +183,7 @@ static unsigned bch_bio_max_sectors(struct bio *bio)
ret = min(ret, queue_max_sectors(q)); ret = min(ret, queue_max_sectors(q));
WARN_ON(!ret); WARN_ON(!ret);
ret = max_t(int, ret, bio_iovec(bio)->bv_len >> 9); ret = max_t(int, ret, bio_iovec(bio).bv_len >> 9);
return ret; return ret;
} }
......
...@@ -524,7 +524,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio) ...@@ -524,7 +524,7 @@ static int verity_map(struct dm_target *ti, struct bio *bio)
io->io_vec = io->io_vec_inline; io->io_vec = io->io_vec_inline;
else else
io->io_vec = mempool_alloc(v->vec_mempool, GFP_NOIO); io->io_vec = mempool_alloc(v->vec_mempool, GFP_NOIO);
memcpy(io->io_vec, bio_iovec(bio), memcpy(io->io_vec, __bio_iovec(bio),
io->io_vec_size * sizeof(struct bio_vec)); io->io_vec_size * sizeof(struct bio_vec));
verity_submit_prefetch(v, io); verity_submit_prefetch(v, io);
......
...@@ -801,7 +801,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq) ...@@ -801,7 +801,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)
if (sdkp->device->no_write_same) if (sdkp->device->no_write_same)
return BLKPREP_KILL; return BLKPREP_KILL;
BUG_ON(bio_offset(bio) || bio_iovec(bio)->bv_len != sdp->sector_size); BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size);
sector >>= ilog2(sdp->sector_size) - 9; sector >>= ilog2(sdp->sector_size) - 9;
nr_sectors >>= ilog2(sdp->sector_size) - 9; nr_sectors >>= ilog2(sdp->sector_size) - 9;
......
...@@ -821,12 +821,12 @@ void bio_advance(struct bio *bio, unsigned bytes) ...@@ -821,12 +821,12 @@ void bio_advance(struct bio *bio, unsigned bytes)
break; break;
} }
if (bytes >= bio_iovec(bio)->bv_len) { if (bytes >= bio_iovec(bio).bv_len) {
bytes -= bio_iovec(bio)->bv_len; bytes -= bio_iovec(bio).bv_len;
bio->bi_iter.bi_idx++; bio->bi_iter.bi_idx++;
} else { } else {
bio_iovec(bio)->bv_len -= bytes; bio_iovec(bio).bv_len -= bytes;
bio_iovec(bio)->bv_offset += bytes; bio_iovec(bio).bv_offset += bytes;
bytes = 0; bytes = 0;
} }
} }
...@@ -879,8 +879,8 @@ void bio_copy_data(struct bio *dst, struct bio *src) ...@@ -879,8 +879,8 @@ void bio_copy_data(struct bio *dst, struct bio *src)
unsigned src_offset, dst_offset, bytes; unsigned src_offset, dst_offset, bytes;
void *src_p, *dst_p; void *src_p, *dst_p;
src_bv = bio_iovec(src); src_bv = __bio_iovec(src);
dst_bv = bio_iovec(dst); dst_bv = __bio_iovec(dst);
src_offset = src_bv->bv_offset; src_offset = src_bv->bv_offset;
dst_offset = dst_bv->bv_offset; dst_offset = dst_bv->bv_offset;
...@@ -893,7 +893,7 @@ void bio_copy_data(struct bio *dst, struct bio *src) ...@@ -893,7 +893,7 @@ void bio_copy_data(struct bio *dst, struct bio *src)
if (!src) if (!src)
break; break;
src_bv = bio_iovec(src); src_bv = __bio_iovec(src);
} }
src_offset = src_bv->bv_offset; src_offset = src_bv->bv_offset;
...@@ -906,7 +906,7 @@ void bio_copy_data(struct bio *dst, struct bio *src) ...@@ -906,7 +906,7 @@ void bio_copy_data(struct bio *dst, struct bio *src)
if (!dst) if (!dst)
break; break;
dst_bv = bio_iovec(dst); dst_bv = __bio_iovec(dst);
} }
dst_offset = dst_bv->bv_offset; dst_offset = dst_bv->bv_offset;
...@@ -1776,8 +1776,8 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) ...@@ -1776,8 +1776,8 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
bp->bio1.bi_iter.bi_size = first_sectors << 9; bp->bio1.bi_iter.bi_size = first_sectors << 9;
if (bi->bi_vcnt != 0) { if (bi->bi_vcnt != 0) {
bp->bv1 = *bio_iovec(bi); bp->bv1 = bio_iovec(bi);
bp->bv2 = *bio_iovec(bi); bp->bv2 = bio_iovec(bi);
if (bio_is_rw(bi)) { if (bio_is_rw(bi)) {
bp->bv2.bv_offset += first_sectors << 9; bp->bv2.bv_offset += first_sectors << 9;
......
...@@ -62,9 +62,11 @@ ...@@ -62,9 +62,11 @@
* on highmem page vectors * on highmem page vectors
*/ */
#define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)])) #define bio_iovec_idx(bio, idx) (&((bio)->bi_io_vec[(idx)]))
#define bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_iter.bi_idx) #define __bio_iovec(bio) bio_iovec_idx((bio), (bio)->bi_iter.bi_idx)
#define bio_page(bio) bio_iovec((bio))->bv_page #define bio_iovec(bio) (*__bio_iovec(bio))
#define bio_offset(bio) bio_iovec((bio))->bv_offset
#define bio_page(bio) (bio_iovec((bio)).bv_page)
#define bio_offset(bio) (bio_iovec((bio)).bv_offset)
#define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_iter.bi_idx) #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_iter.bi_idx)
#define bio_sectors(bio) ((bio)->bi_iter.bi_size >> 9) #define bio_sectors(bio) ((bio)->bi_iter.bi_size >> 9)
#define bio_end_sector(bio) ((bio)->bi_iter.bi_sector + bio_sectors((bio))) #define bio_end_sector(bio) ((bio)->bi_iter.bi_sector + bio_sectors((bio)))
...@@ -72,7 +74,7 @@ ...@@ -72,7 +74,7 @@
static inline unsigned int bio_cur_bytes(struct bio *bio) static inline unsigned int bio_cur_bytes(struct bio *bio)
{ {
if (bio->bi_vcnt) if (bio->bi_vcnt)
return bio_iovec(bio)->bv_len; return bio_iovec(bio).bv_len;
else /* dataless requests such as discard */ else /* dataless requests such as discard */
return bio->bi_iter.bi_size; return bio->bi_iter.bi_size;
} }
......
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