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)
Mon, Nov 18, 11:35 AM
Unknown Object (File)
Thu, Nov 14, 6:26 PM
Unknown Object (File)
Thu, Nov 14, 6:02 PM
Unknown Object (File)
Thu, Nov 14, 11:30 AM
Unknown Object (File)
Thu, Nov 14, 7:34 AM
Unknown Object (File)
Wed, Nov 13, 9:51 PM
Unknown Object (File)
Tue, Nov 12, 6:51 AM
Unknown Object (File)
Tue, Nov 12, 5:19 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

Lint
Lint Skipped
Unit
Tests Skipped

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

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