Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73299
b: refs/heads/master
c: 4e9563f
h: refs/heads/master
i:
  73297: e00bae7
  73295: ec2a504
v: v3
  • Loading branch information
Mark Fasheh committed Nov 6, 2007
1 parent ad32778 commit b653619
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9ea2d32f40434589ea0e136373f7d1545afb411f
refs/heads/master: 4e9563fd55ff4479f2b118d0757d121dd0cfc39c
22 changes: 22 additions & 0 deletions trunk/fs/ocfs2/aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,27 @@ static void ocfs2_clear_page_regions(struct page *page,
kunmap_atomic(kaddr, KM_USER0);
}

/*
* Nonsparse file systems fully allocate before we get to the write
* code. This prevents ocfs2_write() from tagging the write as an
* allocating one, which means ocfs2_map_page_blocks() might try to
* read-in the blocks at the tail of our file. Avoid reading them by
* testing i_size against each block offset.
*/
static int ocfs2_should_read_blk(struct inode *inode, struct page *page,
unsigned int block_start)
{
u64 offset = page_offset(page) + block_start;

if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)))
return 1;

if (i_size_read(inode) > offset)
return 1;

return 0;
}

/*
* Some of this taken from block_prepare_write(). We already have our
* mapping by now though, and the entire write will be allocating or
Expand Down Expand Up @@ -781,6 +802,7 @@ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
set_buffer_uptodate(bh);
} else if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
!buffer_new(bh) &&
ocfs2_should_read_blk(inode, page, block_start) &&
(block_start < from || block_end > to)) {
ll_rw_block(READ, 1, &bh);
*wait_bh++=bh;
Expand Down

0 comments on commit b653619

Please sign in to comment.