mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
block: rename bi_bvec_done
struct bvec_iter::bi_bvec_done is used an offset in the current bvec, let's rename it accordingly for better clarity. I also plan to use it for non-bvec based iteration in the future like dma-buf, so drop the "bvec" part. Suggested-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://patch.msgid.link/4e4c21858705a200bd8848ffe4080522e3eb5c1c.1786018753.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
a600051da1
commit
b539aeacf8
@@ -16,16 +16,16 @@ bv_len by the number of bytes completed in that biovec.
|
||||
In the new scheme of things, everything that must be mutated in order to
|
||||
partially complete a bio is segregated into struct bvec_iter: bi_sector,
|
||||
bi_size and bi_idx have been moved there; and instead of modifying bv_offset
|
||||
and bv_len, struct bvec_iter has bi_bvec_done, which represents the number of
|
||||
and bv_len, struct bvec_iter has bi_offset, which represents the number of
|
||||
bytes completed in the current bvec.
|
||||
|
||||
There are a bunch of new helper macros for hiding the gory details - in
|
||||
particular, presenting the illusion of partially completed biovecs so that
|
||||
normal code doesn't have to deal with bi_bvec_done.
|
||||
normal code doesn't have to deal with bi_offset.
|
||||
|
||||
* Driver code should no longer refer to biovecs directly; we now have
|
||||
bio_iovec() and bio_iter_iovec() macros that return literal struct biovecs,
|
||||
constructed from the raw biovecs but taking into account bi_bvec_done and
|
||||
constructed from the raw biovecs but taking into account bi_offset and
|
||||
bi_size.
|
||||
|
||||
bio_for_each_segment() has been updated to take a bvec_iter argument
|
||||
@@ -101,7 +101,7 @@ Other implications:
|
||||
I.e. instead of using bio_iovec_idx() (or bio->bi_iovec[bio->bi_idx]), you
|
||||
now use bio_iter_iovec(), which takes a bvec_iter and returns a
|
||||
literal struct bio_vec - constructed on the fly from the raw biovec but
|
||||
taking into account bi_bvec_done (and bi_size).
|
||||
taking into account bi_offset (and bi_size).
|
||||
|
||||
* bi_vcnt can't be trusted or relied upon by driver code - i.e. anything that
|
||||
doesn't actually own the bio. The reason is twofold: firstly, it's not
|
||||
|
||||
+2
-2
@@ -229,7 +229,7 @@ void bio_init(struct bio *bio, struct block_device *bdev, struct bio_vec *table,
|
||||
bio->bi_iter.bi_sector = 0;
|
||||
bio->bi_iter.bi_size = 0;
|
||||
bio->bi_iter.bi_idx = 0;
|
||||
bio->bi_iter.bi_bvec_done = 0;
|
||||
bio->bi_iter.bi_offset = 0;
|
||||
bio->bi_end_io = NULL;
|
||||
bio->bi_private = NULL;
|
||||
#ifdef CONFIG_BLK_CGROUP
|
||||
@@ -1188,7 +1188,7 @@ void bio_iov_bvec_set(struct bio *bio, const struct iov_iter *iter)
|
||||
|
||||
bio->bi_io_vec = (struct bio_vec *)iter->bvec;
|
||||
bio->bi_iter.bi_idx = 0;
|
||||
bio->bi_iter.bi_bvec_done = iter->iov_offset;
|
||||
bio->bi_iter.bi_offset = iter->iov_offset;
|
||||
bio->bi_iter.bi_size = iov_iter_count(iter);
|
||||
bio_set_flag(bio, BIO_CLONED);
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
|
||||
|
||||
bio_advance_iter(bio, &iter, iter.bi_size);
|
||||
|
||||
if (!iter.bi_bvec_done)
|
||||
if (!iter.bi_offset)
|
||||
idx = iter.bi_idx - 1;
|
||||
else /* in the middle of bvec */
|
||||
idx = iter.bi_idx;
|
||||
@@ -41,11 +41,11 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
|
||||
*bv = bio->bi_io_vec[idx];
|
||||
|
||||
/*
|
||||
* iter.bi_bvec_done records actual length of the last bvec
|
||||
* iter.bi_offset records actual length of the last bvec
|
||||
* if this bio ends in the middle of one io vector
|
||||
*/
|
||||
if (iter.bi_bvec_done)
|
||||
bv->bv_len = iter.bi_bvec_done;
|
||||
if (iter.bi_offset)
|
||||
bv->bv_len = iter.bi_offset;
|
||||
}
|
||||
|
||||
static inline bool bio_will_gap(struct request_queue *q,
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ static bool blk_map_iter_next(struct request *req, struct blk_map_iter *iter,
|
||||
* one could be merged into it. This typically happens when moving to
|
||||
* the next bio, but some callers also don't pack bvecs tight.
|
||||
*/
|
||||
while (!iter->iter.bi_size || !iter->iter.bi_bvec_done) {
|
||||
while (!iter->iter.bi_size || !iter->iter.bi_offset) {
|
||||
struct bio_vec next;
|
||||
|
||||
if (!__blk_map_iter_next(iter))
|
||||
|
||||
+1
-1
@@ -406,7 +406,7 @@ static inline bool bio_may_need_split(struct bio *bio,
|
||||
return true;
|
||||
|
||||
bv = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
|
||||
if (bio->bi_iter.bi_size > bv->bv_len - bio->bi_iter.bi_bvec_done)
|
||||
if (bio->bi_iter.bi_size > bv->bv_len - bio->bi_iter.bi_offset)
|
||||
return true;
|
||||
if ((bv->bv_offset | bv->bv_len) & lim->dma_alignment)
|
||||
return true;
|
||||
|
||||
@@ -379,7 +379,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
|
||||
iov_iter_bvec(&iter, rw,
|
||||
__bvec_iter_bvec(rq->bio->bi_io_vec, rq->bio->bi_iter),
|
||||
nr_bvec, blk_rq_bytes(rq));
|
||||
iter.iov_offset = rq->bio->bi_iter.bi_bvec_done;
|
||||
iter.iov_offset = rq->bio->bi_iter.bi_offset;
|
||||
}
|
||||
atomic_set(&cmd->ref, 2);
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ static int zloop_do_rw(struct zloop_cmd *cmd)
|
||||
iov_iter_bvec(&iter, rw,
|
||||
__bvec_iter_bvec(rq->bio->bi_io_vec, rq->bio->bi_iter),
|
||||
nr_bvec, blk_rq_bytes(rq));
|
||||
iter.iov_offset = rq->bio->bi_iter.bi_bvec_done;
|
||||
iter.iov_offset = rq->bio->bi_iter.bi_offset;
|
||||
}
|
||||
|
||||
cmd->iocb.ki_pos = (cmd->sector - zone->start) << SECTOR_SHIFT;
|
||||
|
||||
@@ -16,12 +16,12 @@ static inline bool dm_bvec_iter_rewind(const struct bio_vec *bv,
|
||||
int idx;
|
||||
|
||||
iter->bi_size += bytes;
|
||||
if (bytes <= iter->bi_bvec_done) {
|
||||
iter->bi_bvec_done -= bytes;
|
||||
if (bytes <= iter->bi_offset) {
|
||||
iter->bi_offset -= bytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
bytes -= iter->bi_bvec_done;
|
||||
bytes -= iter->bi_offset;
|
||||
idx = iter->bi_idx - 1;
|
||||
|
||||
while (idx >= 0 && bytes && bytes > bv[idx].bv_len) {
|
||||
@@ -32,13 +32,13 @@ static inline bool dm_bvec_iter_rewind(const struct bio_vec *bv,
|
||||
if (WARN_ONCE(idx < 0 && bytes,
|
||||
"Attempted to rewind iter beyond bvec's boundaries\n")) {
|
||||
iter->bi_size -= bytes;
|
||||
iter->bi_bvec_done = 0;
|
||||
iter->bi_offset = 0;
|
||||
iter->bi_idx = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
iter->bi_idx = idx;
|
||||
iter->bi_bvec_done = bv[idx].bv_len - bytes;
|
||||
iter->bi_offset = bv[idx].bv_len - bytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ int segment_copy_to_bio(struct pcache_segment *segment,
|
||||
|
||||
iov_iter_bvec(&iter, ITER_DEST, &bio->bi_io_vec[bio->bi_iter.bi_idx],
|
||||
bio_segments(bio), bio->bi_iter.bi_size);
|
||||
iter.iov_offset = bio->bi_iter.bi_bvec_done;
|
||||
iter.iov_offset = bio->bi_iter.bi_offset;
|
||||
if (bio_off)
|
||||
iov_iter_advance(&iter, bio_off);
|
||||
|
||||
@@ -35,7 +35,7 @@ int segment_copy_from_bio(struct pcache_segment *segment,
|
||||
|
||||
iov_iter_bvec(&iter, ITER_SOURCE, &bio->bi_io_vec[bio->bi_iter.bi_idx],
|
||||
bio_segments(bio), bio->bi_iter.bi_size);
|
||||
iter.iov_offset = bio->bi_iter.bi_bvec_done;
|
||||
iter.iov_offset = bio->bi_iter.bi_offset;
|
||||
if (bio_off)
|
||||
iov_iter_advance(&iter, bio_off);
|
||||
|
||||
|
||||
@@ -1155,7 +1155,7 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip,
|
||||
bv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter);
|
||||
/*
|
||||
* The 'bv' obtained from bvec_iter_bvec has its .bv_len and
|
||||
* .bv_offset already adjusted for iter->bi_bvec_done, and we
|
||||
* .bv_offset already adjusted for iter->bi_offset, and we
|
||||
* can use those directly
|
||||
*/
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ static void nvme_tcp_init_iter(struct nvme_tcp_request *req,
|
||||
iov_iter_bvec(&req->iter, dir,
|
||||
__bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter), nr_bvec,
|
||||
bio->bi_iter.bi_size);
|
||||
req->iter.iov_offset = bio->bi_iter.bi_bvec_done;
|
||||
req->iter.iov_offset = bio->bi_iter.bi_offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ static inline struct bvec_iter init_bvec_iter_for_bio(struct bio *bio)
|
||||
.bi_sector = 0,
|
||||
.bi_size = bio_size,
|
||||
.bi_idx = 0,
|
||||
.bi_bvec_done = 0,
|
||||
.bi_offset = 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ struct bvec_iter {
|
||||
/*
|
||||
* Current offset in the bvec entry pointed to by `bi_idx`.
|
||||
*/
|
||||
unsigned int bi_bvec_done;
|
||||
unsigned int bi_offset;
|
||||
} __packed __aligned(4);
|
||||
|
||||
struct bvec_iter_all {
|
||||
@@ -135,14 +135,14 @@ mp_bvec_iter_page(const struct bio_vec *bvecs, const struct bvec_iter iter)
|
||||
static __always_inline unsigned int
|
||||
mp_bvec_iter_len(const struct bio_vec *bvecs, const struct bvec_iter iter)
|
||||
{
|
||||
return min(__bvec_iter_bvec(bvecs, iter)->bv_len - iter.bi_bvec_done,
|
||||
return min(__bvec_iter_bvec(bvecs, iter)->bv_len - iter.bi_offset,
|
||||
iter.bi_size);
|
||||
}
|
||||
|
||||
static __always_inline unsigned int
|
||||
mp_bvec_iter_offset(const struct bio_vec *bvecs, const struct bvec_iter iter)
|
||||
{
|
||||
return __bvec_iter_bvec(bvecs, iter)->bv_offset + iter.bi_bvec_done;
|
||||
return __bvec_iter_bvec(bvecs, iter)->bv_offset + iter.bi_offset;
|
||||
}
|
||||
|
||||
static __always_inline unsigned int
|
||||
@@ -204,7 +204,7 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
|
||||
}
|
||||
|
||||
iter->bi_size -= bytes;
|
||||
bytes += iter->bi_bvec_done;
|
||||
bytes += iter->bi_offset;
|
||||
|
||||
while (bytes && bytes >= bv[idx].bv_len) {
|
||||
bytes -= bv[idx].bv_len;
|
||||
@@ -212,7 +212,7 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
|
||||
}
|
||||
|
||||
iter->bi_idx = idx;
|
||||
iter->bi_bvec_done = bytes;
|
||||
iter->bi_offset = bytes;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -223,13 +223,13 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
|
||||
static inline void bvec_iter_advance_single(const struct bio_vec *bv,
|
||||
struct bvec_iter *iter, unsigned int bytes)
|
||||
{
|
||||
unsigned int done = iter->bi_bvec_done + bytes;
|
||||
unsigned int done = iter->bi_offset + bytes;
|
||||
|
||||
if (done == bv[iter->bi_idx].bv_len) {
|
||||
done = 0;
|
||||
iter->bi_idx++;
|
||||
}
|
||||
iter->bi_bvec_done = done;
|
||||
iter->bi_offset = done;
|
||||
iter->bi_size -= bytes;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1470,7 +1470,7 @@ static int io_sg_from_iter(struct sk_buff *skb,
|
||||
return zerocopy_fill_skb_from_iter(skb, from, length);
|
||||
|
||||
bi.bi_size = min(from->count, length);
|
||||
bi.bi_bvec_done = from->iov_offset;
|
||||
bi.bi_offset = from->iov_offset;
|
||||
bi.bi_idx = 0;
|
||||
|
||||
while (bi.bi_size && frag < MAX_SKB_FRAGS) {
|
||||
@@ -1489,7 +1489,7 @@ static int io_sg_from_iter(struct sk_buff *skb,
|
||||
from->bvec += bi.bi_idx;
|
||||
from->nr_segs -= bi.bi_idx;
|
||||
from->count -= copied;
|
||||
from->iov_offset = bi.bi_bvec_done;
|
||||
from->iov_offset = bi.bi_offset;
|
||||
|
||||
skb->data_len += copied;
|
||||
skb->len += copied;
|
||||
|
||||
+1
-1
@@ -1634,7 +1634,7 @@ static ssize_t iov_iter_extract_bvec_pages(struct iov_iter *i,
|
||||
}
|
||||
bi.bi_idx = 0;
|
||||
bi.bi_size = maxsize;
|
||||
bi.bi_bvec_done = skip;
|
||||
bi.bi_offset = skip;
|
||||
|
||||
maxpages = want_pages_array(pages, maxsize, skip, maxpages);
|
||||
if (!maxpages)
|
||||
|
||||
@@ -762,7 +762,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor,
|
||||
if (!cursor->resid)
|
||||
return false; /* no more data */
|
||||
|
||||
if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done &&
|
||||
if (!bytes || (it->iter.bi_size && it->iter.bi_offset &&
|
||||
page == bio_iter_page(it->bio, it->iter)))
|
||||
return false; /* more bytes to process in this segment */
|
||||
|
||||
@@ -817,7 +817,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
|
||||
if (!cursor->resid)
|
||||
return false; /* no more data */
|
||||
|
||||
if (!bytes || (cursor->bvec_iter.bi_bvec_done &&
|
||||
if (!bytes || (cursor->bvec_iter.bi_offset &&
|
||||
page == bvec_iter_page(bvecs, cursor->bvec_iter)))
|
||||
return false; /* more bytes to process in this segment */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user