aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2023-08-28 14:38:35 +0800
committerRichard Weinberger <richard@nod.at>2023-10-28 22:32:58 +0200
commit08a4267874164b2e9c8c50831acd466f47208acc (patch)
tree2e5fc76227813d51c5a4da1f5c2f88fc615c7420
parent4d18b5a57b16c21cf868369ca555068722c32b2d (diff)
downloadubifs-08a4267874164b2e9c8c50831acd466f47208acc.tar.gz
ubi: fastmap: erase_block: Get erase counter from wl_entry rather than flash
Just like sync_erase() does, getting erase counter from wl_entry is faster than reading from flash. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--drivers/mtd/ubi/fastmap.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index f8c230acc55e74..05ecdc04934349 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1399,36 +1399,27 @@ out:
*/
static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)
{
- int ret;
+ int err;
struct ubi_ec_hdr *ec_hdr;
- long long ec;
+ long long ec = e->ec;
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
if (!ec_hdr)
return -ENOMEM;
- ret = ubi_io_read_ec_hdr(ubi, e->pnum, ec_hdr, 0);
- if (ret < 0)
- goto out;
- else if (ret && ret != UBI_IO_BITFLIPS) {
- ret = -EINVAL;
- goto out;
- }
-
- ret = ubi_io_sync_erase(ubi, e->pnum, 0);
- if (ret < 0)
+ err = ubi_io_sync_erase(ubi, e->pnum, 0);
+ if (err < 0)
goto out;
- ec = be64_to_cpu(ec_hdr->ec);
- ec += ret;
+ ec += err;
if (ec > UBI_MAX_ERASECOUNTER) {
- ret = -EINVAL;
+ err = -EINVAL;
goto out;
}
ec_hdr->ec = cpu_to_be64(ec);
- ret = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
- if (ret < 0)
+ err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
+ if (err < 0)
goto out;
e->ec = ec;
@@ -1439,7 +1430,7 @@ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)
out:
kfree(ec_hdr);
- return ret;
+ return err;
}
/**