ZFS: Requirements of "zfs jail JID DS"?

From: Alexander Leidinger <Alexander_at_Leidinger.net>
Date: Mon, 15 Jan 2024 09:53:24 UTC
Hi,

I'm working on adding zfs dataset jailing as a native operation into 
jail(8). The "zfs jail JID DS" on jail creation works.

For the removal of a jail the "zfs unjail JID DS" comes too late or too 
early. Either the processes are still running, so I can't really remove 
the DS, or the jail structure in the kernel is already gone and there is 
no JID for this jail anymore. In that case the zfs unjail command fails.

Now my questions:
Is it only to remove a DS from a running jail? When is the zfs unjail 
needed?
Would it be ok to simply do nothing with the DS which is attached to a 
jail when the jail is stopped?

In my testing I was able to jail a DS multiple times in jail start/stop 
cycles (jail start, zfs jail, jail stop, repeat), so it seems it is ok 
to do nothing with the DS on jail stop, but I would like to get a 
confirmation from someone who knows more about the "zfs jail" part.

For those interested, the current WIP is attached.

Bye,
Alexander.

-- 
http://www.Leidinger.net Alexander@Leidinger.net: PGP 0x8F31830F9F2772BF
http://www.FreeBSD.org    netchild@FreeBSD.org  : PGP 0x8F31830F9F2772BF