Patchwork ext4: disable defrag for metadata_csum file systems

login
register
mail settings
Submitter Theodore Ts'o
Date April 18, 2013, 9:58 p.m.
Message ID <1366322282-4673-1-git-send-email-tytso@mit.edu>
Download mbox | patch
Permalink /patch/237750/
State Rejected
Headers show

Comments

Theodore Ts'o - April 18, 2013, 9:58 p.m.
It looks like there is absolutely no support for metadata checksums in
fs/ext4/move_extent.c.  So if you try to defrag a file on a
metadata_csum, it leaves the file system corrupted.

We really, really should get this fixed ASAP, but until we do, let's
disable e4defrag on metadata_csum file systems so we avoid corrupting
file systems.

Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 fs/ext4/ioctl.c | 9 +++++++++
 1 file changed, 9 insertions(+)
Zheng Liu - April 18, 2013, 11:13 p.m.
[Sorry, it seems that I got a delivery error.  So send again]

On 04/19/2013 05:58 AM, Theodore Ts'o wrote:
> It looks like there is absolutely no support for metadata checksums in
> fs/ext4/move_extent.c.  So if you try to defrag a file on a
> metadata_csum, it leaves the file system corrupted.
> 
> We really, really should get this fixed ASAP, but until we do, let's
> disable e4defrag on metadata_csum file systems so we avoid corrupting
> file systems.
> 
> Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Yes, I also notice this problem.  So currently it seems that the best
choice is to disable defrag for metadata_csum.

Reviewed-By: Zheng Liu <wenqing.lz@taobao.com>

Thanks,
						- Zheng

> ---
>  fs/ext4/ioctl.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 9491ac0..2d043da 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -450,6 +450,15 @@ group_extend_out:
>  			goto mext_out;
>  		}
>  
> +		if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
> +			EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
> +			ext4_msg(sb, KERN_ERR,
> +				 "Online defrag not supported with "
> +				 "metadata_csum");
> +			err = -EOPNOTSUPP;
> +			goto mext_out;
> +		}
> +
>  		err = mnt_want_write_file(filp);
>  		if (err)
>  			goto mext_out;
> 

--
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
Darrick J. Wong - April 19, 2013, 5:47 a.m.
On Fri, Apr 19, 2013 at 07:13:10AM +0800, Zheng Liu wrote:
> [Sorry, it seems that I got a delivery error.  So send again]
> 
> On 04/19/2013 05:58 AM, Theodore Ts'o wrote:
> > It looks like there is absolutely no support for metadata checksums in
> > fs/ext4/move_extent.c.  So if you try to defrag a file on a
> > metadata_csum, it leaves the file system corrupted.
> > 
> > We really, really should get this fixed ASAP, but until we do, let's
> > disable e4defrag on metadata_csum file systems so we avoid corrupting
> > file systems.
> > 
> > Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
> > Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> 
> Yes, I also notice this problem.  So currently it seems that the best
> choice is to disable defrag for metadata_csum.

I think this happens because mext_insert_extents() open-codes the metadata
dirtying and forgets to update the extent block header.  It should call
ext4_ext_dirty() at the end, instead. :(

I should see if there are any other sites that dirty metadata without making
the proper csum_set calls.  Will send a fix shortly, so NAK.

--D
> 
> Reviewed-By: Zheng Liu <wenqing.lz@taobao.com>
> 
> Thanks,
> 						- Zheng
> 
> > ---
> >  fs/ext4/ioctl.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> > index 9491ac0..2d043da 100644
> > --- a/fs/ext4/ioctl.c
> > +++ b/fs/ext4/ioctl.c
> > @@ -450,6 +450,15 @@ group_extend_out:
> >  			goto mext_out;
> >  		}
> >  
> > +		if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
> > +			EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
> > +			ext4_msg(sb, KERN_ERR,
> > +				 "Online defrag not supported with "
> > +				 "metadata_csum");
> > +			err = -EOPNOTSUPP;
> > +			goto mext_out;
> > +		}
> > +
> >  		err = mnt_want_write_file(filp);
> >  		if (err)
> >  			goto mext_out;
> > 
> 
> --
> 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
--
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

Patch

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 9491ac0..2d043da 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -450,6 +450,15 @@  group_extend_out:
 			goto mext_out;
 		}
 
+		if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb,
+			EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
+			ext4_msg(sb, KERN_ERR,
+				 "Online defrag not supported with "
+				 "metadata_csum");
+			err = -EOPNOTSUPP;
+			goto mext_out;
+		}
+
 		err = mnt_want_write_file(filp);
 		if (err)
 			goto mext_out;