Fix post-remount soft-lockup by persisting new directory block init#90
Open
RoyWFHuang wants to merge 1 commit into
Open
Fix post-remount soft-lockup by persisting new directory block init#90RoyWFHuang wants to merge 1 commit into
RoyWFHuang wants to merge 1 commit into
Conversation
simplefs_get_new_ext() initializes each new directory block with files[0].nr_blk = SIMPLEFS_FILES_PER_BLOCK but released the buffer without mark_buffer_dirty(), so the init was never written back. After a remount the block reads back all-zero (nr_blk == 0) and the "_fi += nr_blk" scan in __file_lookup() never advances -> kernel soft-lockup.
This was referenced Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
get_free_blocks() (bitmap.h) zeroes each of the 8 blocks (SIMPLEFS_MAX_BLOCKS_PER_EXTENT) of a new extent and sync_dirty_buffer()s them → on disk every block is all-zero.
simplefs_get_new_ext() (inode.c) writes files[0].nr_blk = SIMPLEFS_FILES_PER_BLOCK into each block, but releases the buffer with brelse() only — no mark_buffer_dirty() — so the initialization lives only in the page cache and is never written back.
simplefs_create() inserts the file into a single block and marks only that block (and the ei_block) dirty. The remaining blocks of the extent are never dirtied → they stay all-zero on disk.
On unmount, simplefs_put_super() does sync_blockdev(), flushes only dirty buffers(drops the cached). On remount the blocks are read from disk as {inode: 0, nr_blk: 0}.
Closes #89
Summary by cubic
Persist directory block initialization by marking new dir block buffers dirty in
simplefs_get_new_ext(), preventing post-remount soft-lockups.mark_buffer_dirty(bh)after settingfiles[0].nr_blk = SIMPLEFS_FILES_PER_BLOCKso the init is written to disk.nr_blk == 0, which caused__file_lookup()to loop and soft-lock the kernel.Written for commit a75f22e. Summary will update on new commits.