From: Richard Weinberger <richard@nod.at>
To: dedekind1@gmail.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH 4/4] UBI: Fastmap: Optimize anchor PEB search
Date: Sun, 30 Nov 2014 13:22:37 +0100 [thread overview]
Message-ID: <1417350157-9373-5-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1417350157-9373-1-git-send-email-richard@nod.at>
The UBI RB trees are sorted by the PEB number, hence
we don't have to traverse the whole tree because ubi_rb_for_each_entry()
walks the tree in sort order.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/ubi/fastmap-wl.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
index b2a6653..c7ad2a7 100644
--- a/drivers/mtd/ubi/fastmap-wl.c
+++ b/drivers/mtd/ubi/fastmap-wl.c
@@ -39,7 +39,10 @@ static struct ubi_wl_entry *find_anchor_wl_entry(struct rb_root *root)
int max_ec = UBI_MAX_ERASECOUNTER;
ubi_rb_for_each_entry(p, e, root, u.rb) {
- if (e->pnum < UBI_FM_MAX_START && e->ec < max_ec) {
+ if (e->pnum >= UBI_FM_MAX_START)
+ break;
+
+ if (e->ec < max_ec) {
victim = e;
max_ec = e->ec;
}
@@ -74,6 +77,8 @@ static int anchor_pebs_avalible(struct rb_root *root)
ubi_rb_for_each_entry(p, e, root, u.rb)
if (e->pnum < UBI_FM_MAX_START)
return 1;
+ else
+ break;
return 0;
}
--
1.8.4.5
next prev parent reply other threads:[~2014-11-30 12:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-30 12:22 Fastmap update v2 (pile 7) Richard Weinberger
2014-11-30 12:22 ` [PATCH 1/4] UBI: Fastmap: Add blank line after declarations Richard Weinberger
2014-11-30 12:22 ` [PATCH 2/4] Add drivers/mtd/ubi/fastmap-wl.c to MAINTAINERS file Richard Weinberger
2014-11-30 12:22 ` [PATCH 3/4] UBI: Fastmap: Remove is_fm_block() Richard Weinberger
2014-11-30 12:22 ` Richard Weinberger [this message]
2014-12-05 15:23 ` [PATCH 4/4] UBI: Fastmap: Optimize anchor PEB search Richard Weinberger
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=1417350157-9373-5-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=dedekind1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/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
all inboxes | Powered by JetHome®