diff options
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r-- | fs/ocfs2/aops.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index c69c1b300155..556e34ccb005 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -729,6 +729,27 @@ static void ocfs2_clear_page_regions(struct page *page, | |||
729 | } | 729 | } |
730 | 730 | ||
731 | /* | 731 | /* |
732 | * Nonsparse file systems fully allocate before we get to the write | ||
733 | * code. This prevents ocfs2_write() from tagging the write as an | ||
734 | * allocating one, which means ocfs2_map_page_blocks() might try to | ||
735 | * read-in the blocks at the tail of our file. Avoid reading them by | ||
736 | * testing i_size against each block offset. | ||
737 | */ | ||
738 | static int ocfs2_should_read_blk(struct inode *inode, struct page *page, | ||
739 | unsigned int block_start) | ||
740 | { | ||
741 | u64 offset = page_offset(page) + block_start; | ||
742 | |||
743 | if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) | ||
744 | return 1; | ||
745 | |||
746 | if (i_size_read(inode) > offset) | ||
747 | return 1; | ||
748 | |||
749 | return 0; | ||
750 | } | ||
751 | |||
752 | /* | ||
732 | * Some of this taken from block_prepare_write(). We already have our | 753 | * Some of this taken from block_prepare_write(). We already have our |
733 | * mapping by now though, and the entire write will be allocating or | 754 | * mapping by now though, and the entire write will be allocating or |
734 | * it won't, so not much need to use BH_New. | 755 | * it won't, so not much need to use BH_New. |
@@ -781,6 +802,7 @@ int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, | |||
781 | set_buffer_uptodate(bh); | 802 | set_buffer_uptodate(bh); |
782 | } else if (!buffer_uptodate(bh) && !buffer_delay(bh) && | 803 | } else if (!buffer_uptodate(bh) && !buffer_delay(bh) && |
783 | !buffer_new(bh) && | 804 | !buffer_new(bh) && |
805 | ocfs2_should_read_blk(inode, page, block_start) && | ||
784 | (block_start < from || block_end > to)) { | 806 | (block_start < from || block_end > to)) { |
785 | ll_rw_block(READ, 1, &bh); | 807 | ll_rw_block(READ, 1, &bh); |
786 | *wait_bh++=bh; | 808 | *wait_bh++=bh; |