linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: disable defrag for metadata_csum file systems
@ 2013-04-18 21:58 Theodore Ts'o
  2013-04-18 23:13 ` Zheng Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Theodore Ts'o @ 2013-04-18 21:58 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o, Darrick J. Wong

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(+)

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;
-- 
1.7.12.rc0.22.gcdd159b


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

* Re: [PATCH] ext4: disable defrag for metadata_csum file systems
  2013-04-18 21:58 [PATCH] ext4: disable defrag for metadata_csum file systems Theodore Ts'o
@ 2013-04-18 23:13 ` Zheng Liu
  2013-04-19  5:47   ` Darrick J. Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Zheng Liu @ 2013-04-18 23:13 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Ext4 Developers List, Darrick J. Wong

[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;
> 


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

* Re: [PATCH] ext4: disable defrag for metadata_csum file systems
  2013-04-18 23:13 ` Zheng Liu
@ 2013-04-19  5:47   ` Darrick J. Wong
  2013-04-19  6:17     ` Theodore Ts'o
  0 siblings, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2013-04-19  5:47 UTC (permalink / raw)
  To: Zheng Liu; +Cc: Theodore Ts'o, Ext4 Developers List

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

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

* Re: [PATCH] ext4: disable defrag for metadata_csum file systems
  2013-04-19  5:47   ` Darrick J. Wong
@ 2013-04-19  6:17     ` Theodore Ts'o
  2013-04-19  6:19       ` Theodore Ts'o
  0 siblings, 1 reply; 5+ messages in thread
From: Theodore Ts'o @ 2013-04-19  6:17 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Zheng Liu, Ext4 Developers List

On Thu, Apr 18, 2013 at 10:47:38PM -0700, Darrick J. Wong wrote:
> 
> 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. :(

Yes.  The following patch seems to fix the problem.

I'm wondering if we could significantly simplify the move_extent.c
file by allocating two tmp_inodes and then using
ext4_ext_insert_extent() the same way fs/ext4/migrate.c handles
things.  But that's a potential cleanup for later....

						- Ted

commit fa3a0fc57b3d3c885dd7354508c9f20fc0c4a184
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Fri Apr 19 02:14:18 2013 -0400

    ext4: set the extent leaf checksum when processing EXT4_IOC_MOVE_EXT
    
    The EXT4_IOC_MOVE_EXT which is used by the e4defrag program was not
    properly setting the checksum in the extent leaf block.  Fix this.
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 779d26b..269122e 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2574,6 +2574,11 @@ extern int ext4_check_blockref(const char *, unsigned int,
 struct ext4_ext_path;
 struct ext4_extent;
 
+#define ext4_ext_dirty(handle, inode, path) \
+		ext4__ext_dirty(__func__, __LINE__, (handle), (inode), (path))
+extern int ext4__ext_dirty(const char *where, unsigned int line,
+			   handle_t *handle, struct inode *inode,
+			   struct ext4_ext_path *path);
 extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
 extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
 extern int ext4_ext_index_trans_blocks(struct inode *inode, int nrblocks,
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 6fcb375..ff019ed 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -157,11 +157,8 @@ static int ext4_ext_get_access(handle_t *handle, struct inode *inode,
  *  - ENOMEM
  *  - EIO
  */
-#define ext4_ext_dirty(handle, inode, path) \
-		__ext4_ext_dirty(__func__, __LINE__, (handle), (inode), (path))
-static int __ext4_ext_dirty(const char *where, unsigned int line,
-			    handle_t *handle, struct inode *inode,
-			    struct ext4_ext_path *path)
+int ext4__ext_dirty(const char *where, unsigned int line, handle_t *handle,
+		    struct inode *inode, struct ext4_ext_path *path)
 {
 	int err;
 	if (path->p_bh) {
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 309ca89..a05a622 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -410,8 +410,7 @@ mext_insert_extents(handle_t *handle, struct inode *orig_inode,
 						end_ext, eh, range_to_move);
 
 	if (depth) {
-		ret = ext4_handle_dirty_metadata(handle, orig_inode,
-						 orig_path->p_bh);
+		ret = ext4_ext_dirty(handle, orig_inode, orig_path);
 		if (ret)
 			return ret;
 	} else {

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

* Re: [PATCH] ext4: disable defrag for metadata_csum file systems
  2013-04-19  6:17     ` Theodore Ts'o
@ 2013-04-19  6:19       ` Theodore Ts'o
  0 siblings, 0 replies; 5+ messages in thread
From: Theodore Ts'o @ 2013-04-19  6:19 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Zheng Liu, Ext4 Developers List

On Fri, Apr 19, 2013 at 02:17:27AM -0400, Theodore Ts'o wrote:
> On Thu, Apr 18, 2013 at 10:47:38PM -0700, Darrick J. Wong wrote:
> > 
> > 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. :(
> 
> Yes.  The following patch seems to fix the problem.

Ah, I see you posted a similar patch.  I'll take yours, since it's cleaner.

      	      	       	       	       	    - Ted

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

end of thread, other threads:[~2013-04-19  6:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 21:58 [PATCH] ext4: disable defrag for metadata_csum file systems Theodore Ts'o
2013-04-18 23:13 ` Zheng Liu
2013-04-19  5:47   ` Darrick J. Wong
2013-04-19  6:17     ` Theodore Ts'o
2013-04-19  6:19       ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).