aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/aops.c
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2007-02-16 14:46:50 -0500
committerMark Fasheh <mark.fasheh@oracle.com>2007-04-26 18:02:20 -0400
commit60b11392f1a09433740bda3048202213daa27736 (patch)
treea8687fcb0ce62b130b732d663b54a984564d28b2 /fs/ocfs2/aops.c
parent25baf2da1473d9dcde1a4c7b0ab26e7d67d9bf62 (diff)
ocfs2: zero tail of sparse files on truncate
Since we don't zero on extend anymore, truncate needs to be fixed up to zero the part of a file between i_size and and end of it's cluster. Otherwise a subsequent extend could expose bad data. This introduced a new helper, which can be used in ocfs2_write(). Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/aops.c')
-rw-r--r--fs/ocfs2/aops.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index acf8f0006725..605c82a93f01 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -308,13 +308,13 @@ int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page,
308 * functionality yet, but IMHO it's better to cut and paste the whole 308 * functionality yet, but IMHO it's better to cut and paste the whole
309 * thing so we can avoid introducing our own bugs (and easily pick up 309 * thing so we can avoid introducing our own bugs (and easily pick up
310 * their fixes when they happen) --Mark */ 310 * their fixes when they happen) --Mark */
311static int walk_page_buffers( handle_t *handle, 311int walk_page_buffers( handle_t *handle,
312 struct buffer_head *head, 312 struct buffer_head *head,
313 unsigned from, 313 unsigned from,
314 unsigned to, 314 unsigned to,
315 int *partial, 315 int *partial,
316 int (*fn)( handle_t *handle, 316 int (*fn)( handle_t *handle,
317 struct buffer_head *bh)) 317 struct buffer_head *bh))
318{ 318{
319 struct buffer_head *bh; 319 struct buffer_head *bh;
320 unsigned block_start, block_end; 320 unsigned block_start, block_end;
@@ -654,9 +654,9 @@ static void ocfs2_clear_page_regions(struct page *page,
654 * 654 *
655 * This will also skip zeroing, which is handled externally. 655 * This will also skip zeroing, which is handled externally.
656 */ 656 */
657static int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno, 657int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
658 struct inode *inode, unsigned int from, 658 struct inode *inode, unsigned int from,
659 unsigned int to, int new) 659 unsigned int to, int new)
660{ 660{
661 int ret = 0; 661 int ret = 0;
662 struct buffer_head *head, *bh, *wait[2], **wait_bh = wait; 662 struct buffer_head *head, *bh, *wait[2], **wait_bh = wait;
@@ -675,8 +675,7 @@ static int ocfs2_map_page_blocks(struct page *page, u64 *p_blkno,
675 * Ignore blocks outside of our i/o range - 675 * Ignore blocks outside of our i/o range -
676 * they may belong to unallocated clusters. 676 * they may belong to unallocated clusters.
677 */ 677 */
678 if (block_start >= to || 678 if (block_start >= to || block_end <= from) {
679 (block_start + bsize) <= from) {
680 if (PageUptodate(page)) 679 if (PageUptodate(page))
681 set_buffer_uptodate(bh); 680 set_buffer_uptodate(bh);
682 continue; 681 continue;
@@ -971,7 +970,6 @@ static ssize_t ocfs2_write(struct file *file, u32 phys, handle_t *handle,
971 u64 v_blkno, p_blkno; 970 u64 v_blkno, p_blkno;
972 struct address_space *mapping = file->f_mapping; 971 struct address_space *mapping = file->f_mapping;
973 struct inode *inode = mapping->host; 972 struct inode *inode = mapping->host;
974 unsigned int cbits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
975 unsigned long index, start; 973 unsigned long index, start;
976 struct page **cpages; 974 struct page **cpages;
977 975
@@ -979,13 +977,11 @@ static ssize_t ocfs2_write(struct file *file, u32 phys, handle_t *handle,
979 977
980 /* 978 /*
981 * Figure out how many pages we'll be manipulating here. For 979 * Figure out how many pages we'll be manipulating here. For
982 * non-allocating write, or any writes where cluster size is 980 * non allocating write, we just change the one
983 * less than page size, we only need one page. Otherwise, 981 * page. Otherwise, we'll need a whole clusters worth.
984 * allocating writes of cluster size larger than page size
985 * need cluster size pages.
986 */ 982 */
987 if (new && !wc->w_large_pages) 983 if (new)
988 numpages = (1 << cbits) / PAGE_SIZE; 984 numpages = ocfs2_pages_per_cluster(inode->i_sb);
989 985
990 cpages = kzalloc(sizeof(*cpages) * numpages, GFP_NOFS); 986 cpages = kzalloc(sizeof(*cpages) * numpages, GFP_NOFS);
991 if (!cpages) { 987 if (!cpages) {