From: Andrew Morton Date: Thu, 2 Dec 2004 23:43:27 +0000 (-0800) Subject: [PATCH] revert the "dio handle eof" fix X-Git-Tag: v2.6.10-rc3~25 X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=01a59cd111e9c378c5a5d1fc65b50bf4c7ef3b94;p=history.git [PATCH] revert the "dio handle eof" fix This recent fix isn't quite right: it is causing smaller-than-expected I/Os to be submitted when extending files, which causes AIO-based writes to oops. So just revert it - the bug was really over in blockdev_get_blocks() anyway. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/direct-io.c b/fs/direct-io.c index 0eb122c56320..4cbcff38e014 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -928,8 +928,6 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, ssize_t ret = 0; ssize_t ret2; size_t bytes; - size_t bytes_todo; - loff_t isize; dio->bio = NULL; dio->inode = inode; @@ -977,32 +975,16 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, else dio->pages_in_io = 0; - bytes_todo = 0; for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; dio->pages_in_io += ((user_addr+iov[seg].iov_len +PAGE_SIZE-1)/PAGE_SIZE - user_addr/PAGE_SIZE); - bytes_todo += iov[seg].iov_len; } - isize = i_size_read(inode); - if (bytes_todo > (isize - offset)) { - if ((isize - offset)) - bytes_todo = isize - offset; - else if (bytes_todo > PAGE_SIZE) - bytes_todo = PAGE_SIZE; - } - - for (seg = 0; seg < nr_segs && bytes_todo; seg++) { - size_t bytes_done; - + for (seg = 0; seg < nr_segs; seg++) { user_addr = (unsigned long)iov[seg].iov_base; - bytes = iov[seg].iov_len; - if (bytes > bytes_todo) - bytes = bytes_todo; - bytes_todo -= bytes; - dio->size += bytes; + dio->size += bytes = iov[seg].iov_len; /* Index into the first page of the first block */ dio->first_block_in_page = (user_addr & ~PAGE_MASK) >> blkbits; @@ -1014,19 +996,16 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode, dio->curr_page = 0; dio->total_pages = 0; - bytes_done = bytes; if (user_addr & (PAGE_SIZE-1)) { dio->total_pages++; - bytes_done = bytes; bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1)); } - dio->total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE; dio->curr_user_address = user_addr; ret = do_direct_IO(dio); - dio->result += bytes_done - + dio->result += iov[seg].iov_len - ((dio->final_block_in_request - dio->block_in_file) << blkbits);