Guard the inode write operation for readonly FS

Merged
CH
5d ago
+3-0

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.