Page MenuHomeFreeBSD

swapon before closing trimming fd
ClosedPublic

Authored by dougm on Jul 20 2019, 4:27 AM.
Tags
None
Referenced Files
F131647419: D21006.id.diff
Fri, Oct 10, 12:46 AM
Unknown Object (File)
Thu, Oct 2, 11:44 PM
Unknown Object (File)
Thu, Oct 2, 8:34 AM
Unknown Object (File)
Tue, Sep 30, 6:51 AM
Unknown Object (File)
Mon, Sep 29, 11:21 PM
Unknown Object (File)
Sun, Sep 21, 10:54 PM
Unknown Object (File)
Wed, Sep 17, 5:50 AM
Unknown Object (File)
Tue, Sep 16, 6:17 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