Skip to content

Fix failed-mount teardown and CI regressions - #101

Merged
jserv merged 3 commits into
masterfrom
fix/failed-mount-teardown
Nov 4, 2026
Merged

jserv merged 3 commits into
masterfrom
fix/failed-mount-teardown

Conversation

@jserv

@jserv jserv commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Since 6.7, simplefs_kill_sb() read sb->s_fs_info to release the external journal device, but the VFS calls kill_sb even when fill_super failed, where that pointer is NULL (or already freed by fill_super's error path). This is the unmount crash described at sysprog21/rv32emu#827 (comment). kill_sb also dropped the journal device before put_super had finished using it. The journal device is now released at the end of simplefs_put_super(), as 5.10 to 6.5 already did, and kill_sb is just kill_block_super(); fill_super clears s_fs_info when it frees sbi.

The same route also had a handful of error-path bugs, fixed here: simplefs_get_dev_journal() returned NULL where the caller checks IS_ERR(), a double iput() after d_make_root() failure, a double brelse() of the superblock buffer, path references leaked or read after path_put(), and a bogus return value from option parsing.

The branch also carries the two fixes needed to get CI green, which were already failing on master. simplefs_write() returned 0 once the write position hit the maximum file size, and a caller that retries zero-byte writes spins forever; the CI image now ships uutils dd, which does, so test_too_large_file hung until the 6 hour job limit. It now returns -EFBIG as write(2) specifies and the test expects the failure. The coding_style job also flagged three clang-format deviations in mkfs.c and inode.c that predate this branch, reformatted in their own commit.

The teardown change was verified only by compiling fs.c and super.c against the 6.17 kernel headers in Lima; the module was not loaded or mounted and make check was not run. The 7.3+ branch (fs_bdev_file_release() in put_super) and the kernels below 6.17 were not built. Reviewed independently by Codex, Agy and Claude. Not addressed: mounting read-only should fail up front instead of surfacing later write errors, and journal_path pointing at a non-block file is still silently ignored.

Since 6.7, simplefs_kill_sb() dereferenced sb->s_fs_info to release the
external journal device, but the VFS calls kill_sb even when
fill_super failed, where that pointer is NULL or already freed. It also
released the device before put_super had finished using it.

Release the journal device in simplefs_put_super() after the journal is
torn down, which is where 5.10 to 6.5 already did it, and reduce
kill_sb to kill_block_super(). Clear s_fs_info when fill_super frees
sbi.

Also fix error paths hit on the same route: a NULL journal returned as
success, a double iput after d_make_root() failure, a double brelse,
leaked or prematurely dropped path references, and a bogus return value
from option parsing.

Co-authored-by: ChinYikMing <yikming2222@gmail.com>
cubic-dev-ai[bot]

This comment was marked as resolved.

@jserv jserv changed the title Fix teardown after a failed mount Fix failed-mount teardown and CI regressions Nov 4, 2026
cubic-dev-ai[bot]

This comment was marked as resolved.

jserv added 2 commits November 4, 2026 09:50
simplefs_write() clamped len to zero once pos reached the maximum
file size and returned 0. A caller that retries zero-byte writes, such
as uutils dd shipped with recent Ubuntu, then spins forever, which hung
the CI test for six hours.

Return -EFBIG instead, as write(2) specifies, and make the test report
a write over the limit that succeeds.
The coding_style CI job flags a compound literal brace and two
comment indents that predate this branch. Reformat them so the job
passes.
@jserv
jserv force-pushed the fix/failed-mount-teardown branch from 5231170 to 13e42e8 Compare November 4, 2026 01:51
@jserv
jserv merged commit 13b2cf5 into master Nov 4, 2026
7 checks passed
@jserv
jserv deleted the fix/failed-mount-teardown branch November 4, 2026 02:14
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.

1 participant