Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cda9205d authored by Kenneth W Chen's avatar Kenneth W Chen Committed by Linus Torvalds
Browse files

[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: default avatarKen Chen <kenneth.w.chen@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 15c945c3
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -190,6 +190,12 @@ static struct page *blk_get_page(unsigned long addr, size_t count, int rw,
	return pvec->page[pvec->idx++];
	return pvec->page[pvec->idx++];
}
}


/* return a page back to pvec array */
static void blk_unget_page(struct page *page, struct pvec *pvec)
{
	pvec->page[--pvec->idx] = page;
}

static ssize_t
static ssize_t
blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
		 loff_t pos, unsigned long nr_segs)
		 loff_t pos, unsigned long nr_segs)
@@ -278,6 +284,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
				count = min(count, nbytes);
				count = min(count, nbytes);
				goto same_bio;
				goto same_bio;
			}
			}
		} else {
			blk_unget_page(page, &pvec);
		}
		}


		/* bio is ready, submit it */
		/* bio is ready, submit it */