Page MenuHomeFreeBSD

ffs: wait for trims earlier during unmount to avoid panic
ClosedPublic

Authored by chs on Apr 6 2022, 5:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 29, 2:58 AM
Unknown Object (File)
Wed, Mar 20, 10:40 AM
Unknown Object (File)
Feb 10 2024, 6:40 AM
Unknown Object (File)
Dec 23 2023, 5:14 PM
Unknown Object (File)
Dec 23 2023, 2:50 AM
Unknown Object (File)
Dec 19 2023, 6:27 AM
Unknown Object (File)
Oct 18 2023, 4:57 PM
Unknown Object (File)
Aug 27 2023, 4:49 PM
Subscribers

Details

Summary

All softdep processing is supposed to be completed by
softdep_flushfiles() and no more deps are supposed to be created after
that, but if a pending trim completes after softdep_flushfiles() and
before softdep_unmount() then the blkfree that is performed by
ffs_blkfree_trim_task() will create a dep when none should exist, and
if softdep_unmount() is called before that dep is freed then the
kernel will panic. Prevent this by waiting for trims to complete
earlier in the unmount process, in ffs_flushfiles(), so that any deps
will be freed and any modified CG buffers will be flushed by the final
fsync of the devvp in ffs_flushfiles() as intended.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chs requested review of this revision.Apr 6 2022, 5:54 PM

I concur with the analysis. Waiting for trims in the current location is clearly too late. Waiting in the new location will ensure that all the dependencies get flushed. And once flushed it should not be possible to add any new ones thus no new trims should be able to appear.

This revision is now accepted and ready to land.Apr 6 2022, 6:37 PM
sys/ufs/ffs/ffs_vfsops.c
1428

I believe that the drain should be moved as well, otherwise e.g. um_trim_inflight_blks could be accessed after free.

Also, I would add an assert that um_trim_inflight == 0 there, before taskqueue_free()

This revision now requires review to proceed.Apr 7 2022, 10:26 PM
This revision is now accepted and ready to land.Apr 8 2022, 12:14 AM