From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 10/12] direct IO fixes
Date: Fri, 09 Aug 2002 17:57:58 -0700 [thread overview]
Message-ID: <3D546516.E60C7E4@zip.com.au> (raw)
Some direct IO fixes from Badari Pulavarty.
- off-by-one in the bounds checking in blkdev_get_blocks().
- When adding more blocks into a bio_vec, account for the current
offset into that bio_vec.
- Fix a total ballsup in the code which calculates the total number
of pages which are about to be put under IO.
block_dev.c | 2 +-
direct-io.c | 7 ++++---
2 files changed, 5 insertions, 4 deletions
--- 2.5.30/fs/direct-io.c~direct_io-fixes Fri Aug 9 17:36:47 2002
+++ 2.5.30-akpm/fs/direct-io.c Fri Aug 9 17:36:47 2002
@@ -489,7 +489,7 @@ int do_direct_IO(struct dio *dio)
/* Work out how much disk we can add to this page */
this_chunk_blocks = dio->blocks_available;
- u = (PAGE_SIZE - dio->bvec->bv_len) >> blkbits;
+ u = (PAGE_SIZE - (dio->bvec->bv_offset + dio->bvec->bv_len)) >> blkbits;
if (this_chunk_blocks > u)
this_chunk_blocks = u;
u = dio->final_block_in_request - dio->block_in_file;
@@ -567,10 +567,11 @@ generic_direct_IO(int rw, struct inode *
dio.curr_page = 0;
bytes = count;
dio.total_pages = 0;
- if (offset & PAGE_SIZE) {
+ if (user_addr & (PAGE_SIZE - 1)) {
dio.total_pages++;
- bytes -= PAGE_SIZE - (offset & ~(PAGE_SIZE - 1));
+ bytes -= PAGE_SIZE - (user_addr & (PAGE_SIZE - 1));
}
+
dio.total_pages += (bytes + PAGE_SIZE - 1) / PAGE_SIZE;
dio.curr_user_address = user_addr;
--- 2.5.30/fs/block_dev.c~direct_io-fixes Fri Aug 9 17:36:47 2002
+++ 2.5.30-akpm/fs/block_dev.c Fri Aug 9 17:36:47 2002
@@ -105,7 +105,7 @@ static int
blkdev_get_blocks(struct inode *inode, sector_t iblock,
unsigned long max_blocks, struct buffer_head *bh, int create)
{
- if ((iblock + max_blocks) >= max_block(inode->i_bdev))
+ if ((iblock + max_blocks) > max_block(inode->i_bdev))
return -EIO;
bh->b_bdev = inode->i_bdev;
.
reply other threads:[~2002-08-10 0:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D546516.E60C7E4@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox