Fix per-jail zfs.mount_snapshot setting

When jail.conf set the nopersist flag during startup, it was
incorrectly destroying the per-jail ZFS settings.

Reported-by: Martin Matuska <mm@FreeBSD.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Sponsored-by: Modirum MDPay
Sponsored-by: Klara, Inc.
Closes #14509
This commit is contained in:
Allan Jude 2023-02-21 20:23:01 -05:00 committed by GitHub
parent 0f32b1f728
commit 1d56c6d017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2495,7 +2495,9 @@ zfs_jailparam_set(void *obj, void *data)
mount_snapshot = -1; mount_snapshot = -1;
else else
jsys = JAIL_SYS_NEW; jsys = JAIL_SYS_NEW;
if (jsys == JAIL_SYS_NEW) { switch (jsys) {
case JAIL_SYS_NEW:
{
/* "zfs=new" or "zfs.*": the prison gets its own ZFS info. */ /* "zfs=new" or "zfs.*": the prison gets its own ZFS info. */
struct zfs_jailparam *zjp; struct zfs_jailparam *zjp;
@ -2513,12 +2515,22 @@ zfs_jailparam_set(void *obj, void *data)
if (mount_snapshot != -1) if (mount_snapshot != -1)
zjp->mount_snapshot = mount_snapshot; zjp->mount_snapshot = mount_snapshot;
mtx_unlock(&pr->pr_mtx); mtx_unlock(&pr->pr_mtx);
} else { break;
}
case JAIL_SYS_INHERIT:
/* "zfs=inherit": inherit the parent's ZFS info. */ /* "zfs=inherit": inherit the parent's ZFS info. */
mtx_lock(&pr->pr_mtx); mtx_lock(&pr->pr_mtx);
osd_jail_del(pr, zfs_jailparam_slot); osd_jail_del(pr, zfs_jailparam_slot);
mtx_unlock(&pr->pr_mtx); mtx_unlock(&pr->pr_mtx);
break;
case -1:
/*
* If the setting being changed is not ZFS related
* then do nothing.
*/
break;
} }
return (0); return (0);
} }