Bug 234795 - bectl: jail command does not mount deep boot environments
Summary: bectl: jail command does not mount deep boot environments
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-09 18:03 UTC by Wes Maag
Modified: 2023-10-12 03:15 UTC (History)
1 user (show)

See Also:
kevans: mfc-stable12?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wes Maag 2019-01-09 18:03:01 UTC
I have a zfs layout with the following. 

NAME                                      USED  AVAIL  REFER  MOUNTPOINT
...
root/ROOT                                48.7G  60.4G   352K  none
root/ROOT/20181127                       24.7G  60.4G  18.6G  /
root/ROOT/20181127/usr                    128M  60.4G    23K  none
root/ROOT/20181127/usr/local              127M  60.4G  2.57G  /usr/local
root/ROOT/20181127/usr/obj                648K  60.4G  4.10G  /usr/obj
root/ROOT/20181127/usr/ports                1K  60.4G  2.74G  /usr/ports
root/ROOT/20181127/usr/src                  1K  60.4G  3.10G  /usr/src
root/ROOT/default                        24.0G  60.4G  19.4G  /
root/ROOT/default/usr                    24.0G  60.4G    23K  none
root/ROOT/default/usr/local              6.42G  60.4G  4.55G  /usr/local
root/ROOT/default/usr/obj                13.9G  60.4G  9.80G  /usr/obj
root/ROOT/default/usr/ports              3.22G  60.4G  2.97G  /usr/ports
root/ROOT/default/usr/src                 468M  60.4G  3.22G  /usr/src


Currently I'm using 20181127 as my active bootenv. When calling

# bectl jail default

only the root/ROOT/default dataset is mounted. Which prevents me from building/installing updates from source within the jail.
Comment 1 Wes Maag 2019-01-09 18:06:55 UTC
review D18796
Comment 2 Kyle Evans freebsd_committer freebsd_triage 2019-01-09 18:08:51 UTC
Take
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-01-10 03:28:02 UTC
A commit references this bug:

Author: kevans
Date: Thu Jan 10 03:27:21 UTC 2019
New revision: 342911
URL: https://svnweb.freebsd.org/changeset/base/342911

Log:
  libbe(3): Change be_mount to mount/unmount child datasets

  This set of changes is geared towards making bectl respect deep boot
  environments when they exist and are mounted. The deep BE composition
  functionality (`bectl add`) remains disabled for the time being. This set of
  changes has no effect for the average user. but allows deep BE users to
  upgrade properly with their current setup.

  libbe(3): Open the target boot environment and get a zfs handle, then pass
  that with the target mountpoint to be_mount_iter; If the BE_MNT_DEEP flag is
  set call zfs_iter_filesystems and mount the child datasets.

  Similar logic is employed when unmounting the datasets, save for children
  are unmounted first.

  bectl(8): Change bectl_cmd_jail to pass the BE_MNT_DEEP flag when
  calling be_mount as well as call be_unmount when cleaning up after the
  jail has exited instead of umount(2) directly.

  PR:		234795
  Submitted by:	Wes Maag <jwmaag_gmail.com> (test additions by kevans)
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D18796

Changes:
  head/lib/libbe/be_access.c
  head/sbin/bectl/bectl.c
  head/sbin/bectl/bectl_jail.c
  head/sbin/bectl/tests/bectl_test.sh
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2019-01-10 03:33:04 UTC
Thanks! Will MFC to stable/12 in a week, then to stable/11 once the pending work on bectl/libbe slows down.
Comment 5 commit-hook freebsd_committer freebsd_triage 2019-01-21 02:58:21 UTC
A commit references this bug:

Author: kevans
Date: Mon Jan 21 02:57:59 UTC 2019
New revision: 343241
URL: https://svnweb.freebsd.org/changeset/base/343241

Log:
  MFC r342903, r342911: libbe(3)/bectl(8) refactor and fix mount for deep BEs

  r342903: libbe(3): move altroot augmentation bits around a little bit

  We could perhaps have a method that does this given a dataset, but it's yet
  clear that we'll always want to bypass the altroot when we grab the
  mountpoint. For now, we'll refactor things a bit so we grab the altroot
  length when libbe is initialized and have a common method that does the
  necessary augmentation (replace with / if it's the root, return a pointer to
  later in the string if not).

  This will be used in some upcoming work to make be_mount work properly for
  deep BEs.

  r342911: libbe(3): Change be_mount to mount/unmount child datasets

  This set of changes is geared towards making bectl respect deep boot
  environments when they exist and are mounted. The deep BE composition
  functionality (`bectl add`) remains disabled for the time being. This set of
  changes has no effect for the average user. but allows deep BE users to
  upgrade properly with their current setup.

  libbe(3): Open the target boot environment and get a zfs handle, then pass
  that with the target mountpoint to be_mount_iter; If the BE_MNT_DEEP flag is
  set call zfs_iter_filesystems and mount the child datasets.

  Similar logic is employed when unmounting the datasets, save for children
  are unmounted first.

  bectl(8): Change bectl_cmd_jail to pass the BE_MNT_DEEP flag when
  calling be_mount as well as call be_unmount when cleaning up after the
  jail has exited instead of umount(2) directly.

  PR:		234795

Changes:
_U  stable/12/
  stable/12/lib/libbe/be.c
  stable/12/lib/libbe/be_access.c
  stable/12/lib/libbe/be_impl.h
  stable/12/sbin/bectl/bectl.c
  stable/12/sbin/bectl/bectl_jail.c
  stable/12/sbin/bectl/tests/bectl_test.sh