]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
jail: Add pr_state to struct prison
authorJamie Gritton <jamie@FreeBSD.org>
Sun, 21 Feb 2021 21:24:47 +0000 (13:24 -0800)
committerJamie Gritton <jamie@FreeBSD.org>
Sun, 21 Feb 2021 21:24:47 +0000 (13:24 -0800)
commit1158508a8086a1a93492c1a2e22b61cd7fee4ec7
treef0a56410bcde889ddc96aa31883eb5b9aed2ab2a
parent2443068d486020ed9a4250e0d3b28168c40f741a
jail: Add pr_state to struct prison

Rather that using references (pr_ref and pr_uref) to deduce the state
of a prison, keep track of its state explicitly.  A prison is either
"invalid" (pr_ref == 0), "alive" (pr_uref > 0) or "dying"
(pr_uref == 0).

State transitions are generally tied to the reference counts, but with
some flexibility: a new prison is "invalid" even though it now starts
with a reference, and jail_remove(2) sets the state to "dying" before
the user reference count drops to zero (which was prviously
accomplished via the PR_REMOVE flag).

pr_state is protected by both the prison mutex and allprison_lock, so
it has the same availablity guarantees as the reference counts do.

Differential Revision: https://reviews.freebsd.org/D27876
sys/kern/kern_jail.c
sys/sys/jail.h