HomeFreeBSD

jail: Add pr_state to struct prison

Description

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

Details

Provenance
jamieAuthored on Feb 21 2021, 9:24 PM
Differential Revision
D27876: jail: Add pr_state to struct prison
Parents
rG2443068d4860: vfs: shrink struct vnode to 448 bytes on LP64
Branches
Unknown
Tags
Unknown