All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zheng Liu <gnehzuil.liu@gmail.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Eryu Guan <guaneryu@gmail.com>,
	linux-ext4@vger.kernel.org, Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH] ext4: no need to remove extent if len is 0 in ext4_es_remove_extent()
Date: Sat, 23 Feb 2013 12:07:24 +0800	[thread overview]
Message-ID: <5128407C.1020508@gmail.com> (raw)
In-Reply-To: <20130222175557.GA21264@thunk.org>

Hi Ted,

One minor comment below for the note.

On 02/23/2013 01:55 AM, Theodore Ts'o wrote:
[snip]
> From 7d46e5051453b2c4dfac4e31ae1afb30064cc404 Mon Sep 17 00:00:00 2001
> From: Eryu Guan <guaneryu@gmail.com>
> Date: Fri, 22 Feb 2013 12:54:36 -0500
> Subject: [PATCH] ext4: no need to remove extent if len is 0 in
>  ext4_es_remove_extent()
> 
> len is 0 means no extent needs to be removed, so return immediately.
> Otherwise it could trigger the following BUG_ON() in
> ext4_es_remove_extent()
> 
> 	end = lblk + len - 1;
> 	BUG_ON(end < lblk);
> 
> This could be reproduced by a simple truncate(1) command by an
> unprivileged user
> 
> 	truncate -s $(($((2**32 - 1)) * 4096)) /mnt/ext4/testfile
> 
> The same is true for __es_insert_extent().
> 
> Patched kernel passed xfstests regression test.
> 
> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
> ---
>  fs/ext4/extents_status.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 9f1380e..2be245b 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -392,6 +392,9 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
>  	struct rb_node *parent = NULL;
>  	struct extent_status *es;
>  
> +	if (!len)
> +		return 0;
> +

This will cause a compile error because we don't define a 'len'
variable.  But I have noticed that you have fixed it in latest dev
branch.  So just for the note.

Otherwise the patch looks good.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>

Thanks for fixing it,
						- Zheng

>  	while (*p) {
>  		parent = *p;
>  		es = rb_entry(parent, struct extent_status, rb_node);
> @@ -456,6 +459,9 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
>  	es_debug("add [%u/%u) %llu %llx to extent status tree of inode %lu\n",
>  		 lblk, len, pblk, status, inode->i_ino);
>  
> +	if (!len)
> +		return 0;
> +
>  	BUG_ON(end < lblk);
>  
>  	newes.es_lblk = lblk;
> @@ -649,6 +655,9 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
>  	es_debug("remove [%u/%u) from extent status tree of inode %lu\n",
>  		 lblk, len, inode->i_ino);
>  
> +	if (!len)
> +		return err;
> +
>  	end = lblk + len - 1;
>  	BUG_ON(end < lblk);
>  
> 


      parent reply	other threads:[~2013-02-23  4:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-22  5:34 [PATCH] ext4: no need to remove extent if len is 0 in ext4_es_remove_extent() Eryu Guan
2013-02-22  6:25 ` Zheng Liu
2013-02-22 17:55   ` Theodore Ts'o
2013-02-23  3:40     ` Eryu Guan
2013-02-23 23:45       ` Theodore Ts'o
2013-02-24  5:06         ` Eryu Guan
2013-02-23  4:07     ` Zheng Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5128407C.1020508@gmail.com \
    --to=gnehzuil.liu@gmail.com \
    --cc=guaneryu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=wenqing.lz@taobao.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.