]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC 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>
Fri, 12 Mar 2021 18:46:43 +0000 (10:46 -0800)
commit2bfecbef9a57cd172fd734bff757168d30aa9512
tree80befe1aac7a8b1a869be89da186e90529f6aae6
parentec24f78e5b201ea56a69607c6e4438a2faac25c0
MFC 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

(cherry picked from commit 1158508a8086a1a93492c1a2e22b61cd7fee4ec7)

MFC jail: Fix a LOR introduced in 1158508a8086

(cherry picked from commit 701d6b50ae7b0b2b50fbd191c2dbd646ef3b4a67)
sys/kern/kern_jail.c
sys/sys/jail.h