]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] direct IO fixes
authorAndrew Morton <akpm@zip.com.au>
Sat, 10 Aug 2002 09:44:51 +0000 (02:44 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Sat, 10 Aug 2002 09:44:51 +0000 (02:44 -0700)
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.

fs/block_dev.c
fs/direct-io.c

index e43631fac6df8b9afabfd2aa00e75e802f614ae5..aefe1a4302ce02d06491ca67d20267bc17655214 100644 (file)
@@ -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;
index 504d38dd8c57e22a69ad295252234cf57a4a5493..015881a7914784d3cfdbb8049dde69d5f5f1e00d 100644 (file)
@@ -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 *inode, char *buf, loff_t offset,
        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;