aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/rbd.c2
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--fs/bio.c12
-rw-r--r--fs/exofs/ore.c2
-rw-r--r--fs/exofs/ore_raid.c2
-rw-r--r--include/linux/bio.h17
-rw-r--r--mm/bounce.c2
7 files changed, 25 insertions, 14 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6c81a4c040b9..11e179826b60 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -952,7 +952,7 @@ static struct bio *bio_clone_range(struct bio *bio_src,
952 /* Find first affected segment... */ 952 /* Find first affected segment... */
953 953
954 resid = offset; 954 resid = offset;
955 __bio_for_each_segment(bv, bio_src, idx, 0) { 955 bio_for_each_segment(bv, bio_src, idx) {
956 if (resid < bv->bv_len) 956 if (resid < bv->bv_len)
957 break; 957 break;
958 resid -= bv->bv_len; 958 resid -= bv->bv_len;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 0a3988a25aab..853482015d3d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1291,7 +1291,7 @@ read_again:
1291 * know the original bi_idx, so we just free 1291 * know the original bi_idx, so we just free
1292 * them all 1292 * them all
1293 */ 1293 */
1294 __bio_for_each_segment(bvec, mbio, j, 0) 1294 bio_for_each_segment_all(bvec, mbio, j)
1295 bvec->bv_page = r1_bio->behind_bvecs[j].bv_page; 1295 bvec->bv_page = r1_bio->behind_bvecs[j].bv_page;
1296 if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags)) 1296 if (test_bit(WriteMostly, &conf->mirrors[i].rdev->flags))
1297 atomic_inc(&r1_bio->behind_remaining); 1297 atomic_inc(&r1_bio->behind_remaining);
diff --git a/fs/bio.c b/fs/bio.c
index e437f9aae67d..618f9044c414 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -961,7 +961,7 @@ static int __bio_copy_iov(struct bio *bio, struct bio_vec *iovecs,
961 int iov_idx = 0; 961 int iov_idx = 0;
962 unsigned int iov_off = 0; 962 unsigned int iov_off = 0;
963 963
964 __bio_for_each_segment(bvec, bio, i, 0) { 964 bio_for_each_segment_all(bvec, bio, i) {
965 char *bv_addr = page_address(bvec->bv_page); 965 char *bv_addr = page_address(bvec->bv_page);
966 unsigned int bv_len = iovecs[i].bv_len; 966 unsigned int bv_len = iovecs[i].bv_len;
967 967
@@ -1143,7 +1143,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
1143 return bio; 1143 return bio;
1144cleanup: 1144cleanup:
1145 if (!map_data) 1145 if (!map_data)
1146 bio_for_each_segment(bvec, bio, i) 1146 bio_for_each_segment_all(bvec, bio, i)
1147 __free_page(bvec->bv_page); 1147 __free_page(bvec->bv_page);
1148 1148
1149 bio_put(bio); 1149 bio_put(bio);
@@ -1357,7 +1357,7 @@ static void __bio_unmap_user(struct bio *bio)
1357 /* 1357 /*
1358 * make sure we dirty pages we wrote to 1358 * make sure we dirty pages we wrote to
1359 */ 1359 */
1360 __bio_for_each_segment(bvec, bio, i, 0) { 1360 bio_for_each_segment_all(bvec, bio, i) {
1361 if (bio_data_dir(bio) == READ) 1361 if (bio_data_dir(bio) == READ)
1362 set_page_dirty_lock(bvec->bv_page); 1362 set_page_dirty_lock(bvec->bv_page);
1363 1363
@@ -1463,7 +1463,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
1463 int i; 1463 int i;
1464 char *p = bmd->sgvecs[0].iov_base; 1464 char *p = bmd->sgvecs[0].iov_base;
1465 1465
1466 __bio_for_each_segment(bvec, bio, i, 0) { 1466 bio_for_each_segment_all(bvec, bio, i) {
1467 char *addr = page_address(bvec->bv_page); 1467 char *addr = page_address(bvec->bv_page);
1468 int len = bmd->iovecs[i].bv_len; 1468 int len = bmd->iovecs[i].bv_len;
1469 1469
@@ -1503,7 +1503,7 @@ struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len,
1503 if (!reading) { 1503 if (!reading) {
1504 void *p = data; 1504 void *p = data;
1505 1505
1506 bio_for_each_segment(bvec, bio, i) { 1506 bio_for_each_segment_all(bvec, bio, i) {
1507 char *addr = page_address(bvec->bv_page); 1507 char *addr = page_address(bvec->bv_page);
1508 1508
1509 memcpy(addr, p, bvec->bv_len); 1509 memcpy(addr, p, bvec->bv_len);
@@ -1789,7 +1789,7 @@ sector_t bio_sector_offset(struct bio *bio, unsigned short index,
1789 if (index >= bio->bi_idx) 1789 if (index >= bio->bi_idx)
1790 index = bio->bi_vcnt - 1; 1790 index = bio->bi_vcnt - 1;
1791 1791
1792 __bio_for_each_segment(bv, bio, i, 0) { 1792 bio_for_each_segment_all(bv, bio, i) {
1793 if (i == index) { 1793 if (i == index) {
1794 if (offset > bv->bv_offset) 1794 if (offset > bv->bv_offset)
1795 sectors += (offset - bv->bv_offset) / sector_sz; 1795 sectors += (offset - bv->bv_offset) / sector_sz;
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c
index f936cb50dc0d..b74422888604 100644
--- a/fs/exofs/ore.c
+++ b/fs/exofs/ore.c
@@ -401,7 +401,7 @@ static void _clear_bio(struct bio *bio)
401 struct bio_vec *bv; 401 struct bio_vec *bv;
402 unsigned i; 402 unsigned i;
403 403
404 __bio_for_each_segment(bv, bio, i, 0) { 404 bio_for_each_segment_all(bv, bio, i) {
405 unsigned this_count = bv->bv_len; 405 unsigned this_count = bv->bv_len;
406 406
407 if (likely(PAGE_SIZE == this_count)) 407 if (likely(PAGE_SIZE == this_count))
diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c
index b963f38ac298..7682b970d0f1 100644
--- a/fs/exofs/ore_raid.c
+++ b/fs/exofs/ore_raid.c
@@ -432,7 +432,7 @@ static void _mark_read4write_pages_uptodate(struct ore_io_state *ios, int ret)
432 if (!bio) 432 if (!bio)
433 continue; 433 continue;
434 434
435 __bio_for_each_segment(bv, bio, i, 0) { 435 bio_for_each_segment_all(bv, bio, i) {
436 struct page *page = bv->bv_page; 436 struct page *page = bv->bv_page;
437 437
438 SetPageUptodate(page); 438 SetPageUptodate(page);
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 90d36c65cb70..be2efa09f9bf 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -137,16 +137,27 @@ static inline int bio_has_allocated_vec(struct bio *bio)
137#define bio_io_error(bio) bio_endio((bio), -EIO) 137#define bio_io_error(bio) bio_endio((bio), -EIO)
138 138
139/* 139/*
140 * drivers should not use the __ version unless they _really_ want to 140 * drivers should not use the __ version unless they _really_ know what
141 * run through the entire bio and not just pending pieces 141 * they're doing
142 */ 142 */
143#define __bio_for_each_segment(bvl, bio, i, start_idx) \ 143#define __bio_for_each_segment(bvl, bio, i, start_idx) \
144 for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ 144 for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \
145 i < (bio)->bi_vcnt; \ 145 i < (bio)->bi_vcnt; \
146 bvl++, i++) 146 bvl++, i++)
147 147
148/*
149 * drivers should _never_ use the all version - the bio may have been split
150 * before it got to the driver and the driver won't own all of it
151 */
152#define bio_for_each_segment_all(bvl, bio, i) \
153 for (i = 0; \
154 bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \
155 i++)
156
148#define bio_for_each_segment(bvl, bio, i) \ 157#define bio_for_each_segment(bvl, bio, i) \
149 __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) 158 for (i = (bio)->bi_idx; \
159 bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \
160 i++)
150 161
151/* 162/*
152 * get a reference to a bio, so it won't disappear. the intended use is 163 * get a reference to a bio, so it won't disappear. the intended use is
diff --git a/mm/bounce.c b/mm/bounce.c
index 55f512af50c7..2ee1b6fef44a 100644
--- a/mm/bounce.c
+++ b/mm/bounce.c
@@ -134,7 +134,7 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)
134 /* 134 /*
135 * free up bounce indirect pages used 135 * free up bounce indirect pages used
136 */ 136 */
137 __bio_for_each_segment(bvec, bio, i, 0) { 137 bio_for_each_segment_all(bvec, bio, i) {
138 org_vec = bio_orig->bi_io_vec + i; 138 org_vec = bio_orig->bi_io_vec + i;
139 if (bvec->bv_page == org_vec->bv_page) 139 if (bvec->bv_page == org_vec->bv_page)
140 continue; 140 continue;