Skip to content

Guard the inode write operation for readonly FS - #103

Merged
jserv merged 1 commit into
sysprog21:masterfrom
ChinYikMing:write-inode-guardrail
Nov 7, 2026
Merged

jserv merged 1 commit into
sysprog21:masterfrom
ChinYikMing:write-inode-guardrail

Conversation

@ChinYikMing

@ChinYikMing ChinYikMing commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Userspace ls command running on rv32emu emulated guestOS v6.18.x generates write traffic on the filesystem which is not typically expected and hangs the emulator to umount the simplefs disk.

The readonly guardrail fixes the issue.

[  272.359329] Call Trace:
[  272.359512] [<c0009f54>] dump_backtrace+0x2c/0x3c [  272.359921] [<c0001280>] show_stack+0x3c/0x50
[  272.360256] [<c00057e0>] dump_stack_lvl+0x4c/0x74 [  272.360634] [<c0005824>] dump_stack+0x1c/0x2c
[  272.360999] [<c01d3ec4>] submit_bio_noacct+0xd8/0x2e4 [  272.361410] [<c01d41cc>] submit_bio+0xfc/0x10c
[  272.361795] [<c012d8d4>] submit_bh_wbc.isra.0+0x15c/0x178 [  272.362240] [<c012d908>] submit_bh+0x18/0x28
[  272.362637] [<c012da18>] __sync_dirty_buffer+0x84/0xc0 [  272.363071] [<c012da70>] sync_dirty_buffer+0x1c/0x2c [  272.363499] [<a40283b0>] simplefs_write_inode+0x108/0x138 [simplefs] [  272.366368] [<c011d878>] __writeback_single_inode+0x1b0/0x1b4 [  272.366789] [<c011da4c>] writeback_sb_inodes+0x1d0/0x3b4 [  272.367192] [<c011dcb8>] __writeback_inodes_wb+0x88/0xe0 [  272.367593] [<c011e078>] wb_writeback.isra.0+0x154/0x174 [  272.367996] [<c011e7c4>] wb_workfn+0x168/0x28c
[  272.368372] [<c0028be0>] process_scheduled_works+0x1dc/0x294 [  272.368774] [<c0028df0>] worker_thread+0x158/0x1e8 [  272.369143] [<c0030760>] kthread+0x170/0x174
[  272.369482] [<c0007cb8>] ret_from_fork_kernel+0x1c/0x74 [  272.369898] [<c03e1e90>] ret_from_exception_end+0x1c/0x20

Summary by cubic

Prevents simplefs writeback on read-only filesystems, which was hanging the emulator during umount when running ls on the guestOS.

  • simplefs_write_inode now returns early when the superblock is read-only, skipping the write path entirely.

Written for commit feb243b. Summary will update on new commits.

View guided diff

Userspace ls command running on rv32emu emulated guestOS v6.18.x
generates write traffic on the filesystem which is not typically
expected and hangs the emulator to umount the simplefs disk.

The readonly guardrail fixes the issue.

[  272.359329] Call Trace:
[  272.359512] [<c0009f54>] dump_backtrace+0x2c/0x3c
[  272.359921] [<c0001280>] show_stack+0x3c/0x50
[  272.360256] [<c00057e0>] dump_stack_lvl+0x4c/0x74
[  272.360634] [<c0005824>] dump_stack+0x1c/0x2c
[  272.360999] [<c01d3ec4>] submit_bio_noacct+0xd8/0x2e4
[  272.361410] [<c01d41cc>] submit_bio+0xfc/0x10c
[  272.361795] [<c012d8d4>] submit_bh_wbc.isra.0+0x15c/0x178
[  272.362240] [<c012d908>] submit_bh+0x18/0x28
[  272.362637] [<c012da18>] __sync_dirty_buffer+0x84/0xc0
[  272.363071] [<c012da70>] sync_dirty_buffer+0x1c/0x2c
[  272.363499] [<a40283b0>] simplefs_write_inode+0x108/0x138 [simplefs]
[  272.366368] [<c011d878>] __writeback_single_inode+0x1b0/0x1b4
[  272.366789] [<c011da4c>] writeback_sb_inodes+0x1d0/0x3b4
[  272.367192] [<c011dcb8>] __writeback_inodes_wb+0x88/0xe0
[  272.367593] [<c011e078>] wb_writeback.isra.0+0x154/0x174
[  272.367996] [<c011e7c4>] wb_workfn+0x168/0x28c
[  272.368372] [<c0028be0>] process_scheduled_works+0x1dc/0x294
[  272.368774] [<c0028df0>] worker_thread+0x158/0x1e8
[  272.369143] [<c0030760>] kthread+0x170/0x174
[  272.369482] [<c0007cb8>] ret_from_fork_kernel+0x1c/0x74
[  272.369898] [<c03e1e90>] ret_from_exception_end+0x1c/0x20
cubic-dev-ai[bot]

This comment was marked as resolved.

@ChinYikMing

Copy link
Copy Markdown
Contributor Author

This changes pass the simplefs boot test CI on rv32emu: https://github.com/sysprog21/rv32emu/actions/runs/42382983991/job/128438633546

Note that the CI status on rv32emu CI is fail, but actually they are the error of the virtio sound on Linux host and others.

@jserv
jserv merged commit 4f9e6dc into sysprog21:master Nov 7, 2026
4 checks passed
@jserv

jserv commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Thank @ChinYikMing for contributing!

ChinYikMing added a commit to ChinYikMing/rv32emu that referenced this pull request Nov 8, 2026
4f9e6dc2a2d1cdbe5a697ccb35c6c4d5c8926951 version fixes the write traffic
when running userspace read command. [1]

$ find /tmp/simplefs -type f -not -path '*/.git/*' -print0 | LC_ALL=C \
sort -z |  xargs -0 sha1sum | LC_ALL=C sort | sha1sum [2]
12cee9d0095fbdf4bfcdae407fd30ae11bbfacef  -

[1] sysprog21/simplefs#103
[2] https://github.com/sysprog21/rv32emu/blob/ffb041bab9d1513e5329f25f486378778dceed13/mk/external.mk#L162
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants