@@ -120,7 +120,7 @@ ForEachMacros:
- 'for_each_available_child_of_node'
- 'for_each_bio'
- 'for_each_board_func_rsrc'
- - 'for_each_bvec'
+ - 'for_each_segment'
- 'for_each_child_of_node'
- 'for_each_clear_bit'
- 'for_each_clear_bit_from'
@@ -1574,7 +1574,7 @@ static bool __journal_read_write(struct dm_integrity_io *dio, struct bio *bio,
char *tag_ptr = journal_entry_tag(ic, je);
if (bip) do {
- struct bio_vec biv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter);
+ struct bio_vec biv = segment_iter_bvec(bip->bip_vec, bip->bip_iter);
unsigned tag_now = min(biv.bv_len, tag_todo);
char *tag_addr;
BUG_ON(PageHighMem(biv.bv_page));
@@ -208,8 +208,8 @@ static void list_dp_init(struct dpages *dp, struct page_list *pl, unsigned offse
static void bio_get_page(struct dpages *dp, struct page **p,
unsigned long *len, unsigned *offset)
{
- struct bio_vec bvec = bvec_iter_bvec((struct bio_vec *)dp->context_ptr,
- dp->context_bi);
+ struct bio_vec bvec = segment_iter_bvec((struct bio_vec *)dp->context_ptr,
+ dp->context_bi);
*p = bvec.bv_page;
*len = bvec.bv_len;
@@ -89,9 +89,9 @@ static int nd_blk_rw_integrity(struct nd_namespace_blk *nsblk,
struct bio_vec bv;
void *iobuf;
- bv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter);
+ bv = segment_iter_bvec(bip->bip_vec, bip->bip_iter);
/*
- * The 'bv' obtained from bvec_iter_bvec has its .bv_len and
+ * The 'bv' obtained from segment_iter_bvec has its .bv_len and
* .bv_offset already adjusted for iter->bi_bvec_done, and we
* can use those directly
*/
@@ -1154,9 +1154,9 @@ static int btt_rw_integrity(struct btt *btt, struct bio_integrity_payload *bip,
struct bio_vec bv;
void *mem;
- bv = bvec_iter_bvec(bip->bip_vec, bip->bip_iter);
+ bv = segment_iter_bvec(bip->bip_vec, bip->bip_iter);
/*
- * The 'bv' obtained from bvec_iter_bvec has its .bv_len and
+ * The 'bv' obtained from segment_iter_bvec has its .bv_len and
* .bv_offset already adjusted for iter->bi_bvec_done, and we
* can use those directly
*/
@@ -48,14 +48,14 @@
#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio)
#define bio_iter_iovec(bio, iter) \
- bvec_iter_bvec((bio)->bi_io_vec, (iter))
+ segment_iter_bvec((bio)->bi_io_vec, (iter))
#define bio_iter_page(bio, iter) \
- bvec_iter_page((bio)->bi_io_vec, (iter))
+ segment_iter_page((bio)->bi_io_vec, (iter))
#define bio_iter_len(bio, iter) \
- bvec_iter_len((bio)->bi_io_vec, (iter))
+ segment_iter_len((bio)->bi_io_vec, (iter))
#define bio_iter_offset(bio, iter) \
- bvec_iter_offset((bio)->bi_io_vec, (iter))
+ segment_iter_offset((bio)->bi_io_vec, (iter))
#define bio_page(bio) bio_iter_page((bio), (bio)->bi_iter)
#define bio_offset(bio) bio_iter_offset((bio), (bio)->bi_iter)
@@ -733,7 +733,7 @@ static inline bool bioset_initialized(struct bio_set *bs)
#if defined(CONFIG_BLK_DEV_INTEGRITY)
#define bip_for_each_vec(bvl, bip, iter) \
- for_each_bvec(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
+ for_each_segment(bvl, (bip)->bip_vec, iter, (bip)->bip_iter)
#define bio_for_each_integrity_vec(_bvl, _bio, _iter) \
for_each_bio(_bio) \
@@ -50,23 +50,25 @@ struct bvec_iter {
*/
#define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx])
-#define bvec_iter_page(bvec, iter) \
+#define segment_iter_page(bvec, iter) \
(__bvec_iter_bvec((bvec), (iter))->bv_page)
-#define bvec_iter_len(bvec, iter) \
+#define segment_iter_len(bvec, iter) \
min((iter).bi_size, \
__bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done)
-#define bvec_iter_offset(bvec, iter) \
+#define segment_iter_offset(bvec, iter) \
(__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done)
-#define bvec_iter_bvec(bvec, iter) \
+#define segment_iter_bvec(bvec, iter) \
((struct bio_vec) { \
- .bv_page = bvec_iter_page((bvec), (iter)), \
- .bv_len = bvec_iter_len((bvec), (iter)), \
- .bv_offset = bvec_iter_offset((bvec), (iter)), \
+ .bv_page = segment_iter_page((bvec), (iter)), \
+ .bv_len = segment_iter_len((bvec), (iter)), \
+ .bv_offset = segment_iter_offset((bvec), (iter)), \
})
+#define bvec_iter_len segment_iter_len
+
static inline bool bvec_iter_advance(const struct bio_vec *bv,
struct bvec_iter *iter, unsigned bytes)
{
@@ -92,10 +94,10 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
return true;
}
-#define for_each_bvec(bvl, bio_vec, iter, start) \
+#define for_each_segment(bvl, bio_vec, iter, start) \
for (iter = (start); \
(iter).bi_size && \
- ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
+ ((bvl = segment_iter_bvec((bio_vec), (iter))), 1); \
bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
/* for iterating one bio from start to end */
@@ -155,7 +155,7 @@ struct ceph_bvec_iter {
\
__cur_iter = (it)->iter; \
__cur_iter.bi_size = (n); \
- for_each_bvec(bv, (it)->bvecs, __cur_iter, __cur_iter) \
+ for_each_segment(bv, (it)->bvecs, __cur_iter, __cur_iter) \
(void)(BVEC_STEP); \
}))
@@ -65,7 +65,7 @@
__start.bi_size = n; \
__start.bi_bvec_done = skip; \
__start.bi_idx = 0; \
- for_each_bvec(__v, i->bvec, __bi, __start) { \
+ for_each_segment(__v, i->bvec, __bi, __start) { \
if (!__v.bv_len) \
continue; \
(void)(STEP); \
@@ -889,17 +889,17 @@ static void ceph_msg_data_bvecs_cursor_init(struct ceph_msg_data_cursor *cursor,
cursor->bvec_iter = data->bvec_pos.iter;
cursor->bvec_iter.bi_size = cursor->resid;
- BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter));
+ BUG_ON(cursor->resid < segment_iter_len(bvecs, cursor->bvec_iter));
cursor->last_piece =
- cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter);
+ cursor->resid == segment_iter_len(bvecs, cursor->bvec_iter);
}
static struct page *ceph_msg_data_bvecs_next(struct ceph_msg_data_cursor *cursor,
size_t *page_offset,
size_t *length)
{
- struct bio_vec bv = bvec_iter_bvec(cursor->data->bvec_pos.bvecs,
- cursor->bvec_iter);
+ struct bio_vec bv = segment_iter_bvec(cursor->data->bvec_pos.bvecs,
+ cursor->bvec_iter);
*page_offset = bv.bv_offset;
*length = bv.bv_len;
@@ -912,7 +912,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs;
BUG_ON(bytes > cursor->resid);
- BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter));
+ BUG_ON(bytes > segment_iter_len(bvecs, cursor->bvec_iter));
cursor->resid -= bytes;
bvec_iter_advance(bvecs, &cursor->bvec_iter, bytes);
@@ -925,9 +925,9 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor,
return false; /* more bytes to process in this segment */
BUG_ON(cursor->last_piece);
- BUG_ON(cursor->resid < bvec_iter_len(bvecs, cursor->bvec_iter));
+ BUG_ON(cursor->resid < segment_iter_len(bvecs, cursor->bvec_iter));
cursor->last_piece =
- cursor->resid == bvec_iter_len(bvecs, cursor->bvec_iter);
+ cursor->resid == segment_iter_len(bvecs, cursor->bvec_iter);
return true;
}
We will support multi-page bvec soon, and have to deal with single-page vs multi-page bvec. This patch follows Christoph's suggestion to rename all the following helpers: for_each_bvec bvec_iter_bvec bvec_iter_len bvec_iter_page bvec_iter_offset into: for_each_segment segment_iter_bvec segment_iter_len segment_iter_page segment_iter_offset so that these helpers named with 'segment' only deal with single-page bvec, or called segment. We will introduce helpers named with 'bvec' for multi-page bvec. bvec_iter_advance() isn't renamed becasue this helper is always operated on real bvec even though multi-page bvec is supported. Suggested-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> --- .clang-format | 2 +- drivers/md/dm-integrity.c | 2 +- drivers/md/dm-io.c | 4 ++-- drivers/nvdimm/blk.c | 4 ++-- drivers/nvdimm/btt.c | 4 ++-- include/linux/bio.h | 10 +++++----- include/linux/bvec.h | 20 +++++++++++--------- include/linux/ceph/messenger.h | 2 +- lib/iov_iter.c | 2 +- net/ceph/messenger.c | 14 +++++++------- 10 files changed, 33 insertions(+), 31 deletions(-)