* [PATCH 1/2] UBI: fix documentation and improve readability
@ 2012-03-08 14:21 Artem Bityutskiy
2012-03-08 14:21 ` [PATCH 2/2] UBI: fix eraseblock picking criteria Artem Bityutskiy
2012-03-08 15:57 ` [PATCH 1/2] UBI: fix documentation and improve readability Shmulik Ladkani
0 siblings, 2 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-03-08 14:21 UTC (permalink / raw)
To: MTD Maling List; +Cc: Shmulik Ladkani
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
The "max" parameter of 'find_wl_entry()' was documented incorrectly and
it actually means the maximum possible difference from th smallest erase
counter. Rename it to "diff" instead, and amend the documentation.
Reported-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
---
drivers/mtd/ubi/wl.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 0696e36..8616f52 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -350,18 +350,19 @@ static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e)
/**
* find_wl_entry - find wear-leveling entry closest to certain erase counter.
* @root: the RB-tree where to look for
- * @max: highest possible erase counter
+ * @diff: maximum possible difference from the smallest erase counter
*
* This function looks for a wear leveling entry with erase counter closest to
- * @max and less than @max.
+ * min + @diff, where min is the smallest erase counter.
*/
-static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max)
+static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int diff)
{
struct rb_node *p;
struct ubi_wl_entry *e;
+ int max;
e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb);
- max += e->ec;
+ max = e->ec + diff;
p = root->rb_node;
while (p) {
--
1.7.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] UBI: fix eraseblock picking criteria
2012-03-08 14:21 [PATCH 1/2] UBI: fix documentation and improve readability Artem Bityutskiy
@ 2012-03-08 14:21 ` Artem Bityutskiy
2012-03-08 15:57 ` [PATCH 1/2] UBI: fix documentation and improve readability Shmulik Ladkani
1 sibling, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-03-08 14:21 UTC (permalink / raw)
To: MTD Maling List; +Cc: Shmulik Ladkani
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
The 'find_wl_entry()' function expects the maximum difference as the second
argument, not the maximum absolute value. So the "unknown" eraseblock picking
was incorrect, as Shmulik Ladkani spotted. This patch fixes the issue.
Reported-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
Cc: stable@kernel.org
---
drivers/mtd/ubi/wl.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 8616f52..512eab0 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -390,7 +390,7 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int diff)
*/
int ubi_wl_get_peb(struct ubi_device *ubi, int dtype)
{
- int err, medium_ec;
+ int err;
struct ubi_wl_entry *e, *first, *last;
ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM ||
@@ -428,7 +428,7 @@ retry:
* For unknown data we pick a physical eraseblock with medium
* erase counter. But we by no means can pick a physical
* eraseblock with erase counter greater or equivalent than the
- * lowest erase counter plus %WL_FREE_MAX_DIFF.
+ * lowest erase counter plus %WL_FREE_MAX_DIFF/2.
*/
first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry,
u.rb);
@@ -437,10 +437,8 @@ retry:
if (last->ec - first->ec < WL_FREE_MAX_DIFF)
e = rb_entry(ubi->free.rb_node,
struct ubi_wl_entry, u.rb);
- else {
- medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2;
- e = find_wl_entry(&ubi->free, medium_ec);
- }
+ else
+ e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF/2);
break;
case UBI_SHORTTERM:
/*
--
1.7.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] UBI: fix documentation and improve readability
2012-03-08 14:21 [PATCH 1/2] UBI: fix documentation and improve readability Artem Bityutskiy
2012-03-08 14:21 ` [PATCH 2/2] UBI: fix eraseblock picking criteria Artem Bityutskiy
@ 2012-03-08 15:57 ` Shmulik Ladkani
2012-03-09 7:43 ` Artem Bityutskiy
1 sibling, 1 reply; 4+ messages in thread
From: Shmulik Ladkani @ 2012-03-08 15:57 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: MTD Maling List
On Thu, 8 Mar 2012 16:21:30 +0200 Artem Bityutskiy <dedekind1@gmail.com> wrote:
> From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
>
> The "max" parameter of 'find_wl_entry()' was documented incorrectly and
> it actually means the maximum possible difference from th smallest erase
s/ th / the /
Regards,
Shmulik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] UBI: fix documentation and improve readability
2012-03-08 15:57 ` [PATCH 1/2] UBI: fix documentation and improve readability Shmulik Ladkani
@ 2012-03-09 7:43 ` Artem Bityutskiy
0 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-03-09 7:43 UTC (permalink / raw)
To: Shmulik Ladkani; +Cc: MTD Maling List
On Thu, 2012-03-08 at 17:57 +0200, Shmulik Ladkani wrote:
> On Thu, 8 Mar 2012 16:21:30 +0200 Artem Bityutskiy <dedekind1@gmail.com> wrote:
> > From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> >
> > The "max" parameter of 'find_wl_entry()' was documented incorrectly and
> > it actually means the maximum possible difference from th smallest erase
>
> s/ th / the /
Fixed, thanks!
--
Best Regards,
Artem Bityutskiy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-03-09 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08 14:21 [PATCH 1/2] UBI: fix documentation and improve readability Artem Bityutskiy
2012-03-08 14:21 ` [PATCH 2/2] UBI: fix eraseblock picking criteria Artem Bityutskiy
2012-03-08 15:57 ` [PATCH 1/2] UBI: fix documentation and improve readability Shmulik Ladkani
2012-03-09 7:43 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox