summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-04-25 03:03:00 -0400
committerJens Axboe <axboe@kernel.dk>2019-04-30 11:26:13 -0400
commit2b070cfe582b8e99fec6ada57d2e59e194aae202 (patch)
tree354961c24c2cc77cdaa66128c5f2a0997bc746e8
parentf936b06ae53815a7633b30ffd8cf5661ac826b3a (diff)
block: remove the i argument to bio_for_each_segment_all
We only have two callers that need the integer loop iterator, and they can easily maintain it themselves. Suggested-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Acked-by: David Sterba <dsterba@suse.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Acked-by: Coly Li <colyli@suse.de> Reviewed-by: Matthew Wilcox <willy@infradead.org> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/bio.c29
-rw-r--r--block/bounce.c3
-rw-r--r--drivers/md/bcache/btree.c3
-rw-r--r--drivers/md/dm-crypt.c3
-rw-r--r--drivers/md/raid1.c6
-rw-r--r--drivers/staging/erofs/data.c3
-rw-r--r--drivers/staging/erofs/unzip_vle.c3
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/btrfs/compression.c3
-rw-r--r--fs/btrfs/disk-io.c4
-rw-r--r--fs/btrfs/extent_io.c10
-rw-r--r--fs/btrfs/inode.c8
-rw-r--r--fs/btrfs/raid56.c3
-rw-r--r--fs/crypto/bio.c3
-rw-r--r--fs/direct-io.c3
-rw-r--r--fs/ext4/page-io.c3
-rw-r--r--fs/ext4/readpage.c3
-rw-r--r--fs/f2fs/data.c9
-rw-r--r--fs/gfs2/lops.c3
-rw-r--r--fs/gfs2/meta_io.c3
-rw-r--r--fs/iomap.c6
-rw-r--r--fs/mpage.c3
-rw-r--r--fs/xfs/xfs_aops.c3
-rw-r--r--include/linux/bio.h5
24 files changed, 47 insertions, 81 deletions
diff --git a/block/bio.c b/block/bio.c
index 662d45752ec5..9ad0d00cdc9b 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -874,9 +874,8 @@ static void bio_get_pages(struct bio *bio)
874{ 874{
875 struct bvec_iter_all iter_all; 875 struct bvec_iter_all iter_all;
876 struct bio_vec *bvec; 876 struct bio_vec *bvec;
877 int i;
878 877
879 bio_for_each_segment_all(bvec, bio, i, iter_all) 878 bio_for_each_segment_all(bvec, bio, iter_all)
880 get_page(bvec->bv_page); 879 get_page(bvec->bv_page);
881} 880}
882 881
@@ -884,9 +883,8 @@ static void bio_release_pages(struct bio *bio)
884{ 883{
885 struct bvec_iter_all iter_all; 884 struct bvec_iter_all iter_all;
886 struct bio_vec *bvec; 885 struct bio_vec *bvec;
887 int i;
888 886
889 bio_for_each_segment_all(bvec, bio, i, iter_all) 887 bio_for_each_segment_all(bvec, bio, iter_all)
890 put_page(bvec->bv_page); 888 put_page(bvec->bv_page);
891} 889}
892 890
@@ -1166,11 +1164,10 @@ static struct bio_map_data *bio_alloc_map_data(struct iov_iter *data,
1166 */ 1164 */
1167static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter) 1165static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter)
1168{ 1166{
1169 int i;
1170 struct bio_vec *bvec; 1167 struct bio_vec *bvec;
1171 struct bvec_iter_all iter_all; 1168 struct bvec_iter_all iter_all;
1172 1169
1173 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1170 bio_for_each_segment_all(bvec, bio, iter_all) {
1174 ssize_t ret; 1171 ssize_t ret;
1175 1172
1176 ret = copy_page_from_iter(bvec->bv_page, 1173 ret = copy_page_from_iter(bvec->bv_page,
@@ -1198,11 +1195,10 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter *iter)
1198 */ 1195 */
1199static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) 1196static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)
1200{ 1197{
1201 int i;
1202 struct bio_vec *bvec; 1198 struct bio_vec *bvec;
1203 struct bvec_iter_all iter_all; 1199 struct bvec_iter_all iter_all;
1204 1200
1205 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1201 bio_for_each_segment_all(bvec, bio, iter_all) {
1206 ssize_t ret; 1202 ssize_t ret;
1207 1203
1208 ret = copy_page_to_iter(bvec->bv_page, 1204 ret = copy_page_to_iter(bvec->bv_page,
@@ -1223,10 +1219,9 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter)
1223void bio_free_pages(struct bio *bio) 1219void bio_free_pages(struct bio *bio)
1224{ 1220{
1225 struct bio_vec *bvec; 1221 struct bio_vec *bvec;
1226 int i;
1227 struct bvec_iter_all iter_all; 1222 struct bvec_iter_all iter_all;
1228 1223
1229 bio_for_each_segment_all(bvec, bio, i, iter_all) 1224 bio_for_each_segment_all(bvec, bio, iter_all)
1230 __free_page(bvec->bv_page); 1225 __free_page(bvec->bv_page);
1231} 1226}
1232EXPORT_SYMBOL(bio_free_pages); 1227EXPORT_SYMBOL(bio_free_pages);
@@ -1464,7 +1459,7 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1464 return bio; 1459 return bio;
1465 1460
1466 out_unmap: 1461 out_unmap:
1467 bio_for_each_segment_all(bvec, bio, j, iter_all) { 1462 bio_for_each_segment_all(bvec, bio, iter_all) {
1468 put_page(bvec->bv_page); 1463 put_page(bvec->bv_page);
1469 } 1464 }
1470 bio_put(bio); 1465 bio_put(bio);
@@ -1474,13 +1469,12 @@ struct bio *bio_map_user_iov(struct request_queue *q,
1474static void __bio_unmap_user(struct bio *bio) 1469static void __bio_unmap_user(struct bio *bio)
1475{ 1470{
1476 struct bio_vec *bvec; 1471 struct bio_vec *bvec;
1477 int i;
1478 struct bvec_iter_all iter_all; 1472 struct bvec_iter_all iter_all;
1479 1473
1480 /* 1474 /*
1481 * make sure we dirty pages we wrote to 1475 * make sure we dirty pages we wrote to
1482 */ 1476 */
1483 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1477 bio_for_each_segment_all(bvec, bio, iter_all) {
1484 if (bio_data_dir(bio) == READ) 1478 if (bio_data_dir(bio) == READ)
1485 set_page_dirty_lock(bvec->bv_page); 1479 set_page_dirty_lock(bvec->bv_page);
1486 1480
@@ -1571,10 +1565,9 @@ static void bio_copy_kern_endio_read(struct bio *bio)
1571{ 1565{
1572 char *p = bio->bi_private; 1566 char *p = bio->bi_private;
1573 struct bio_vec *bvec; 1567 struct bio_vec *bvec;
1574 int i;
1575 struct bvec_iter_all iter_all; 1568 struct bvec_iter_all iter_all;
1576 1569
1577 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1570 bio_for_each_segment_all(bvec, bio, iter_all) {
1578 memcpy(p, page_address(bvec->bv_page), bvec->bv_len); 1571 memcpy(p, page_address(bvec->bv_page), bvec->bv_len);
1579 p += bvec->bv_len; 1572 p += bvec->bv_len;
1580 } 1573 }
@@ -1682,10 +1675,9 @@ cleanup:
1682void bio_set_pages_dirty(struct bio *bio) 1675void bio_set_pages_dirty(struct bio *bio)
1683{ 1676{
1684 struct bio_vec *bvec; 1677 struct bio_vec *bvec;
1685 int i;
1686 struct bvec_iter_all iter_all; 1678 struct bvec_iter_all iter_all;
1687 1679
1688 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1680 bio_for_each_segment_all(bvec, bio, iter_all) {
1689 if (!PageCompound(bvec->bv_page)) 1681 if (!PageCompound(bvec->bv_page))
1690 set_page_dirty_lock(bvec->bv_page); 1682 set_page_dirty_lock(bvec->bv_page);
1691 } 1683 }
@@ -1734,10 +1726,9 @@ void bio_check_pages_dirty(struct bio *bio)
1734{ 1726{
1735 struct bio_vec *bvec; 1727 struct bio_vec *bvec;
1736 unsigned long flags; 1728 unsigned long flags;
1737 int i;
1738 struct bvec_iter_all iter_all; 1729 struct bvec_iter_all iter_all;
1739 1730
1740 bio_for_each_segment_all(bvec, bio, i, iter_all) { 1731 bio_for_each_segment_all(bvec, bio, iter_all) {
1741 if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page)) 1732 if (!PageDirty(bvec->bv_page) && !PageCompound(bvec->bv_page))
1742 goto defer; 1733 goto defer;
1743 } 1734 }
diff --git a/block/bounce.c b/block/bounce.c
index 47eb7e936e22..f8ed677a1bf7 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -163,14 +163,13 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool)
163{ 163{
164 struct bio *bio_orig = bio->bi_private; 164 struct bio *bio_orig = bio->bi_private;
165 struct bio_vec *bvec, orig_vec; 165 struct bio_vec *bvec, orig_vec;
166 int i;
167 struct bvec_iter orig_iter = bio_orig->bi_iter; 166 struct bvec_iter orig_iter = bio_orig->bi_iter;
168 struct bvec_iter_all iter_all; 167 struct bvec_iter_all iter_all;
169 168
170 /* 169 /*
171 * free up bounce indirect pages used 170 * free up bounce indirect pages used
172 */ 171 */
173 bio_for_each_segment_all(bvec, bio, i, iter_all) { 172 bio_for_each_segment_all(bvec, bio, iter_all) {
174 orig_vec = bio_iter_iovec(bio_orig, orig_iter); 173 orig_vec = bio_iter_iovec(bio_orig, orig_iter);
175 if (bvec->bv_page != orig_vec.bv_page) { 174 if (bvec->bv_page != orig_vec.bv_page) {
176 dec_zone_page_state(bvec->bv_page, NR_BOUNCE); 175 dec_zone_page_state(bvec->bv_page, NR_BOUNCE);
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 3a9f8ed437de..773f5fdad25f 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -429,12 +429,11 @@ static void do_btree_node_write(struct btree *b)
429 bset_sector_offset(&b->keys, i)); 429 bset_sector_offset(&b->keys, i));
430 430
431 if (!bch_bio_alloc_pages(b->bio, __GFP_NOWARN|GFP_NOWAIT)) { 431 if (!bch_bio_alloc_pages(b->bio, __GFP_NOWARN|GFP_NOWAIT)) {
432 int j;
433 struct bio_vec *bv; 432 struct bio_vec *bv;
434 void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); 433 void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
435 struct bvec_iter_all iter_all; 434 struct bvec_iter_all iter_all;
436 435
437 bio_for_each_segment_all(bv, b->bio, j, iter_all) { 436 bio_for_each_segment_all(bv, b->bio, iter_all) {
438 memcpy(page_address(bv->bv_page), addr, PAGE_SIZE); 437 memcpy(page_address(bv->bv_page), addr, PAGE_SIZE);
439 addr += PAGE_SIZE; 438 addr += PAGE_SIZE;
440 } 439 }
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index dd6565798778..cca68546945b 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1445,11 +1445,10 @@ out:
1445 1445
1446static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone) 1446static void crypt_free_buffer_pages(struct crypt_config *cc, struct bio *clone)
1447{ 1447{
1448 unsigned int i;
1449 struct bio_vec *bv; 1448 struct bio_vec *bv;
1450 struct bvec_iter_all iter_all; 1449 struct bvec_iter_all iter_all;
1451 1450
1452 bio_for_each_segment_all(bv, clone, i, iter_all) { 1451 bio_for_each_segment_all(bv, clone, iter_all) {
1453 BUG_ON(!bv->bv_page); 1452 BUG_ON(!bv->bv_page);
1454 mempool_free(bv->bv_page, &cc->page_pool); 1453 mempool_free(bv->bv_page, &cc->page_pool);
1455 } 1454 }
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index fdf451aac369..0c8a098d220e 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2110,7 +2110,7 @@ static void process_checks(struct r1bio *r1_bio)
2110 } 2110 }
2111 r1_bio->read_disk = primary; 2111 r1_bio->read_disk = primary;
2112 for (i = 0; i < conf->raid_disks * 2; i++) { 2112 for (i = 0; i < conf->raid_disks * 2; i++) {
2113 int j; 2113 int j = 0;
2114 struct bio *pbio = r1_bio->bios[primary]; 2114 struct bio *pbio = r1_bio->bios[primary];
2115 struct bio *sbio = r1_bio->bios[i]; 2115 struct bio *sbio = r1_bio->bios[i];
2116 blk_status_t status = sbio->bi_status; 2116 blk_status_t status = sbio->bi_status;
@@ -2125,8 +2125,8 @@ static void process_checks(struct r1bio *r1_bio)
2125 /* Now we can 'fixup' the error value */ 2125 /* Now we can 'fixup' the error value */
2126 sbio->bi_status = 0; 2126 sbio->bi_status = 0;
2127 2127
2128 bio_for_each_segment_all(bi, sbio, j, iter_all) 2128 bio_for_each_segment_all(bi, sbio, iter_all)
2129 page_len[j] = bi->bv_len; 2129 page_len[j++] = bi->bv_len;
2130 2130
2131 if (!status) { 2131 if (!status) {
2132 for (j = vcnt; j-- ; ) { 2132 for (j = vcnt; j-- ; ) {
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 81af768e7248..9f04d7466c55 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -17,12 +17,11 @@
17 17
18static inline void read_endio(struct bio *bio) 18static inline void read_endio(struct bio *bio)
19{ 19{
20 int i;
21 struct bio_vec *bvec; 20 struct bio_vec *bvec;
22 const blk_status_t err = bio->bi_status; 21 const blk_status_t err = bio->bi_status;
23 struct bvec_iter_all iter_all; 22 struct bvec_iter_all iter_all;
24 23
25 bio_for_each_segment_all(bvec, bio, i, iter_all) { 24 bio_for_each_segment_all(bvec, bio, iter_all) {
26 struct page *page = bvec->bv_page; 25 struct page *page = bvec->bv_page;
27 26
28 /* page is already locked */ 27 /* page is already locked */
diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c
index 31eef8395774..59b9f37d5c00 100644
--- a/drivers/staging/erofs/unzip_vle.c
+++ b/drivers/staging/erofs/unzip_vle.c
@@ -844,14 +844,13 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios)
844static inline void z_erofs_vle_read_endio(struct bio *bio) 844static inline void z_erofs_vle_read_endio(struct bio *bio)
845{ 845{
846 const blk_status_t err = bio->bi_status; 846 const blk_status_t err = bio->bi_status;
847 unsigned int i;
848 struct bio_vec *bvec; 847 struct bio_vec *bvec;
849#ifdef EROFS_FS_HAS_MANAGED_CACHE 848#ifdef EROFS_FS_HAS_MANAGED_CACHE
850 struct address_space *mc = NULL; 849 struct address_space *mc = NULL;
851#endif 850#endif
852 struct bvec_iter_all iter_all; 851 struct bvec_iter_all iter_all;
853 852
854 bio_for_each_segment_all(bvec, bio, i, iter_all) { 853 bio_for_each_segment_all(bvec, bio, iter_all) {
855 struct page *page = bvec->bv_page; 854 struct page *page = bvec->bv_page;
856 bool cachemngd = false; 855 bool cachemngd = false;
857 856
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 24615c76c1d0..8abc6570d29f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -210,7 +210,6 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
210 struct bio bio; 210 struct bio bio;
211 ssize_t ret; 211 ssize_t ret;
212 blk_qc_t qc; 212 blk_qc_t qc;
213 int i;
214 struct bvec_iter_all iter_all; 213 struct bvec_iter_all iter_all;
215 214
216 if ((pos | iov_iter_alignment(iter)) & 215 if ((pos | iov_iter_alignment(iter)) &
@@ -261,7 +260,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
261 } 260 }
262 __set_current_state(TASK_RUNNING); 261 __set_current_state(TASK_RUNNING);
263 262
264 bio_for_each_segment_all(bvec, &bio, i, iter_all) { 263 bio_for_each_segment_all(bvec, &bio, iter_all) {
265 if (should_dirty && !PageCompound(bvec->bv_page)) 264 if (should_dirty && !PageCompound(bvec->bv_page))
266 set_page_dirty_lock(bvec->bv_page); 265 set_page_dirty_lock(bvec->bv_page);
267 put_page(bvec->bv_page); 266 put_page(bvec->bv_page);
@@ -339,9 +338,8 @@ static void blkdev_bio_end_io(struct bio *bio)
339 if (!bio_flagged(bio, BIO_NO_PAGE_REF)) { 338 if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
340 struct bvec_iter_all iter_all; 339 struct bvec_iter_all iter_all;
341 struct bio_vec *bvec; 340 struct bio_vec *bvec;
342 int i;
343 341
344 bio_for_each_segment_all(bvec, bio, i, iter_all) 342 bio_for_each_segment_all(bvec, bio, iter_all)
345 put_page(bvec->bv_page); 343 put_page(bvec->bv_page);
346 } 344 }
347 bio_put(bio); 345 bio_put(bio);
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 4f2a8ae0aa42..6313dc65209e 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -160,7 +160,6 @@ csum_failed:
160 if (cb->errors) { 160 if (cb->errors) {
161 bio_io_error(cb->orig_bio); 161 bio_io_error(cb->orig_bio);
162 } else { 162 } else {
163 int i;
164 struct bio_vec *bvec; 163 struct bio_vec *bvec;
165 struct bvec_iter_all iter_all; 164 struct bvec_iter_all iter_all;
166 165
@@ -169,7 +168,7 @@ csum_failed:
169 * checked so the end_io handlers know about it 168 * checked so the end_io handlers know about it
170 */ 169 */
171 ASSERT(!bio_flagged(bio, BIO_CLONED)); 170 ASSERT(!bio_flagged(bio, BIO_CLONED));
172 bio_for_each_segment_all(bvec, cb->orig_bio, i, iter_all) 171 bio_for_each_segment_all(bvec, cb->orig_bio, iter_all)
173 SetPageChecked(bvec->bv_page); 172 SetPageChecked(bvec->bv_page);
174 173
175 bio_endio(cb->orig_bio); 174 bio_endio(cb->orig_bio);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6fe9197f6ee4..c333e79408ff 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -832,11 +832,11 @@ static blk_status_t btree_csum_one_bio(struct bio *bio)
832{ 832{
833 struct bio_vec *bvec; 833 struct bio_vec *bvec;
834 struct btrfs_root *root; 834 struct btrfs_root *root;
835 int i, ret = 0; 835 int ret = 0;
836 struct bvec_iter_all iter_all; 836 struct bvec_iter_all iter_all;
837 837
838 ASSERT(!bio_flagged(bio, BIO_CLONED)); 838 ASSERT(!bio_flagged(bio, BIO_CLONED));
839 bio_for_each_segment_all(bvec, bio, i, iter_all) { 839 bio_for_each_segment_all(bvec, bio, iter_all) {
840 root = BTRFS_I(bvec->bv_page->mapping->host)->root; 840 root = BTRFS_I(bvec->bv_page->mapping->host)->root;
841 ret = csum_dirty_buffer(root->fs_info, bvec->bv_page); 841 ret = csum_dirty_buffer(root->fs_info, bvec->bv_page);
842 if (ret) 842 if (ret)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index ca8b8e785cf3..c85505c36fa6 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2451,11 +2451,10 @@ static void end_bio_extent_writepage(struct bio *bio)
2451 struct bio_vec *bvec; 2451 struct bio_vec *bvec;
2452 u64 start; 2452 u64 start;
2453 u64 end; 2453 u64 end;
2454 int i;
2455 struct bvec_iter_all iter_all; 2454 struct bvec_iter_all iter_all;
2456 2455
2457 ASSERT(!bio_flagged(bio, BIO_CLONED)); 2456 ASSERT(!bio_flagged(bio, BIO_CLONED));
2458 bio_for_each_segment_all(bvec, bio, i, iter_all) { 2457 bio_for_each_segment_all(bvec, bio, iter_all) {
2459 struct page *page = bvec->bv_page; 2458 struct page *page = bvec->bv_page;
2460 struct inode *inode = page->mapping->host; 2459 struct inode *inode = page->mapping->host;
2461 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 2460 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -2523,11 +2522,10 @@ static void end_bio_extent_readpage(struct bio *bio)
2523 u64 extent_len = 0; 2522 u64 extent_len = 0;
2524 int mirror; 2523 int mirror;
2525 int ret; 2524 int ret;
2526 int i;
2527 struct bvec_iter_all iter_all; 2525 struct bvec_iter_all iter_all;
2528 2526
2529 ASSERT(!bio_flagged(bio, BIO_CLONED)); 2527 ASSERT(!bio_flagged(bio, BIO_CLONED));
2530 bio_for_each_segment_all(bvec, bio, i, iter_all) { 2528 bio_for_each_segment_all(bvec, bio, iter_all) {
2531 struct page *page = bvec->bv_page; 2529 struct page *page = bvec->bv_page;
2532 struct inode *inode = page->mapping->host; 2530 struct inode *inode = page->mapping->host;
2533 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 2531 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -3643,11 +3641,11 @@ static void end_bio_extent_buffer_writepage(struct bio *bio)
3643{ 3641{
3644 struct bio_vec *bvec; 3642 struct bio_vec *bvec;
3645 struct extent_buffer *eb; 3643 struct extent_buffer *eb;
3646 int i, done; 3644 int done;
3647 struct bvec_iter_all iter_all; 3645 struct bvec_iter_all iter_all;
3648 3646
3649 ASSERT(!bio_flagged(bio, BIO_CLONED)); 3647 ASSERT(!bio_flagged(bio, BIO_CLONED));
3650 bio_for_each_segment_all(bvec, bio, i, iter_all) { 3648 bio_for_each_segment_all(bvec, bio, iter_all) {
3651 struct page *page = bvec->bv_page; 3649 struct page *page = bvec->bv_page;
3652 3650
3653 eb = (struct extent_buffer *)page->private; 3651 eb = (struct extent_buffer *)page->private;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 82fdda8ff5ab..10a8d08d3d29 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7828,7 +7828,6 @@ static void btrfs_retry_endio_nocsum(struct bio *bio)
7828 struct inode *inode = done->inode; 7828 struct inode *inode = done->inode;
7829 struct bio_vec *bvec; 7829 struct bio_vec *bvec;
7830 struct extent_io_tree *io_tree, *failure_tree; 7830 struct extent_io_tree *io_tree, *failure_tree;
7831 int i;
7832 struct bvec_iter_all iter_all; 7831 struct bvec_iter_all iter_all;
7833 7832
7834 if (bio->bi_status) 7833 if (bio->bi_status)
@@ -7841,7 +7840,7 @@ static void btrfs_retry_endio_nocsum(struct bio *bio)
7841 7840
7842 done->uptodate = 1; 7841 done->uptodate = 1;
7843 ASSERT(!bio_flagged(bio, BIO_CLONED)); 7842 ASSERT(!bio_flagged(bio, BIO_CLONED));
7844 bio_for_each_segment_all(bvec, bio, i, iter_all) 7843 bio_for_each_segment_all(bvec, bio, iter_all)
7845 clean_io_failure(BTRFS_I(inode)->root->fs_info, failure_tree, 7844 clean_io_failure(BTRFS_I(inode)->root->fs_info, failure_tree,
7846 io_tree, done->start, bvec->bv_page, 7845 io_tree, done->start, bvec->bv_page,
7847 btrfs_ino(BTRFS_I(inode)), 0); 7846 btrfs_ino(BTRFS_I(inode)), 0);
@@ -7919,7 +7918,7 @@ static void btrfs_retry_endio(struct bio *bio)
7919 struct bio_vec *bvec; 7918 struct bio_vec *bvec;
7920 int uptodate; 7919 int uptodate;
7921 int ret; 7920 int ret;
7922 int i; 7921 int i = 0;
7923 struct bvec_iter_all iter_all; 7922 struct bvec_iter_all iter_all;
7924 7923
7925 if (bio->bi_status) 7924 if (bio->bi_status)
@@ -7934,7 +7933,7 @@ static void btrfs_retry_endio(struct bio *bio)
7934 failure_tree = &BTRFS_I(inode)->io_failure_tree; 7933 failure_tree = &BTRFS_I(inode)->io_failure_tree;
7935 7934
7936 ASSERT(!bio_flagged(bio, BIO_CLONED)); 7935 ASSERT(!bio_flagged(bio, BIO_CLONED));
7937 bio_for_each_segment_all(bvec, bio, i, iter_all) { 7936 bio_for_each_segment_all(bvec, bio, iter_all) {
7938 ret = __readpage_endio_check(inode, io_bio, i, bvec->bv_page, 7937 ret = __readpage_endio_check(inode, io_bio, i, bvec->bv_page,
7939 bvec->bv_offset, done->start, 7938 bvec->bv_offset, done->start,
7940 bvec->bv_len); 7939 bvec->bv_len);
@@ -7946,6 +7945,7 @@ static void btrfs_retry_endio(struct bio *bio)
7946 bvec->bv_offset); 7945 bvec->bv_offset);
7947 else 7946 else
7948 uptodate = 0; 7947 uptodate = 0;
7948 i++;
7949 } 7949 }
7950 7950
7951 done->uptodate = uptodate; 7951 done->uptodate = uptodate;
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index 67a6f7d47402..f3d0576dd327 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1442,12 +1442,11 @@ static int fail_bio_stripe(struct btrfs_raid_bio *rbio,
1442static void set_bio_pages_uptodate(struct bio *bio) 1442static void set_bio_pages_uptodate(struct bio *bio)
1443{ 1443{
1444 struct bio_vec *bvec; 1444 struct bio_vec *bvec;
1445 int i;
1446 struct bvec_iter_all iter_all; 1445 struct bvec_iter_all iter_all;
1447 1446
1448 ASSERT(!bio_flagged(bio, BIO_CLONED)); 1447 ASSERT(!bio_flagged(bio, BIO_CLONED));
1449 1448
1450 bio_for_each_segment_all(bvec, bio, i, iter_all) 1449 bio_for_each_segment_all(bvec, bio, iter_all)
1451 SetPageUptodate(bvec->bv_page); 1450 SetPageUptodate(bvec->bv_page);
1452} 1451}
1453 1452
diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c
index 5759bcd018cd..8f3a8bc15d98 100644
--- a/fs/crypto/bio.c
+++ b/fs/crypto/bio.c
@@ -29,10 +29,9 @@
29static void __fscrypt_decrypt_bio(struct bio *bio, bool done) 29static void __fscrypt_decrypt_bio(struct bio *bio, bool done)
30{ 30{
31 struct bio_vec *bv; 31 struct bio_vec *bv;
32 int i;
33 struct bvec_iter_all iter_all; 32 struct bvec_iter_all iter_all;
34 33
35 bio_for_each_segment_all(bv, bio, i, iter_all) { 34 bio_for_each_segment_all(bv, bio, iter_all) {
36 struct page *page = bv->bv_page; 35 struct page *page = bv->bv_page;
37 int ret = fscrypt_decrypt_page(page->mapping->host, page, 36 int ret = fscrypt_decrypt_page(page->mapping->host, page,
38 PAGE_SIZE, 0, page->index); 37 PAGE_SIZE, 0, page->index);
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 9bb015bc4a83..fbe885d68035 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -538,7 +538,6 @@ static struct bio *dio_await_one(struct dio *dio)
538static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio) 538static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
539{ 539{
540 struct bio_vec *bvec; 540 struct bio_vec *bvec;
541 unsigned i;
542 blk_status_t err = bio->bi_status; 541 blk_status_t err = bio->bi_status;
543 542
544 if (err) { 543 if (err) {
@@ -553,7 +552,7 @@ static blk_status_t dio_bio_complete(struct dio *dio, struct bio *bio)
553 } else { 552 } else {
554 struct bvec_iter_all iter_all; 553 struct bvec_iter_all iter_all;
555 554
556 bio_for_each_segment_all(bvec, bio, i, iter_all) { 555 bio_for_each_segment_all(bvec, bio, iter_all) {
557 struct page *page = bvec->bv_page; 556 struct page *page = bvec->bv_page;
558 557
559 if (dio->op == REQ_OP_READ && !PageCompound(page) && 558 if (dio->op == REQ_OP_READ && !PageCompound(page) &&
diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 3e9298e6a705..4690618a92e9 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -61,11 +61,10 @@ static void buffer_io_error(struct buffer_head *bh)
61 61
62static void ext4_finish_bio(struct bio *bio) 62static void ext4_finish_bio(struct bio *bio)
63{ 63{
64 int i;
65 struct bio_vec *bvec; 64 struct bio_vec *bvec;
66 struct bvec_iter_all iter_all; 65 struct bvec_iter_all iter_all;
67 66
68 bio_for_each_segment_all(bvec, bio, i, iter_all) { 67 bio_for_each_segment_all(bvec, bio, iter_all) {
69 struct page *page = bvec->bv_page; 68 struct page *page = bvec->bv_page;
70#ifdef CONFIG_FS_ENCRYPTION 69#ifdef CONFIG_FS_ENCRYPTION
71 struct page *data_page = NULL; 70 struct page *data_page = NULL;
diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
index 3adadf461825..3629a74b7f94 100644
--- a/fs/ext4/readpage.c
+++ b/fs/ext4/readpage.c
@@ -71,7 +71,6 @@ static inline bool ext4_bio_encrypted(struct bio *bio)
71static void mpage_end_io(struct bio *bio) 71static void mpage_end_io(struct bio *bio)
72{ 72{
73 struct bio_vec *bv; 73 struct bio_vec *bv;
74 int i;
75 struct bvec_iter_all iter_all; 74 struct bvec_iter_all iter_all;
76 75
77 if (ext4_bio_encrypted(bio)) { 76 if (ext4_bio_encrypted(bio)) {
@@ -82,7 +81,7 @@ static void mpage_end_io(struct bio *bio)
82 return; 81 return;
83 } 82 }
84 } 83 }
85 bio_for_each_segment_all(bv, bio, i, iter_all) { 84 bio_for_each_segment_all(bv, bio, iter_all) {
86 struct page *page = bv->bv_page; 85 struct page *page = bv->bv_page;
87 86
88 if (!bio->bi_status) { 87 if (!bio->bi_status) {
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9727944139f2..64040e998439 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -86,10 +86,9 @@ static void __read_end_io(struct bio *bio)
86{ 86{
87 struct page *page; 87 struct page *page;
88 struct bio_vec *bv; 88 struct bio_vec *bv;
89 int i;
90 struct bvec_iter_all iter_all; 89 struct bvec_iter_all iter_all;
91 90
92 bio_for_each_segment_all(bv, bio, i, iter_all) { 91 bio_for_each_segment_all(bv, bio, iter_all) {
93 page = bv->bv_page; 92 page = bv->bv_page;
94 93
95 /* PG_error was set if any post_read step failed */ 94 /* PG_error was set if any post_read step failed */
@@ -164,7 +163,6 @@ static void f2fs_write_end_io(struct bio *bio)
164{ 163{
165 struct f2fs_sb_info *sbi = bio->bi_private; 164 struct f2fs_sb_info *sbi = bio->bi_private;
166 struct bio_vec *bvec; 165 struct bio_vec *bvec;
167 int i;
168 struct bvec_iter_all iter_all; 166 struct bvec_iter_all iter_all;
169 167
170 if (time_to_inject(sbi, FAULT_WRITE_IO)) { 168 if (time_to_inject(sbi, FAULT_WRITE_IO)) {
@@ -172,7 +170,7 @@ static void f2fs_write_end_io(struct bio *bio)
172 bio->bi_status = BLK_STS_IOERR; 170 bio->bi_status = BLK_STS_IOERR;
173 } 171 }
174 172
175 bio_for_each_segment_all(bvec, bio, i, iter_all) { 173 bio_for_each_segment_all(bvec, bio, iter_all) {
176 struct page *page = bvec->bv_page; 174 struct page *page = bvec->bv_page;
177 enum count_type type = WB_DATA_TYPE(page); 175 enum count_type type = WB_DATA_TYPE(page);
178 176
@@ -349,7 +347,6 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
349{ 347{
350 struct bio_vec *bvec; 348 struct bio_vec *bvec;
351 struct page *target; 349 struct page *target;
352 int i;
353 struct bvec_iter_all iter_all; 350 struct bvec_iter_all iter_all;
354 351
355 if (!io->bio) 352 if (!io->bio)
@@ -358,7 +355,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
358 if (!inode && !page && !ino) 355 if (!inode && !page && !ino)
359 return true; 356 return true;
360 357
361 bio_for_each_segment_all(bvec, io->bio, i, iter_all) { 358 bio_for_each_segment_all(bvec, io->bio, iter_all) {
362 359
363 if (bvec->bv_page->mapping) 360 if (bvec->bv_page->mapping)
364 target = bvec->bv_page; 361 target = bvec->bv_page;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 8722c60b11fe..6f09b5e3dd6e 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -207,7 +207,6 @@ static void gfs2_end_log_write(struct bio *bio)
207 struct gfs2_sbd *sdp = bio->bi_private; 207 struct gfs2_sbd *sdp = bio->bi_private;
208 struct bio_vec *bvec; 208 struct bio_vec *bvec;
209 struct page *page; 209 struct page *page;
210 int i;
211 struct bvec_iter_all iter_all; 210 struct bvec_iter_all iter_all;
212 211
213 if (bio->bi_status) { 212 if (bio->bi_status) {
@@ -216,7 +215,7 @@ static void gfs2_end_log_write(struct bio *bio)
216 wake_up(&sdp->sd_logd_waitq); 215 wake_up(&sdp->sd_logd_waitq);
217 } 216 }
218 217
219 bio_for_each_segment_all(bvec, bio, i, iter_all) { 218 bio_for_each_segment_all(bvec, bio, iter_all) {
220 page = bvec->bv_page; 219 page = bvec->bv_page;
221 if (page_has_buffers(page)) 220 if (page_has_buffers(page))
222 gfs2_end_log_write_bh(sdp, bvec, bio->bi_status); 221 gfs2_end_log_write_bh(sdp, bvec, bio->bi_status);
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 3201342404a7..ff86e1d4f8ff 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -189,10 +189,9 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
189static void gfs2_meta_read_endio(struct bio *bio) 189static void gfs2_meta_read_endio(struct bio *bio)
190{ 190{
191 struct bio_vec *bvec; 191 struct bio_vec *bvec;
192 int i;
193 struct bvec_iter_all iter_all; 192 struct bvec_iter_all iter_all;
194 193
195 bio_for_each_segment_all(bvec, bio, i, iter_all) { 194 bio_for_each_segment_all(bvec, bio, iter_all) {
196 struct page *page = bvec->bv_page; 195 struct page *page = bvec->bv_page;
197 struct buffer_head *bh = page_buffers(page); 196 struct buffer_head *bh = page_buffers(page);
198 unsigned int len = bvec->bv_len; 197 unsigned int len = bvec->bv_len;
diff --git a/fs/iomap.c b/fs/iomap.c
index abdd18e404f8..12a656271076 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -273,10 +273,9 @@ iomap_read_end_io(struct bio *bio)
273{ 273{
274 int error = blk_status_to_errno(bio->bi_status); 274 int error = blk_status_to_errno(bio->bi_status);
275 struct bio_vec *bvec; 275 struct bio_vec *bvec;
276 int i;
277 struct bvec_iter_all iter_all; 276 struct bvec_iter_all iter_all;
278 277
279 bio_for_each_segment_all(bvec, bio, i, iter_all) 278 bio_for_each_segment_all(bvec, bio, iter_all)
280 iomap_read_page_end_io(bvec, error); 279 iomap_read_page_end_io(bvec, error);
281 bio_put(bio); 280 bio_put(bio);
282} 281}
@@ -1592,9 +1591,8 @@ static void iomap_dio_bio_end_io(struct bio *bio)
1592 if (!bio_flagged(bio, BIO_NO_PAGE_REF)) { 1591 if (!bio_flagged(bio, BIO_NO_PAGE_REF)) {
1593 struct bvec_iter_all iter_all; 1592 struct bvec_iter_all iter_all;
1594 struct bio_vec *bvec; 1593 struct bio_vec *bvec;
1595 int i;
1596 1594
1597 bio_for_each_segment_all(bvec, bio, i, iter_all) 1595 bio_for_each_segment_all(bvec, bio, iter_all)
1598 put_page(bvec->bv_page); 1596 put_page(bvec->bv_page);
1599 } 1597 }
1600 bio_put(bio); 1598 bio_put(bio);
diff --git a/fs/mpage.c b/fs/mpage.c
index 3f19da75178b..436a85260394 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -47,10 +47,9 @@
47static void mpage_end_io(struct bio *bio) 47static void mpage_end_io(struct bio *bio)
48{ 48{
49 struct bio_vec *bv; 49 struct bio_vec *bv;
50 int i;
51 struct bvec_iter_all iter_all; 50 struct bvec_iter_all iter_all;
52 51
53 bio_for_each_segment_all(bv, bio, i, iter_all) { 52 bio_for_each_segment_all(bv, bio, iter_all) {
54 struct page *page = bv->bv_page; 53 struct page *page = bv->bv_page;
55 page_endio(page, bio_op(bio), 54 page_endio(page, bio_op(bio),
56 blk_status_to_errno(bio->bi_status)); 55 blk_status_to_errno(bio->bi_status));
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 3619e9e8d359..47941bbaac02 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -98,7 +98,6 @@ xfs_destroy_ioend(
98 98
99 for (bio = &ioend->io_inline_bio; bio; bio = next) { 99 for (bio = &ioend->io_inline_bio; bio; bio = next) {
100 struct bio_vec *bvec; 100 struct bio_vec *bvec;
101 int i;
102 struct bvec_iter_all iter_all; 101 struct bvec_iter_all iter_all;
103 102
104 /* 103 /*
@@ -111,7 +110,7 @@ xfs_destroy_ioend(
111 next = bio->bi_private; 110 next = bio->bi_private;
112 111
113 /* walk each page on bio, ending page IO on them */ 112 /* walk each page on bio, ending page IO on them */
114 bio_for_each_segment_all(bvec, bio, i, iter_all) 113 bio_for_each_segment_all(bvec, bio, iter_all)
115 xfs_finish_page_writeback(inode, bvec, error); 114 xfs_finish_page_writeback(inode, bvec, error);
116 bio_put(bio); 115 bio_put(bio);
117 } 116 }
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 9577ad8f6e28..186b2723c61b 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -134,9 +134,8 @@ static inline bool bio_next_segment(const struct bio *bio,
134 * drivers should _never_ use the all version - the bio may have been split 134 * drivers should _never_ use the all version - the bio may have been split
135 * before it got to the driver and the driver won't own all of it 135 * before it got to the driver and the driver won't own all of it
136 */ 136 */
137#define bio_for_each_segment_all(bvl, bio, i, iter) \ 137#define bio_for_each_segment_all(bvl, bio, iter) \
138 for (i = 0, bvl = bvec_init_iter_all(&iter); \ 138 for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); )
139 bio_next_segment((bio), &iter); i++)
140 139
141static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter, 140static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,
142 unsigned bytes) 141 unsigned bytes)