Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=564f8a3228879d6962edb3432d01bcd7499a67ec
Commit:     564f8a3228879d6962edb3432d01bcd7499a67ec
Parent:     0333394bff439c3fb09264303de42e7038b3e709
Author:     Mark Fasheh <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 14 13:01:05 2006 -0800
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Thu Dec 28 16:38:08 2006 -0800

    ocfs2: Allow direct I/O read past end of file
    
    ocfs2_direct_IO_get_blocks() was incorrectly returning -EIO for a direct I/O
    read whose start block was past the end of the file allocation tree. Fix
    things so that we return a hole instead. do_direct_IO() will then notice
    that the range start is past eof and return a short read.
    
    While there, remove the unused vbo_max variable.
    
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/aops.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index ef6cd30..93628b0 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -540,8 +540,7 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, 
sector_t iblock,
                                     struct buffer_head *bh_result, int create)
 {
        int ret;
-       u64 vbo_max; /* file offset, max_blocks from iblock */
-       u64 p_blkno;
+       u64 p_blkno, inode_blocks;
        int contig_blocks;
        unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;
        unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
@@ -550,12 +549,23 @@ static int ocfs2_direct_IO_get_blocks(struct inode 
*inode, sector_t iblock,
         * nicely aligned and of the right size, so there's no need
         * for us to check any of that. */
 
-       vbo_max = ((u64)iblock + max_blocks) << blocksize_bits;
-
        spin_lock(&OCFS2_I(inode)->ip_lock);
-       if ((iblock + max_blocks) >
-           ocfs2_clusters_to_blocks(inode->i_sb,
-                                    OCFS2_I(inode)->ip_clusters)) {
+       inode_blocks = ocfs2_clusters_to_blocks(inode->i_sb,
+                                               OCFS2_I(inode)->ip_clusters);
+
+       /*
+        * For a read which begins past the end of file, we return a hole.
+        */
+       if (!create && (iblock >= inode_blocks)) {
+               spin_unlock(&OCFS2_I(inode)->ip_lock);
+               ret = 0;
+               goto bail;
+       }
+
+       /*
+        * Any write past EOF is not allowed because we'd be extending.
+        */
+       if (create && (iblock + max_blocks) > inode_blocks) {
                spin_unlock(&OCFS2_I(inode)->ip_lock);
                ret = -EIO;
                goto bail;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to