aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/blocklayout/blocklayout.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-11-07 15:20:26 -0500
committerKent Overstreet <kmo@daterainc.com>2013-11-24 01:33:46 -0500
commit2c30c71bd653afcbed7f6754e8fe3d16e0e708a1 (patch)
treea6b1147e4302b7216600c397cb47ca7f7f375a43 /fs/nfs/blocklayout/blocklayout.c
parent33879d4512c021ae65be9706608dacb36b4687b1 (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/nfs/blocklayout/blocklayout.c')
-rw-r--r--fs/nfs/blocklayout/blocklayout.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index e242bbf72972..da768923bf7c 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -201,18 +201,14 @@ static struct bio *bl_add_page_to_bio(struct bio *bio, int npg, int rw,
201static void bl_end_io_read(struct bio *bio, int err) 201static void bl_end_io_read(struct bio *bio, int err)
202{ 202{
203 struct parallel_io *par = bio->bi_private; 203 struct parallel_io *par = bio->bi_private;
204 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 204 struct bio_vec *bvec;
205 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 205 int i;
206 206
207 do { 207 if (!err)
208 struct page *page = bvec->bv_page; 208 bio_for_each_segment_all(bvec, bio, i)
209 SetPageUptodate(bvec->bv_page);
209 210
210 if (--bvec >= bio->bi_io_vec) 211 if (err) {
211 prefetchw(&bvec->bv_page->flags);
212 if (uptodate)
213 SetPageUptodate(page);
214 } while (bvec >= bio->bi_io_vec);
215 if (!uptodate) {
216 struct nfs_read_data *rdata = par->data; 212 struct nfs_read_data *rdata = par->data;
217 struct nfs_pgio_header *header = rdata->header; 213 struct nfs_pgio_header *header = rdata->header;
218 214
@@ -383,20 +379,16 @@ static void mark_extents_written(struct pnfs_block_layout *bl,
383static void bl_end_io_write_zero(struct bio *bio, int err) 379static void bl_end_io_write_zero(struct bio *bio, int err)
384{ 380{
385 struct parallel_io *par = bio->bi_private; 381 struct parallel_io *par = bio->bi_private;
386 const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags); 382 struct bio_vec *bvec;
387 struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1; 383 int i;
388
389 do {
390 struct page *page = bvec->bv_page;
391 384
392 if (--bvec >= bio->bi_io_vec) 385 bio_for_each_segment_all(bvec, bio, i) {
393 prefetchw(&bvec->bv_page->flags);
394 /* This is the zeroing page we added */ 386 /* This is the zeroing page we added */
395 end_page_writeback(page); 387 end_page_writeback(bvec->bv_page);
396 page_cache_release(page); 388 page_cache_release(bvec->bv_page);
397 } while (bvec >= bio->bi_io_vec); 389 }
398 390
399 if (unlikely(!uptodate)) { 391 if (unlikely(err)) {
400 struct nfs_write_data *data = par->data; 392 struct nfs_write_data *data = par->data;
401 struct nfs_pgio_header *header = data->header; 393 struct nfs_pgio_header *header = data->header;
402 394