Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 45148
b: refs/heads/master
c: 564f8a3
h: refs/heads/master
v: v3
  • Loading branch information
Mark Fasheh committed Dec 29, 2006
1 parent ccbf2d9 commit a8a0395
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0333394bff439c3fb09264303de42e7038b3e709
refs/heads/master: 564f8a3228879d6962edb3432d01bcd7499a67ec
24 changes: 17 additions & 7 deletions trunk/fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a8a0395

Please sign in to comment.