Page MenuHomeFreeBSD

swapon before closing trimming fd
ClosedPublic

Authored by dougm on Jul 20 2019, 4:27 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 7:17 PM
Unknown Object (File)
Fri, Mar 22, 3:14 PM
Unknown Object (File)
Fri, Mar 22, 3:14 PM
Unknown Object (File)
Fri, Mar 22, 11:56 AM
Unknown Object (File)
Fri, Mar 22, 10:53 AM
Unknown Object (File)
Fri, Mar 22, 10:01 AM
Unknown Object (File)
Fri, Mar 22, 9:46 AM
Unknown Object (File)
Mar 8 2024, 11:06 AM
Subscribers

Details

Summary

To make swapon -E work with geli detach-on-last-close, don't close the trimming fd until after swapon(2) is invoked.

Test Plan

Ask reviewers to confirm that it fixes geli, and doesn't break swapon trimming for anyone else.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Probably not safe to start trimming the swap device *after* the kernel has been told to start using it for swapping (even if the window is probably small).

Call swapon(2) after trimming, but before closing the trimming fd.

Call swapon(2) after trimming, but before closing the trimming fd.

Works here. This is cleaner than what I was doing for sure. Got a typo though, it's "Eflag" not "Eflags".

sbin/swapon/swapon.c
765 ↗(On Diff #59960)

I think a comment explaining why this function handles both trimming and swapon would be appropriate.

dougm retitled this revision from trim after swapon to swapon before closing trimming fd.
dougm edited the summary of this revision. (Show Details)

Add explanatory comment.

This revision is now accepted and ready to land.Jul 20 2019, 8:30 PM