Skip to content

Commit cda9205

Browse files
Chen, Kenneth WLinus Torvalds
authored andcommitted
[PATCH] fix blk_direct_IO bio preparation
For large size DIO that needs multiple bio, one full page worth of data was lost at the boundary of bio's maximum sector or segment limits. After a bio is full and got submitted. The outer while (nbytes) { ... } loop will allocate a new bio and just march on to index into next page. It just forgets about the page that bio_add_page() rejected when previous bio is full. Fix it by put the rejected page back to pvec so we pick it up again for the next bio. Signed-off-by: Ken Chen <kenneth.w.chen@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 15c945c commit cda9205

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎fs/block_dev.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ static struct page *blk_get_page(unsigned long addr, size_t count, int rw,
190190
return pvec->page[pvec->idx++];
191191
}
192192

193+
/* return a page back to pvec array */
194+
static void blk_unget_page(struct page *page, struct pvec *pvec)
195+
{
196+
pvec->page[--pvec->idx] = page;
197+
}
198+
193199
static ssize_t
194200
blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
195201
loff_t pos, unsigned long nr_segs)
@@ -278,6 +284,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
278284
count = min(count, nbytes);
279285
goto same_bio;
280286
}
287+
} else {
288+
blk_unget_page(page, &pvec);
281289
}
282290

283291
/* bio is ready, submit it */

0 commit comments

Comments
 (0)