Page MenuHomeFreeBSD

swapon before closing trimming fd
ClosedPublic

Authored by dougm on Jul 20 2019, 4:27 AM.

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dougm created this revision.Jul 20 2019, 4:27 AM

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).

dougm updated this revision to Diff 59959.Jul 20 2019, 7:14 AM

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".

dougm updated this revision to Diff 59960.Jul 20 2019, 7:31 AM

Fix Eflags typo.

markj added inline comments.Jul 20 2019, 6:01 PM
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 updated this revision to Diff 59966.Jul 20 2019, 6:12 PM
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.

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