From feb243b1704dca86d690c297f9f8a6fa8902bfaf Mon Sep 17 00:00:00 2001 From: ChinYikMing Date: Sat, 7 Nov 2026 20:16:59 +0800 Subject: [PATCH] Guard the inode write operation for readonly FS 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] [] dump_backtrace+0x2c/0x3c [ 272.359921] [] show_stack+0x3c/0x50 [ 272.360256] [] dump_stack_lvl+0x4c/0x74 [ 272.360634] [] dump_stack+0x1c/0x2c [ 272.360999] [] submit_bio_noacct+0xd8/0x2e4 [ 272.361410] [] submit_bio+0xfc/0x10c [ 272.361795] [] submit_bh_wbc.isra.0+0x15c/0x178 [ 272.362240] [] submit_bh+0x18/0x28 [ 272.362637] [] __sync_dirty_buffer+0x84/0xc0 [ 272.363071] [] sync_dirty_buffer+0x1c/0x2c [ 272.363499] [] simplefs_write_inode+0x108/0x138 [simplefs] [ 272.366368] [] __writeback_single_inode+0x1b0/0x1b4 [ 272.366789] [] writeback_sb_inodes+0x1d0/0x3b4 [ 272.367192] [] __writeback_inodes_wb+0x88/0xe0 [ 272.367593] [] wb_writeback.isra.0+0x154/0x174 [ 272.367996] [] wb_workfn+0x168/0x28c [ 272.368372] [] process_scheduled_works+0x1dc/0x294 [ 272.368774] [] worker_thread+0x158/0x1e8 [ 272.369143] [] kthread+0x170/0x174 [ 272.369482] [] ret_from_fork_kernel+0x1c/0x74 [ 272.369898] [] ret_from_exception_end+0x1c/0x20 --- super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/super.c b/super.c index ffd8628..685f8b3 100644 --- a/super.c +++ b/super.c @@ -75,6 +75,9 @@ static int simplefs_write_inode(struct inode *inode, uint32_t inode_block = (ino / SIMPLEFS_INODES_PER_BLOCK) + 1; uint32_t inode_shift = ino % SIMPLEFS_INODES_PER_BLOCK; + if (sb_rdonly(inode->i_sb)) + return 0; + if (ino >= sbi->nr_inodes) return 0;