Skip to content

Commit 08a4267

Browse files
Zhihao Chengrichardweinberger
authored andcommitted
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 <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 4d18b5a commit 08a4267

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

drivers/mtd/ubi/fastmap.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,36 +1399,27 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
13991399
*/
14001400
static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)
14011401
{
1402-
int ret;
1402+
int err;
14031403
struct ubi_ec_hdr *ec_hdr;
1404-
long long ec;
1404+
long long ec = e->ec;
14051405

14061406
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
14071407
if (!ec_hdr)
14081408
return -ENOMEM;
14091409

1410-
ret = ubi_io_read_ec_hdr(ubi, e->pnum, ec_hdr, 0);
1411-
if (ret < 0)
1412-
goto out;
1413-
else if (ret && ret != UBI_IO_BITFLIPS) {
1414-
ret = -EINVAL;
1415-
goto out;
1416-
}
1417-
1418-
ret = ubi_io_sync_erase(ubi, e->pnum, 0);
1419-
if (ret < 0)
1410+
err = ubi_io_sync_erase(ubi, e->pnum, 0);
1411+
if (err < 0)
14201412
goto out;
14211413

1422-
ec = be64_to_cpu(ec_hdr->ec);
1423-
ec += ret;
1414+
ec += err;
14241415
if (ec > UBI_MAX_ERASECOUNTER) {
1425-
ret = -EINVAL;
1416+
err = -EINVAL;
14261417
goto out;
14271418
}
14281419

14291420
ec_hdr->ec = cpu_to_be64(ec);
1430-
ret = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
1431-
if (ret < 0)
1421+
err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
1422+
if (err < 0)
14321423
goto out;
14331424

14341425
e->ec = ec;
@@ -1439,7 +1430,7 @@ static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)
14391430

14401431
out:
14411432
kfree(ec_hdr);
1442-
return ret;
1433+
return err;
14431434
}
14441435

14451436
/**

0 commit comments

Comments
 (0)