Linux

掛載文件系統時核心不會跳過壞塊

  • June 2, 2014

我正在使用友好ARM 的micro2440為嵌入式 Linux 應用程序開發。它在三星 s3c2440 ARM 處理器上執行,並在其 NAND 快閃記憶體中使用 squashfs。

最近,一些快閃記憶體塊壞了。u-Boot 正確找到它們並使用 nand bad 命令給出的偏移量創建一個壞塊表:

Device 0 bad blocks:
01340000
0abc0000
0f080000
0ff80000
0ffa0000
0ffc0000
0ffe0000

當我嘗試啟動核心時,它會正確掃描壞塊並創建其壞塊表,如以下消息所示:

Scanning device for bad blocks
Bad eraseblock 154 at 0x000001340000
Bad eraseblock 1374 at 0x00000abc0000
Bad eraseblock 1924 at 0x00000f080000

但是當核心需要將文件系統掛載到發生 0x000001340000 壞塊的分區中時,它似乎無法跳過壞塊,然後它就會崩潰。給出的錯誤消息是:

SQUASHFS error: squashfs_read_data failed to read block 0xd0e24b
SQUASHFS error: Unable to read metadata cache entry [d0e24b]
SQUASHFS error: Unable to read inode 0x3d1d0f68
------------[ cut here ]------------
WARNING: at fs/inode.c:712 unlock_new_inode+0x20/0x3c()
Modules linked in:
[<c0037750>] (unwind_backtrace+0x0/0xcc) from [<c0044994>]                             (warn_slowpath_null+0x34/0x4c)
[<c0044994>] (warn_slowpath_null+0x34/0x4c) from [<c00a42c8>] (unlock_new_inode+0x20/0x3c)
[<c00a42c8>] (unlock_new_inode+0x20/0x3c) from [<c00a61b8>] (iget_failed+0x14/0x20)
[<c00a61b8>] (iget_failed+0x14/0x20) from [<c00f75cc>] (squashfs_fill_super+0x3c8/0x508)
[<c00f75cc>] (squashfs_fill_super+0x3c8/0x508) from [<c0095990>] (get_sb_bdev+0x110/0x16c)
[<c0095990>] (get_sb_bdev+0x110/0x16c) from [<c00f7164>] (squashfs_get_sb+0x18/0x20)
[<c00f7164>] (squashfs_get_sb+0x18/0x20) from [<c0095008>] (vfs_kern_mount+0x44/0xd8)
[<c0095008>] (vfs_kern_mount+0x44/0xd8) from [<c00950e0>] (do_kern_mount+0x34/0xe0)
[<c00950e0>] (do_kern_mount+0x34/0xe0) from [<c00a9084>] (do_mount+0x5d8/0x658)
[<c00a9084>] (do_mount+0x5d8/0x658) from [<c00a9330>] (sys_mount+0x84/0xc4)
[<c00a9330>] (sys_mount+0x84/0xc4) from [<c0008c60>] (mount_block_root+0xe4/0x20c)
[<c0008c60>] (mount_block_root+0xe4/0x20c) from [<c00090fc>] (prepare_namespace+0x160/0x1c0)
[<c00090fc>] (prepare_namespace+0x160/0x1c0) from [<c00089c8>] (kernel_init+0xd8/0x104)
[<c00089c8>] (kernel_init+0xd8/0x104) from [<c0033738>] (kernel_thread_exit+0x0/0x8)
---[ end trace c21b44698de8995c ]---
VFS: Cannot open root device "mtdblock5" or unknown-block(31,5)
Please append a correct "root=" boot option; here are the available         partitions:
1f00             256 mtdblock0 (driver?)
1f01             128 mtdblock1 (driver?)
1f02             640 mtdblock2 (driver?)
1f03            5120 mtdblock3 (driver?)
1f04            5120 mtdblock4 (driver?)
1f05           40960 mtdblock5 (driver?)
1f06           40960 mtdblock6 (driver?)
1f07          167936 mtdblock7 (driver?)
1f08            1024 mtdblock8 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,5)
[<c0037750>] (unwind_backtrace+0x0/0xcc) from [<c02fdd40>] (panic+0x3c/0x114)
[<c02fdd40>] (panic+0x3c/0x114) from [<c0008d44>] (mount_block_root+0x1c8/0x20c)
[<c0008d44>] (mount_block_root+0x1c8/0x20c) from [<c00090fc>] (prepare_namespace+0x160/0x1c0)
[<c00090fc>] (prepare_namespace+0x160/0x1c0) from [<c00089c8>] (kernel_init+0xd8/0x104)
[<c00089c8>] (kernel_init+0xd8/0x104) from [<c0033738>] (kernel_thread_exit+0x0/0x8)

我嘗試在 mtdblock6 分區中安裝文件系統,並且一切都按預期工作,因為記憶體的那部分沒有壞塊。我調查了負責壞塊管理的 mtd 源文件,但我找不到關於核心如何跳過壞塊的有用資訊。

我們發現問題出在 squashfs 本身。它不支持壞塊檢測,如下所述:

http://elinux.org/Support_read-only_block_filesystems_on_MTD_flash

所以可能的解決方案是使用另一個文件系統或使用 UBI 來管理壞塊,然後繼續使用 squashfs。

您是否嘗試在引導參數中添加類似“rootdelay=2”(或更長,我相信最多 10 個)之類的內容?在核心訪問快閃記憶體之前,可能會給快閃記憶體一些額外的時間來解決問題。

引用自:https://unix.stackexchange.com/questions/132398