Commit 4d18b5a
ubi: fastmap: Fix missed ec updating after erasing old fastmap data block
After running fsstress on ubifs for a long time, UBI(16384 blocks,
fastmap takes 2 blocks) has an erase block with different erase
counters displayed from two views:
From ubiscan view: PEB 8031 has erase counter 31581
=========================================================
from to count min avg max
---------------------------------------------------------
0 .. 9: 0 0 0 0
10 .. 99: 0 0 0 0
100 .. 999: 16383 290 315 781
1000 .. 9999: 0 0 0 0
10000 .. 99999: 1 31581 31581 31581
100000 .. inf: 0 0 0 0
---------------------------------------------------------
Total : 16384 290 317 31581
From detailed_erase_block_info view: PEB 8031 has erase counter 7
physical_block_number erase_count
8030 421
8031 7 # mem info is different from disk info
8032 434
8033 425
8034 431
Following process missed updating erase counter in wl_entry(in memory):
ubi_update_fastmap
for (i = 1; i < new_fm->used_blocks; i++) // update fastmap data
if (!tmp_e)
if (old_fm && old_fm->e[i])
erase_block(ubi, old_fm->e[i]->pnum)
ret = ubi_io_sync_erase(ubi, pnum, 0)
ec = be64_to_cpu(ec_hdr->ec)
ec += ret
ec_hdr->ec = cpu_to_be64(ec)
ubi_io_write_ec_hdr(ubi, pnum, ec_hdr) // ec is updated on flash
// ec is not updated in old_fm->e[i] (in memory)
Fix it by passing wl_enter into erase_block() and updating erase
counter in erase_block().
Fixes: dbb7d2a ("UBI: Add fastmap core")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>1 parent 60f2f4a commit 4d18b5a
1 file changed
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1392 | 1392 | | |
1393 | 1393 | | |
1394 | 1394 | | |
1395 | | - | |
| 1395 | + | |
1396 | 1396 | | |
1397 | | - | |
| 1397 | + | |
| 1398 | + | |
1398 | 1399 | | |
1399 | | - | |
| 1400 | + | |
1400 | 1401 | | |
1401 | 1402 | | |
1402 | 1403 | | |
| |||
1406 | 1407 | | |
1407 | 1408 | | |
1408 | 1409 | | |
1409 | | - | |
| 1410 | + | |
1410 | 1411 | | |
1411 | 1412 | | |
1412 | 1413 | | |
1413 | 1414 | | |
1414 | 1415 | | |
1415 | 1416 | | |
1416 | 1417 | | |
1417 | | - | |
| 1418 | + | |
1418 | 1419 | | |
1419 | 1420 | | |
1420 | 1421 | | |
| |||
1426 | 1427 | | |
1427 | 1428 | | |
1428 | 1429 | | |
1429 | | - | |
| 1430 | + | |
1430 | 1431 | | |
1431 | 1432 | | |
1432 | 1433 | | |
1433 | | - | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
1434 | 1440 | | |
1435 | 1441 | | |
1436 | 1442 | | |
| |||
1576 | 1582 | | |
1577 | 1583 | | |
1578 | 1584 | | |
1579 | | - | |
| 1585 | + | |
1580 | 1586 | | |
1581 | 1587 | | |
1582 | 1588 | | |
| |||
1628 | 1634 | | |
1629 | 1635 | | |
1630 | 1636 | | |
1631 | | - | |
| 1637 | + | |
1632 | 1638 | | |
1633 | 1639 | | |
1634 | 1640 | | |
| |||
1640 | 1646 | | |
1641 | 1647 | | |
1642 | 1648 | | |
1643 | | - | |
1644 | 1649 | | |
1645 | 1650 | | |
1646 | 1651 | | |
| |||
0 commit comments