From: Liu Bo <bo.li.liu@oracle.com>
To: miaox@cn.fujitsu.com
Cc: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH V2] Btrfs: fix unnecessary while loop when search the free space, cache
Date: Thu, 18 Oct 2012 16:47:36 +0800 [thread overview]
Message-ID: <507FC228.4050400@oracle.com> (raw)
In-Reply-To: <507FBB39.5090603@cn.fujitsu.com>
On 10/18/2012 04:18 PM, Miao Xie wrote:
> When we find a bitmap free space entry, we may check the previous extent
> entry covers the offset or not. But if we find this entry is also a bitmap
> entry, we will continue to check the previous entry of the current one by
> a while loop. It is unnecessary because it is impossible that the extent
> entry which is in front of a bitmap entry can cover the offset of the entry
> after that bitmap entry.
>
Looks good to me.
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
> Changelog v1 -> v2:
> - fix the same problem in the other place
> ---
> fs/btrfs/free-space-cache.c | 30 ++++++++++--------------------
> 1 files changed, 10 insertions(+), 20 deletions(-)
>
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 1027b85..557502c 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -1250,18 +1250,13 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
> * if previous extent entry covers the offset,
> * we should return it instead of the bitmap entry
> */
> - n = &entry->offset_index;
> - while (1) {
> - n = rb_prev(n);
> - if (!n)
> - break;
> + n = rb_prev(&entry->offset_index);
> + if (n) {
> prev = rb_entry(n, struct btrfs_free_space,
> offset_index);
> - if (!prev->bitmap) {
> - if (prev->offset + prev->bytes > offset)
> - entry = prev;
> - break;
> - }
> + if (!prev->bitmap &&
> + prev->offset + prev->bytes > offset)
> + entry = prev;
> }
> }
> return entry;
> @@ -1287,18 +1282,13 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
> }
>
> if (entry->bitmap) {
> - n = &entry->offset_index;
> - while (1) {
> - n = rb_prev(n);
> - if (!n)
> - break;
> + n = rb_prev(&entry->offset_index);
> + if (n) {
> prev = rb_entry(n, struct btrfs_free_space,
> offset_index);
> - if (!prev->bitmap) {
> - if (prev->offset + prev->bytes > offset)
> - return prev;
> - break;
> - }
> + if (!prev->bitmap &&
> + prev->offset + prev->bytes > offset)
> + return prev;
> }
> if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset)
> return entry;
>
prev parent reply other threads:[~2012-10-18 8:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 8:02 [PATCH] Btrfs: fix unnecessary while loop when search the free space cache Miao Xie
2012-10-18 8:18 ` [PATCH V2] Btrfs: fix unnecessary while loop when search the free space, cache Miao Xie
2012-10-18 8:47 ` Liu Bo [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=507FC228.4050400@oracle.com \
--to=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=miaox@cn.fujitsu.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 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).