From 5496213aa34345eaeade5b5d662879ca553d7f76 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 7 Nov 2013 12:20:26 -0800 Subject: fs/mpage.c: Convert to use bio_for_each_segment() With immutable biovecs we don't want code accessing bi_io_vec directly - the uses this patch changes weren't incorrect since they all own the bio, but it makes the code harder to audit for no good reason - also, this will help with multipage bvecs later. Signed-off-by: Kent Overstreet Cc: Jens Axboe Cc: Alexander Viro Cc: Chris Mason Cc: Jaegeuk Kim Cc: Joern Engel Cc: Prasad Joshi Cc: Trond Myklebust Upstream 2c30c71bd653afcbed7f6754e8fe3d16e0e708a1. Patch applied just to fs/mpage.c for future merges. Signed-off-by: Park Ju Hyung Signed-off-by: Pranav Vashi --- fs/mpage.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index 4e15e652e..6d6699a25 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -43,16 +43,14 @@ */ static void mpage_end_io(struct bio *bio, int err) { - const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); - struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; + struct bio_vec *bv; + int i; - do { - struct page *page = bvec->bv_page; + bio_for_each_segment_all(bv, bio, i) { + struct page *page = bv->bv_page; - if (--bvec >= bio->bi_io_vec) - prefetchw(&bvec->bv_page->flags); if (bio_data_dir(bio) == READ) { - if (uptodate) { + if (!err) { SetPageUptodate(page); } else { ClearPageUptodate(page); @@ -60,14 +58,15 @@ static void mpage_end_io(struct bio *bio, int err) } unlock_page(page); } else { /* bio_data_dir(bio) == WRITE */ - if (!uptodate) { + if (err) { SetPageError(page); if (page->mapping) set_bit(AS_EIO, &page->mapping->flags); } end_page_writeback(page); } - } while (bvec >= bio->bi_io_vec); + } + bio_put(bio); } -- cgit v1.2.3