diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-11-07 15:20:26 -0500 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 01:33:46 -0500 |
commit | 2c30c71bd653afcbed7f6754e8fe3d16e0e708a1 (patch) | |
tree | a6b1147e4302b7216600c397cb47ca7f7f375a43 /fs/mpage.c | |
parent | 33879d4512c021ae65be9706608dacb36b4687b1 (diff) |
block: Convert various code to 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 <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Chris Mason <chris.mason@fusionio.com>
Cc: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Cc: Joern Engel <joern@logfs.org>
Cc: Prasad Joshi <prasadjoshi.linux@gmail.com>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/mpage.c')
-rw-r--r-- | fs/mpage.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/mpage.c b/fs/mpage.c index 0face1c4d4c6..dd6d5878f4d9 100644 --- a/fs/mpage.c +++ b/fs/mpage.c | |||
@@ -43,16 +43,14 @@ | |||
43 | */ | 43 | */ |
44 | static void mpage_end_io(struct bio *bio, int err) | 44 | static void mpage_end_io(struct bio *bio, int err) |
45 | { | 45 | { |
46 | const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); | 46 | struct bio_vec *bv; |
47 | struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; | 47 | int i; |
48 | 48 | ||
49 | do { | 49 | bio_for_each_segment_all(bv, bio, i) { |
50 | struct page *page = bvec->bv_page; | 50 | struct page *page = bv->bv_page; |
51 | 51 | ||
52 | if (--bvec >= bio->bi_io_vec) | ||
53 | prefetchw(&bvec->bv_page->flags); | ||
54 | if (bio_data_dir(bio) == READ) { | 52 | if (bio_data_dir(bio) == READ) { |
55 | if (uptodate) { | 53 | if (!err) { |
56 | SetPageUptodate(page); | 54 | SetPageUptodate(page); |
57 | } else { | 55 | } else { |
58 | ClearPageUptodate(page); | 56 | ClearPageUptodate(page); |
@@ -60,14 +58,15 @@ static void mpage_end_io(struct bio *bio, int err) | |||
60 | } | 58 | } |
61 | unlock_page(page); | 59 | unlock_page(page); |
62 | } else { /* bio_data_dir(bio) == WRITE */ | 60 | } else { /* bio_data_dir(bio) == WRITE */ |
63 | if (!uptodate) { | 61 | if (err) { |
64 | SetPageError(page); | 62 | SetPageError(page); |
65 | if (page->mapping) | 63 | if (page->mapping) |
66 | set_bit(AS_EIO, &page->mapping->flags); | 64 | set_bit(AS_EIO, &page->mapping->flags); |
67 | } | 65 | } |
68 | end_page_writeback(page); | 66 | end_page_writeback(page); |
69 | } | 67 | } |
70 | } while (bvec >= bio->bi_io_vec); | 68 | } |
69 | |||
71 | bio_put(bio); | 70 | bio_put(bio); |
72 | } | 71 | } |
73 | 72 | ||