Skip to content

Fix post-remount soft-lockup by persisting new directory block init#90

Open
RoyWFHuang wants to merge 1 commit into
sysprog21:masterfrom
RoyWFHuang:bug/issue89
Open

Fix post-remount soft-lockup by persisting new directory block init#90
RoyWFHuang wants to merge 1 commit into
sysprog21:masterfrom
RoyWFHuang:bug/issue89

Conversation

@RoyWFHuang

@RoyWFHuang RoyWFHuang commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

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.

  • Bug Fixes
    • Call mark_buffer_dirty(bh) after setting files[0].nr_blk = SIMPLEFS_FILES_PER_BLOCK so the init is written to disk.
    • Prevents remount reading nr_blk == 0, which caused __file_lookup() to loop and soft-lock the kernel.

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

Review in cubic

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

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.

Soft-lockup (unkillable hang) when looking up a name in a directory after remount

1 participant