Skip to contentSkip to conversation

ext4: Properly mark the extent uninitialized during truncate

PATCH In review Aneesh Kumar K.V 2 participants 3 messages Jun 10, 2009 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Properly mark the extent uninitialized during truncate

We should make sure we don't mark the non uninit extent as uninit during truncate

---
 fs/ext4/extents.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/ext4/extents.c +6 -2
index f2a2591..764c394 100644
@@ -2083,12 +2083,16 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
 	ex = EXT_LAST_EXTENT(eh);
 
 	ex_ee_block = le32_to_cpu(ex->ee_block);
-	if (ext4_ext_is_uninitialized(ex))
-		uninitialized = 1;
 	ex_ee_len = ext4_ext_get_actual_len(ex);
 
 	while (ex >= EXT_FIRST_EXTENT(eh) &&
 			ex_ee_block + ex_ee_len > start) {
+
+		if (ext4_ext_is_uninitialized(ex))
+			uninitialized = 1;
+		else
+			uninitialized = 0;
+
 		ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
 		path[depth].p_ext = ex;
 
Signature · 1 line
1.6.3.2.214.gf4f78
#1 lore raw
Quoted 21 lines · Aneesh Kumar K.V

We should make sure we don't mark the non uninit extent as uninit during truncate

---
 fs/ext4/extents.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/ext4/extents.c +0 -2
index f2a2591..764c394 100644
@@ -2083,12 +2083,16 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
 	ex = EXT_LAST_EXTENT(eh);
 
 	ex_ee_block = le32_to_cpu(ex->ee_block);
-	if (ext4_ext_is_uninitialized(ex))
-		uninitialized = 1;
 	ex_ee_len = ext4_ext_get_actual_len(ex);
 
 	while (ex >= EXT_FIRST_EXTENT(eh) &&

fs/ext4/extents.c ext4_ext_rm_leaf(handle_t *handle, struct inode *inode, · line 2098

Quoted 10 lines
fs/ext4/extents.c +6 -0
 			ex_ee_block + ex_ee_len > start) {
+
+		if (ext4_ext_is_uninitialized(ex))
+			uninitialized = 1;
+		else
+			uninitialized = 0;
+
 		ext_debug("remove ext %lu:%u\n", ex_ee_block, ex_ee_len);
 		path[depth].p_ext = ex;
 

BTW this fix is really important. It fix a data corruption when we write to an fallocate space and later truncate the same file. So mostly a stable candidate.

-aneesh

maintainer
#2 lore raw
In reply to Aneesh Kumar K.V
Quoted 2 lines · Aneesh Kumar K.V

We should make sure we don't mark the non uninit extent as uninit during truncate

Good catch! I've applied it to the ext4 patch queue.

Thanks,

- Ted