diff mbox

EXT4: Avoid zeroout-ing and writting the same space

Message ID 1464631943-37365-1-git-send-email-jhe@cs.wisc.edu
State New, archived
Headers show

Commit Message

Jun He May 30, 2016, 6:12 p.m. UTC
When splitting unwritten extent into two extents, currently ext4
zeroout the whole second extent, which contains the requested
space. The requested space will soon be written with data. The
zeroout of requested space is unncessary, causing more traffic
to disk.

Signed-off-by: Jun He <jhe@cs.wisc.edu>
---
 fs/ext4/extents.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2a2eef9..2bba31c 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3597,11 +3597,11 @@  static int ext4_ext_convert_to_initialized(handle_t *handle,
 	split_map.m_len = map->m_len;

 	if (max_zeroout && (allocated > map->m_len)) {
-		if (allocated <= max_zeroout) {
+		if (allocated - map->m_len <= max_zeroout) {
 			/* case 3 */
 			zero_ex.ee_block =
-					 cpu_to_le32(map->m_lblk);
-			zero_ex.ee_len = cpu_to_le16(allocated);
+			    cpu_to_le32(map->m_lblk + map->m_len);
+			zero_ex.ee_len = cpu_to_le16(allocated - map->m_len);
 			ext4_ext_store_pblock(&zero_ex,
 				ext4_ext_pblock(ex) + map->m_lblk - ee_block);
 			err = ext4_ext_zeroout(inode, &zero_ex);