All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] Zero from EOF instead of next block
@ 2011-02-14  6:21 Goldwyn Rodrigues
  2011-02-14  7:25 ` Joel Becker
  0 siblings, 1 reply; 9+ messages in thread
From: Goldwyn Rodrigues @ 2011-02-14  6:21 UTC (permalink / raw)
  To: ocfs2-devel

ocfs2_zero_extend() extends the file from the next page offset
rather from the current file size. zero_extend_page() should
call ocfs2_zero_partial_cluster() to set zero rest of the cluster
when the file size is within the page boundaries.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.de>
---
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index a665195..5a2223e 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -63,6 +63,8 @@
 #include "refcounttree.h"

 #include "buffer_head_io.h"
+static int ocfs2_zero_partial_clusters(struct inode *inode,
+				       u64 start, u64 len);

 static int ocfs2_init_file_private(struct inode *inode, struct file *file)
 {
@@ -960,11 +962,21 @@ int ocfs2_zero_extend(struct inode *inode,
struct buffer_head *di_bh,
 	int ret = 0;
 	u64 zero_start, range_start = 0, range_end = 0;
 	struct super_block *sb = inode->i_sb;
+	u64 current_size = i_size_read(inode), len;

 	zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode));
 	mlog(0, "zero_start %llu for i_size %llu\n",
 	     (unsigned long long)zero_start,
 	     (unsigned long long)i_size_read(inode));
+
+	len = ocfs2_align_bytes_to_clusters(sb, current_size) - current_size;
+	if (len) {
+		ret = ocfs2_zero_partial_clusters(inode, current_size, len);
+		if (ret)
+			goto out;
+		zero_start = ocfs2_align_bytes_to_clusters(sb, current_size);
+	}
+
 	while (zero_start < zero_to_size) {
 		ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start,
 						  zero_to_size,
@@ -990,7 +1002,7 @@ int ocfs2_zero_extend(struct inode *inode, struct
buffer_head *di_bh,
 		}
 		zero_start = range_end;
 	}
-
+out:
 	return ret;
 }


-- 
Goldwyn

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-02-16 14:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-14  6:21 [Ocfs2-devel] [PATCH] Zero from EOF instead of next block Goldwyn Rodrigues
2011-02-14  7:25 ` Joel Becker
2011-02-14 18:24   ` Goldwyn Rodrigues
2011-02-14 22:00     ` Joel Becker
2011-02-14 22:02       ` Joel Becker
2011-02-14 22:16       ` Goldwyn Rodrigues
2011-02-14 22:25         ` Joel Becker
2011-02-16  6:26           ` Goldwyn Rodrigues
2011-02-16 14:24             ` Goldwyn Rodrigues

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.