mirror of
https://github.com/RhapsodiOS/RhapsodiOS.git
synced 2026-11-03 22:01:40 -07:00
[GH-ISSUE #54] msdosfs: concurrent rename deadlocks on denode locks; the hang spreads to the root fs #47
Labels
No labels
bug
documentation
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/RhapsodiOS#47
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @raynorpat on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/RhapsodiOS/RhapsodiOS/issues/54
Symptom
stress-fs -n 4 -s 1 -d /mnt/m rw append tree fsync rename linkon a FAT16volume hangs in the
renametest (rw/append/tree/fsync had passed). All workerssleep in state
Uondenodelocks. Other processes thatstata path through/mntthen block on the root UFSinodelocks of/mntand/, so ssh loginshang too. No panic. Kernel
mach_kernel.issue43(cksum 1562297808, built Oct 15),which contains the #45 msdosfs rename changes (
89e39d0b2,b2381210b,0f1627e08).QEMU gdbstub dump (
msdos-1-hang-threads.txt,msdos-1-hang-locks.txt):rename-> msdosfs_rename (static) ->relookup->vn_lockstat->lookup-> msdosfs_lookup ->deget->vget->vn_lockopen->lookup-> msdosfs_lookuprename->namei-> msdosfs_lookupstat->lookup->degetstat->ufs_lookup(root fs)1747 and 1749 are a two-process lock-order cycle. 1747, the renamer, holds
denode lock 20241204 and waits in
relookupfor 20241884. 1749, in anordinary lookup, holds 20241884 and waits in
degetfor 20241204. Theother waiters queue behind them, and a lookup holding a root-fs vnode lock
spreads the hang to the root fs.
A second hang came from
stress-fs -n 4 -s 3 -d /mnt/m renamerun on itsown (
msdos-3-hang-*.txt). This time two renamers deadlocked each other.Both were in
rename-> msdosfs_rename ->relookup->vn_lock: 1348waited for 2028a604, held by 1349, and 1349 waited for 2028a804, held by
1348. Overall,
renamehung 2 of 5 runs (seeds 1 and 3; seeds 1, 2 and 2passed in their other runs).
After a hard stop,
fsck_msdos -nreported the volume clean the first time(106 leftover files) and 6 lost 2-cluster chains the second time.
Reproduce
i386 QEMU guest. Partition a of a 512-byte-sector NeXT-labelled disk
(
vm/ext2_guest.py wrap_volumelayout), formatted on the guest withnewfs_msdos -s 524288 /dev/rhd2a(FAT16, 4 KiB clusters) and mounted withmount_msdos /dev/hd2a /mnt/m. Toolsmount_msdos/newfs_msdos/fsck_msdosfrom
vm/work/fs-races/msdos/tools.tar. Then:(It hung within the first few minutes of
rename. The run used the fullrw append tree fsync rename linklist, sorenamewas the fifth test.)Artifacts in
vm/work/fsrepro/:msdos-{1,3}-hang.{ppm,png,log},msdos-{1,3}-hang-threads.txt,msdos-{1,3}-hang-locks.txt,res-m3-part1.log,res-m5-final.log.Where to look
bsd/msdosfs/msdosfs_vnops.cmsdosfs_rename(), therelookup()calls added ormoved by
89e39d0b2:relookup(fdvp, &svp, fcnp)(source re-check),relookup_startdir(tdvp, ...), and the finalrelookup(fdvp, &fvp, fcnp).When
newparentis set, the last one runs withtdvpstill locked, so therename locks the target directory and then the source directory. A plain
lookup (
msdosfs_lookup->deget->vget) that holds one of thesedirectories and wants the other closes the cycle. Check every
relookupinthe function for a vnode left locked across it, and compare the lock order
with
ufs_renamein this tree, which passes the samerenameload.Found by the stress suite (
src/Commands/stress, branchstress-phase3) during the phase 3 filesystem run. Related: #45 (rename races, fixed on fs-races).@raynorpat commented on GitHub (Oct 16, 2026):
Fixed in
260033acbb(kernel: Merge filesystem repairs for issues 52-55), on ffs-perf; the rename locking is reworked inmsdosfs_vnops.candmsdosfs_lookup.c.Verified on the repair kernel:
vm/msdosfs_rename_test.cpasses: 4 workers × 4,000 opposing file and directory moves, with lookup checks and source preservation on refused renames.stress-fs treeandrenamepass with 4 workers, 500 iterations, seeds 1, 3 and 10, including the two seeds that hung before.fsck_msdos -nis clean afterwards.Test notes and focused regressions:
vm/filesystem-issues-52-55.mdin that commit. Repair kernel cksum 3500498149 (i386, QEMU snapshot); PowerPC not tested.