From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: Heinz.Egger@linutronix.de, tglx@linutronix.de,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
tim.bird@am.sony.com
Subject: Re: [PATCH 1/7] [RFC] UBI: Export next_sqnum()
Date: Wed, 16 May 2012 16:01:12 +0300 [thread overview]
Message-ID: <1337173272.24809.52.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1337101871-31181-2-git-send-email-richard@nod.at>
[-- Attachment #1: Type: text/plain, Size: 3591 bytes --]
On Tue, 2012-05-15 at 19:11 +0200, Richard Weinberger wrote:
> The fastmap mechanism needs to read the next sequence nummber
> directly.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
I started looking at the code, and made some notes at the same time and
few minor changes - here is the diff which you can apply on top of your
patches.
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 2399511..2f5c362 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -869,15 +869,22 @@ static int attach_by_fastmap(struct ubi_device *ubi)
fm_start = ubi_find_fastmap(ubi);
if (fm_start < 0)
+ /* TODO: instead, return 1 which means that fall-back to
+ * scanning is needed */
return -ENOENT;
+ /* TODO: we need to re-name scan.h to attach.h, scan_info to
+ * attach_info, si to ai, seb to aeb, and so on - because we share the
+ * same data structures between scanning and fastmap, so the word
+ * "scan" is not very sensible to have in the name any more.
+ */
si = ubi_read_fastmap(ubi, fm_start);
if (IS_ERR(si))
return PTR_ERR(si);
- ubi->bad_peb_count = 0;
+ /* TODO: the rest looks very much like attach_by_scanning() - we
+ * need to re-structure the code and avoid duplication */
ubi->good_peb_count = ubi->peb_count;
- ubi->corr_peb_count = 0;
ubi->max_ec = si->max_ec;
ubi->mean_ec = si->mean_ec;
ubi_msg("max. sequence number: %llu", si->max_sqnum);
@@ -888,6 +895,7 @@ static int attach_by_fastmap(struct ubi_device *ubi)
goto out_si;
}
+ /* TODO: the _scan suffix makes no sens anymore - kill it */
err = ubi_wl_init_scan(ubi, si);
if (err) {
ubi_err("ubi_wl_init_scan failed!");
@@ -1022,7 +1030,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
err = attach_by_fastmap(ubi);
if (err) {
if (err != -ENOENT)
- ubi_msg("falling back to attach by scanning mode!");
+ ubi_msg("falling back to attach by scanning");
ubi->attached_by_scanning = true;
err = attach_by_scanning(ubi);
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 2ea1682..7c5f1f7 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -582,7 +582,12 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
goto out;
}
+ /* TODO: Before checking version - check the CRC.
+ * I think you need to add a separate helper function in io.c, similar
+ * to ubi_io_read_vid_hdr(). */
if (fmsb->version != UBI_FM_FMT_VERSION) {
+ /* TODO: we can fall back to scanning instead of saying good
+ * bye! */
ubi_err("Unknown fastmap format version!");
si = ERR_PTR(-EINVAL);
kfree(fmsb);
@@ -606,6 +611,7 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
if (!fm_raw) {
si = ERR_PTR(-ENOMEM);
kfree(fmsb);
+ /* TODO: goto? */
}
vh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
@@ -617,6 +623,9 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
}
for (i = 0; i < nblocks; i++) {
+ /* TODO: you basically perform the scanning here - you should
+ * share the same code as we use in scan.c: use process_peb().
+ */
ret = ubi_io_read_vid_hdr(ubi, be32_to_cpu(fmsb->block_loc[i]),
vh, 0);
if (ret) {
@@ -653,6 +662,7 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
i, be32_to_cpu(fmsb->block_loc[i]));
si = ERR_PTR(ret);
+ /* TODO: fsmb is not freed? */
goto free_vhdr;
}
}
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Artem Bityutskiy <dedekind1@gmail.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, Heinz.Egger@linutronix.de,
tim.bird@am.sony.com
Subject: Re: [PATCH 1/7] [RFC] UBI: Export next_sqnum()
Date: Wed, 16 May 2012 16:01:12 +0300 [thread overview]
Message-ID: <1337173272.24809.52.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <1337101871-31181-2-git-send-email-richard@nod.at>
[-- Attachment #1: Type: text/plain, Size: 3591 bytes --]
On Tue, 2012-05-15 at 19:11 +0200, Richard Weinberger wrote:
> The fastmap mechanism needs to read the next sequence nummber
> directly.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
I started looking at the code, and made some notes at the same time and
few minor changes - here is the diff which you can apply on top of your
patches.
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 2399511..2f5c362 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -869,15 +869,22 @@ static int attach_by_fastmap(struct ubi_device *ubi)
fm_start = ubi_find_fastmap(ubi);
if (fm_start < 0)
+ /* TODO: instead, return 1 which means that fall-back to
+ * scanning is needed */
return -ENOENT;
+ /* TODO: we need to re-name scan.h to attach.h, scan_info to
+ * attach_info, si to ai, seb to aeb, and so on - because we share the
+ * same data structures between scanning and fastmap, so the word
+ * "scan" is not very sensible to have in the name any more.
+ */
si = ubi_read_fastmap(ubi, fm_start);
if (IS_ERR(si))
return PTR_ERR(si);
- ubi->bad_peb_count = 0;
+ /* TODO: the rest looks very much like attach_by_scanning() - we
+ * need to re-structure the code and avoid duplication */
ubi->good_peb_count = ubi->peb_count;
- ubi->corr_peb_count = 0;
ubi->max_ec = si->max_ec;
ubi->mean_ec = si->mean_ec;
ubi_msg("max. sequence number: %llu", si->max_sqnum);
@@ -888,6 +895,7 @@ static int attach_by_fastmap(struct ubi_device *ubi)
goto out_si;
}
+ /* TODO: the _scan suffix makes no sens anymore - kill it */
err = ubi_wl_init_scan(ubi, si);
if (err) {
ubi_err("ubi_wl_init_scan failed!");
@@ -1022,7 +1030,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
err = attach_by_fastmap(ubi);
if (err) {
if (err != -ENOENT)
- ubi_msg("falling back to attach by scanning mode!");
+ ubi_msg("falling back to attach by scanning");
ubi->attached_by_scanning = true;
err = attach_by_scanning(ubi);
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 2ea1682..7c5f1f7 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -582,7 +582,12 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
goto out;
}
+ /* TODO: Before checking version - check the CRC.
+ * I think you need to add a separate helper function in io.c, similar
+ * to ubi_io_read_vid_hdr(). */
if (fmsb->version != UBI_FM_FMT_VERSION) {
+ /* TODO: we can fall back to scanning instead of saying good
+ * bye! */
ubi_err("Unknown fastmap format version!");
si = ERR_PTR(-EINVAL);
kfree(fmsb);
@@ -606,6 +611,7 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
if (!fm_raw) {
si = ERR_PTR(-ENOMEM);
kfree(fmsb);
+ /* TODO: goto? */
}
vh = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
@@ -617,6 +623,9 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
}
for (i = 0; i < nblocks; i++) {
+ /* TODO: you basically perform the scanning here - you should
+ * share the same code as we use in scan.c: use process_peb().
+ */
ret = ubi_io_read_vid_hdr(ubi, be32_to_cpu(fmsb->block_loc[i]),
vh, 0);
if (ret) {
@@ -653,6 +662,7 @@ struct ubi_scan_info *ubi_read_fastmap(struct ubi_device *ubi,
i, be32_to_cpu(fmsb->block_loc[i]));
si = ERR_PTR(ret);
+ /* TODO: fsmb is not freed? */
goto free_vhdr;
}
}
--
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-05-16 12:57 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-15 17:11 [RFC v4] UBI: Fastmap support (aka checkpointing) Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:11 ` [PATCH 1/7] [RFC] UBI: Export next_sqnum() Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-16 13:01 ` Artem Bityutskiy [this message]
2012-05-16 13:01 ` Artem Bityutskiy
2012-05-21 13:34 ` Richard Weinberger
2012-05-21 13:34 ` Richard Weinberger
2012-05-21 14:00 ` Artem Bityutskiy
2012-05-21 14:00 ` Artem Bityutskiy
2012-05-21 14:16 ` Richard Weinberger
2012-05-21 14:16 ` Richard Weinberger
2012-05-22 8:23 ` Artem Bityutskiy
2012-05-22 8:23 ` Artem Bityutskiy
2012-05-22 10:58 ` Artem Bityutskiy
2012-05-22 10:58 ` Artem Bityutskiy
2012-05-16 14:03 ` Shmulik Ladkani
2012-05-16 14:03 ` Shmulik Ladkani
2012-05-16 14:27 ` Artem Bityutskiy
2012-05-16 14:27 ` Artem Bityutskiy
2012-05-17 9:45 ` Shmulik Ladkani
2012-05-17 9:45 ` Shmulik Ladkani
2012-05-17 11:44 ` Artem Bityutskiy
2012-05-17 11:44 ` Artem Bityutskiy
2012-05-17 11:47 ` Richard Weinberger
2012-05-17 11:47 ` Richard Weinberger
2012-05-17 12:34 ` Artem Bityutskiy
2012-05-17 12:34 ` Artem Bityutskiy
2012-05-15 17:11 ` [PATCH 2/7] [RFC] UBI: Export compare_lebs() Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-16 14:09 ` Shmulik Ladkani
2012-05-16 14:09 ` Shmulik Ladkani
2012-05-15 17:11 ` [PATCH 3/7] [RFC] UBI: Add fastmap on-flash layout Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:11 ` [PATCH 4/7] [RFC] UBI: Add fastmap structs to ubi_device Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:11 ` [PATCH 5/7] [RFC] UBI: Make wl subsystem fastmap aware Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:11 ` [PATCH 6/7] [RFC] UBI: Implement fastmapping support Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:11 ` [PATCH 7/7] [RFC] UBI: Wire up fastmap support Richard Weinberger
2012-05-15 17:11 ` Richard Weinberger
2012-05-15 17:48 ` [RFC v4] UBI: Fastmap support (aka checkpointing) Subodh Nijsure
2012-05-15 17:48 ` Subodh Nijsure
2012-05-15 18:10 ` Richard Weinberger
2012-05-15 18:10 ` Richard Weinberger
2012-05-15 18:02 ` Richard Weinberger
2012-05-15 18:02 ` Richard Weinberger
2012-05-15 19:46 ` Shmulik Ladkani
2012-05-15 19:46 ` Shmulik Ladkani
2012-05-16 6:54 ` Fastmap - please, review and test Artem Bityutskiy
2012-05-16 6:54 ` Artem Bityutskiy
2012-05-16 11:51 ` Richard Weinberger
2012-05-16 11:51 ` Richard Weinberger
2012-05-16 9:38 ` [RFC v4] UBI: Fastmap support (aka checkpointing) Artem Bityutskiy
2012-05-16 9:38 ` Artem Bityutskiy
2012-05-16 9:42 ` Artem Bityutskiy
2012-05-16 9:42 ` Artem Bityutskiy
2012-05-16 10:50 ` Richard Weinberger
2012-05-16 10:50 ` Richard Weinberger
2012-05-16 11:09 ` Artem Bityutskiy
2012-05-16 11:09 ` Artem Bityutskiy
2012-05-16 11:18 ` Artem Bityutskiy
2012-05-16 11:18 ` Artem Bityutskiy
2012-05-16 11:29 ` Richard Weinberger
2012-05-16 11:29 ` Richard Weinberger
-- strict thread matches above, loose matches on Subject: below --
2012-05-16 20:51 [RFC v5] " Richard Weinberger
2012-05-16 20:51 ` [PATCH 1/7] [RFC] UBI: Export next_sqnum() Richard Weinberger
2012-05-16 20:51 ` Richard Weinberger
2012-05-17 12:12 ` Artem Bityutskiy
2012-05-17 12:12 ` Artem Bityutskiy
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=1337173272.24809.52.camel@sauron.fi.intel.com \
--to=dedekind1@gmail.com \
--cc=Heinz.Egger@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=tglx@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 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.