From: Hyunchul Lee <hyc.lee@gmail.com>
To: Richard Weinberger <richard@nod.at>,
Artem Bityutskiy <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
kernel-team@lge.com, Hyunchul Lee <cheol.lee@lge.com>
Subject: [PATCH] ubi: Remove ubi_io_is_bad call from scan_peb
Date: Tue, 26 Sep 2017 13:54:57 +0900 [thread overview]
Message-ID: <1506401697-449-1-git-send-email-hyc.lee@gmail.com> (raw)
From: Hyunchul Lee <cheol.lee@lge.com>
When erase count and volume identifier headers are read,
ubi_io_is_bad is called. So instead of calling ubi_io_is_bad
from scan_peb, use the result.
this patch reduces the attach time by about 15% in my
environment.
ARMv7 1GHZ based board, 66.8MiB MTD partition
before after
attach time 308.365 usec 257.100 usec
Signed-off-by: Hyunchul Lee <cheol.lee@lge.com>
---
drivers/mtd/ubi/attach.c | 15 ++++++---------
drivers/mtd/ubi/io.c | 9 ++++++---
drivers/mtd/ubi/ubi.h | 2 ++
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/mtd/ubi/attach.c b/drivers/mtd/ubi/attach.c
index 93ceea4..07b9162 100644
--- a/drivers/mtd/ubi/attach.c
+++ b/drivers/mtd/ubi/attach.c
@@ -962,15 +962,6 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
dbg_bld("scan PEB %d", pnum);
- /* Skip bad physical eraseblocks */
- err = ubi_io_is_bad(ubi, pnum);
- if (err < 0)
- return err;
- else if (err) {
- ai->bad_peb_count += 1;
- return 0;
- }
-
err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
if (err < 0)
return err;
@@ -999,6 +990,9 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
ec = UBI_UNKNOWN;
bitflips = 1;
break;
+ case UBI_IO_BAD_BLK:
+ ai->bad_peb_count += 1;
+ return 0;
default:
ubi_err(ubi, "'ubi_io_read_ec_hdr()' returned unknown code %d",
err);
@@ -1136,6 +1130,9 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
if (err)
return err;
goto adjust_mean_ec;
+ case UBI_IO_BAD_BLK:
+ ai->bad_peb_count += 1;
+ return 0;
default:
ubi_err(ubi, "'ubi_io_read_vid_hdr()' returned unknown code %d",
err);
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 8290432..ae52e7e 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -117,6 +117,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
* o %UBI_IO_BITFLIPS if all the requested data were successfully read, but
* correctable bit-flips were detected; this is harmless but may indicate
* that this eraseblock may become bad soon (but do not have to);
+ * o %UBI_IO_BAD_BLK if the erabse block is bad
* o %-EBADMSG if the MTD subsystem reported about data integrity problems, for
* example it can be an ECC error in case of NAND; this most probably means
* that the data is corrupted;
@@ -137,7 +138,9 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
ubi_assert(len > 0);
err = self_check_not_bad(ubi, pnum);
- if (err)
+ if (err == -EBADSLT)
+ return UBI_IO_BAD_BLK;
+ else if (err)
return err;
/*
@@ -1131,7 +1134,7 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
* @ubi: UBI device description object
* @pnum: physical eraseblock number to check
*
- * This function returns zero if the physical eraseblock is good, %-EINVAL if
+ * This function returns zero if the physical eraseblock is good, %-EBADSLT if
* it is bad and a negative error code if an error occurred.
*/
static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
@@ -1147,7 +1150,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
ubi_err(ubi, "self-check failed for PEB %d", pnum);
dump_stack();
- return err > 0 ? -EINVAL : err;
+ return err > 0 ? -EBADSLT : err;
}
/**
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 5fe6265..5c5207d 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -107,6 +107,7 @@
* data integrity error reported by the MTD driver
* (uncorrectable ECC error in case of NAND)
* UBI_IO_BITFLIPS: bit-flips were detected and corrected
+ * UBI_IO_BAD_BLK: bad erase block
*
* Note, it is probably better to have bit-flip and ebadmsg as flags which can
* be or'ed with other error code. But this is a big change because there are
@@ -118,6 +119,7 @@ enum {
UBI_IO_BAD_HDR,
UBI_IO_BAD_HDR_EBADMSG,
UBI_IO_BITFLIPS,
+ UBI_IO_BAD_BLK,
};
/*
--
1.9.1
next reply other threads:[~2017-09-26 4:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-26 4:54 Hyunchul Lee [this message]
2017-09-26 8:53 ` [PATCH] ubi: Remove ubi_io_is_bad call from scan_peb Hyeoncheol Lee
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=1506401697-449-1-git-send-email-hyc.lee@gmail.com \
--to=hyc.lee@gmail.com \
--cc=cheol.lee@lge.com \
--cc=dedekind1@gmail.com \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
/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