From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, nyoushchenko@mvista.com,
linux-kernel@vger.kernel.org, adrian.hunter@intel.com,
Heinz.Egger@linutronix.de, thomas.wucher@linutronix.de,
shmulik.ladkani@gmail.com, tglx@linutronix.de,
Marius.Mazarel@ugal.ro, tim.bird@am.sony.com
Subject: Re: [PATCH 04/16] UBI: Fastmap: Rename self_check_fastmap()
Date: Thu, 28 Jun 2012 15:44:19 +0300 [thread overview]
Message-ID: <1340887459.3070.100.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1340812676-14460-5-git-send-email-richard@nod.at>
[-- Attachment #1: Type: text/plain, Size: 7624 bytes --]
On Wed, 2012-06-27 at 17:57 +0200, Richard Weinberger wrote:
> Signed-off-by: Richard Weinberger <richard@nod.at>
Hi, pushed this and added a couple of TODOs. Could you please take a
look? Most TODOs are non-essential and easy, but one is more important -
the one about regression in attach time of non-fastmap images.
Thanks!
From b43ceb01a33b322898232fb05e5cc7f754656421 Mon Sep 17 00:00:00 2001
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Thu, 28 Jun 2012 15:08:29 +0300
Subject: [PATCH 1/2] UBI: Fastmap: rename new_ai to alloc_ia
Just more consistent, we do not use "new" in, e.g., 'ubi_zalloc_vid_hdr()'.
Also move the code to avoid forward references, which we also do not use.
Also get rid of unneeded goto in alloc_ia(). Nothing major.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
drivers/mtd/ubi/attach.c | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 7552d25..8204b2d 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -91,7 +91,6 @@
static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
static void destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
-static struct ubi_attach_info *new_ai(void);
/* Temporary variables used during scanning */
static struct ubi_ec_hdr *ech;
@@ -1216,6 +1215,22 @@ out_ai:
return err;
}
+static struct ubi_attach_info *alloc_ai(void)
+{
+ static struct ubi_attach_info *ai;
+
+ ai = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL);
+ if (ai) {
+ INIT_LIST_HEAD(&ai->corr);
+ INIT_LIST_HEAD(&ai->free);
+ INIT_LIST_HEAD(&ai->erase);
+ INIT_LIST_HEAD(&ai->alien);
+ ai->volumes = RB_ROOT;
+ }
+
+ return ai;
+}
+
/**
* ubi_attach - attach an MTD device.
* @ubi: UBI device descriptor
@@ -1229,7 +1244,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
int err;
struct ubi_attach_info *ai;
- ai = new_ai();
+ ai = alloc_ai();
if (!ai)
return -ENOMEM;
@@ -1239,7 +1254,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
err = ubi_scan_fastmap(ubi, ai);
if (err > 0) {
destroy_ai(ubi, ai);
- ai = new_ai();
+ ai = alloc_ai();
if (!ai)
return -ENOMEM;
@@ -1279,7 +1294,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (ubi->fm && ubi->dbg->chk_gen) {
struct ubi_attach_info *scan_ai;
- scan_ai = new_ai();
+ scan_ai = alloc_ai();
if (!scan_ai)
goto out_ai;
@@ -1395,24 +1410,6 @@ static void destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
kfree(ai);
}
-static struct ubi_attach_info *new_ai(void)
-{
- static struct ubi_attach_info *ai;
-
- ai = kzalloc(sizeof(struct ubi_attach_info), GFP_KERNEL);
- if (!ai)
- goto out;
-
- INIT_LIST_HEAD(&ai->corr);
- INIT_LIST_HEAD(&ai->free);
- INIT_LIST_HEAD(&ai->erase);
- INIT_LIST_HEAD(&ai->alien);
- ai->volumes = RB_ROOT;
-
-out:
- return ai;
-}
-
/**
* self_check_ai - check the attaching information.
* @ubi: UBI device description object
--
1.7.10
From 400a911b104d88bbf6cc593e8bb24c9865a1c449 Mon Sep 17 00:00:00 2001
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date: Thu, 28 Jun 2012 15:34:17 +0300
Subject: [PATCH 2/2] UBI: fastmap: some todo and random changes
Add few consmetic changes and a bunch of TODOs.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
drivers/mtd/ubi/attach.c | 29 +++++++++++++++++++++++++++++
drivers/mtd/ubi/eba.c | 7 ++++---
2 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 8204b2d..3d9be42 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -89,6 +89,13 @@
#include <linux/random.h>
#include "ubi.h"
+/*
+ * TODO: please, no forward declarations. We do not use them in UBI code.
+ * Actually initially I did use them a lot, but when upstreaming, I was asked
+ * to remove. Please, follow this convention as well. Please, change globally.
+ * I mean, I am already used to that _all_ the code is upside-down, let's keep
+ * it that way, or re-structure all the code. :-)
+ */
static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
static void destroy_ai(struct ubi_device *ubi, struct ubi_attach_info *ai);
@@ -1170,6 +1177,7 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai)
if (ai->ec_count)
ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
+ /* TODO: if we attach by fastmap, we do not execute this? */
err = late_analysis(ubi, ai);
if (err)
goto out_vidh;
@@ -1251,6 +1259,25 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (force_scan)
err = scan_all(ubi, ai);
else {
+ /* TODO: this is a regression. If I have an old image, and I do
+ * not want to use fastmap, I will be forced to waste time for
+ * useless scan of 64 first eraseblocks. Not good.
+ *
+ * Can you teach ubi_scan_fastmap() to use 'scan_peb()'
+ * function for scanning and build normal ai information? If it
+ * finds fastmap - it can destroy the collected ai. If it does
+ * not find, it returns ai. Then you just confinue scanning.
+ *
+ * I buess what we'll need is:
+ * 1. scan_all() -> scan_range(..., int pnum1, int pnum2);
+ * 2. ubi_scan_fastmap() returns the pnum of the last scanned
+ * eraseblock if fastmap was not found;
+ * Also 'ubi_scan_fastmap()' uses scan_peb() for scanning.
+ * 3. You call 'scan_range(..., pnum, c->peb_cnt - 1)' and
+ * it continues.
+ *
+ * And no regressions.
+ */
err = ubi_scan_fastmap(ubi, ai);
if (err > 0) {
destroy_ai(ubi, ai);
@@ -1276,6 +1303,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (err)
goto out_ai;
+ /* TODO: Hmm why this code is not hidden in 'ubi_scan_fastmap()' ? */
if (ubi->fm) {
ubi->fm_pool.max_size = ubi->fm->max_pool_size;
ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size;
@@ -1294,6 +1322,7 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
if (ubi->fm && ubi->dbg->chk_gen) {
struct ubi_attach_info *scan_ai;
+
scan_ai = alloc_ai();
if (!scan_ai)
goto out_ai;
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index cb0139c..6d6e301 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -1218,11 +1218,12 @@ static void print_rsvd_warning(struct ubi_device *ubi,
}
/**
- * self_check_eba - run a self check on the EBA table construected by fastmap.
- *
+ * self_check_eba - run a self check on the EBA table constructed by fastmap.
* @ubi: UBI device description object
* @ai_fastmap: UBI attach info object created by fastmap
* @ai_scan: UBI attach info object created by scanning
+ *
+ * TODO: what we do and what return.
*/
int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
struct ubi_attach_info *ai_scan)
@@ -1290,6 +1291,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
ubi_err("LEB:%i:%i is PEB:%i instead of %i!",
vol->vol_id, i, fm_eba[i][j], scan_eba[i][j]);
+ /* TODO: no, please, return error instead */
BUG();
}
}
@@ -1306,7 +1308,6 @@ out_free:
kfree(scan_eba);
kfree(fm_eba);
-
return ret;
}
--
1.7.10
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-06-28 12:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-27 15:57 UBI fastmap updates Richard Weinberger
2012-06-27 15:57 ` [PATCH 01/16] UBI: Fastmap: Check find_mean_wl_entry()'s return value Richard Weinberger
2012-06-27 15:57 ` [PATCH 02/16] UBI: Fastmap: Kernel doc updates Richard Weinberger
2012-06-27 15:57 ` [PATCH 03/16] UBI: Fastmap: Fix license version Richard Weinberger
2012-06-27 15:57 ` [PATCH 04/16] UBI: Fastmap: Rename self_check_fastmap() Richard Weinberger
2012-06-28 12:44 ` Artem Bityutskiy [this message]
2012-06-27 15:57 ` [PATCH 05/16] UBI: Fastmap: Address a TODO Richard Weinberger
2012-06-27 15:57 ` [PATCH 06/16] UBI: Fastmap: Address another TODO Richard Weinberger
2012-06-27 15:57 ` [PATCH 07/16] UBI: Fastmap: Address jet another TOOD Richard Weinberger
2012-06-27 15:57 ` [PATCH 08/16] UBI: Fastmap: Address " Richard Weinberger
2012-06-27 15:57 ` [PATCH 09/16] UBI: Fastmap: Be more verbose on fastmap failure Richard Weinberger
2012-06-27 15:57 ` [PATCH 10/16] UBI: Fastmap: More kernel doc updates Richard Weinberger
2012-06-27 15:57 ` [PATCH 11/16] UBI: Fastmap: Store pool sizes in fastmap Richard Weinberger
2012-06-27 15:57 ` [PATCH 12/16] UBI: Fastmap: Make checkpatch.pl happy Richard Weinberger
2012-06-27 15:57 ` [PATCH 13/16] UBI: Fastmap: Remove one point from TODO list Richard Weinberger
2012-06-27 15:57 ` [PATCH 14/16] " Richard Weinberger
2012-06-27 15:57 ` [PATCH 15/16] " Richard Weinberger
2012-06-27 15:57 ` [PATCH 16/16] " 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=1340887459.3070.100.camel@sauron.fi.intel.com \
--to=artem.bityutskiy@linux.intel.com \
--cc=Heinz.Egger@linutronix.de \
--cc=Marius.Mazarel@ugal.ro \
--cc=adrian.hunter@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=nyoushchenko@mvista.com \
--cc=richard@nod.at \
--cc=shmulik.ladkani@gmail.com \
--cc=tglx@linutronix.de \
--cc=thomas.wucher@linutronix.de \
--cc=tim.bird@am.sony.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).