From: Zheng Liu <gnehzuil.liu@gmail.com>
To: Eryu Guan <guaneryu@gmail.com>
Cc: linux-ext4@vger.kernel.org, Zheng Liu <wenqing.lz@taobao.com>,
Theodore Ts'o <tytso@mit.edu>
Subject: Re: [PATCH] ext4: no need to remove extent if len is 0 in ext4_es_remove_extent()
Date: Fri, 22 Feb 2013 14:25:09 +0800 [thread overview]
Message-ID: <20130222062509.GA2735@gmail.com> (raw)
In-Reply-To: <1361511243-2458-1-git-send-email-guaneryu@gmail.com>
On Fri, Feb 22, 2013 at 01:34:03PM +0800, Eryu Guan wrote:
> len is 0 means no extent needs to be removed, so return immediately.
> Otherwise it could trigger the following BUG_ON()
>
> 436 end = offset + len - 1;
> 437 BUG_ON(end < offset);
>
> 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.
>
> Also remove comments about EXT4_I(inode)->i_es_lock, this rwlock
> isn't hold by callers.
>
> Cc: Zheng Liu <wenqing.lz@taobao.com>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Thanks for fixing it.
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Regards,
- Zheng
> ---
> fs/ext4/extents_status.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 564d981..3ac09ca 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -328,6 +328,9 @@ static int __es_insert_extent(struct ext4_es_tree *tree, ext4_lblk_t offset,
> struct extent_status *es;
> ext4_lblk_t end = offset + len - 1;
>
> + if (!len)
> + return 0;
> +
> BUG_ON(end < offset);
> es = tree->cache_es;
> if (es && offset == (extent_status_end(es) + 1)) {
> @@ -386,7 +389,6 @@ out:
>
> /*
> * ext4_es_insert_extent() adds a space to a delayed extent tree.
> - * Caller holds inode->i_es_lock.
> *
> * ext4_es_insert_extent is called by ext4_da_write_begin and
> * ext4_es_remove_extent.
> @@ -415,7 +417,6 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t offset,
>
> /*
> * ext4_es_remove_extent() removes a space from a delayed extent tree.
> - * Caller holds inode->i_es_lock.
> *
> * Return 0 on success, error code on failure.
> */
> @@ -433,6 +434,9 @@ int ext4_es_remove_extent(struct inode *inode, ext4_lblk_t offset,
> es_debug("remove [%u/%u) from extent status tree of inode %lu\n",
> offset, len, inode->i_ino);
>
> + if (!len)
> + return err;
> +
> end = offset + len - 1;
> BUG_ON(end < offset);
> write_lock(&EXT4_I(inode)->i_es_lock);
> --
> 1.8.1.2
>
> --
> 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
next prev parent reply other threads:[~2013-02-22 6:10 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 [this message]
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
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=20130222062509.GA2735@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.