diff mbox

ext4: Properly mark the extent uninitialized during truncate

Message ID 1244638557-13492-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com
State Accepted, archived
Headers show

Commit Message

Aneesh Kumar K.V June 10, 2009, 12:55 p.m. UTC
We should make sure we don't mark the non uninit extent as
uninit during truncate

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/extents.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o June 10, 2009, 6:24 p.m. UTC | #1
On Wed, Jun 10, 2009 at 06:25:57PM +0530, Aneesh Kumar K.V wrote:
> 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
--
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
Aneesh Kumar K.V June 10, 2009, 7:43 p.m. UTC | #2
On Wed, Jun 10, 2009 at 06:25:57PM +0530, Aneesh Kumar K.V wrote:
> We should make sure we don't mark the non uninit extent as
> uninit during truncate
> 
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
>  fs/ext4/extents.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index f2a2591..764c394 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -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;
> 

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
--
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 f2a2591..764c394 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -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;