Project

General

Profile

Bug #12141

libbe cannot handle vfstab updates in NGZ

Added by Andy Fiddaman about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

As part of creating a new boot environment, the /etc/vfstab entries for any legacy-mounted filesystems under the root dataset are updated to reflect the new BE. This works fine in the GZ (including for any linked child zones) but not directly within an NGZ.

To replicate create a zone with legacy mounts under the root dataset, for example (this is an OmniOS sparse zone):

ngzone# grep ROOT /etc/vfstab
data/zone/ngzone/ROOT/zbe/svc - /lib/svc zfs - no -
data/zone/ngzone/ROOT/zbe/fm - /usr/lib/fm zfs - no -

ngzone# df -h | grep data/zone/ngzone
data/zone/ngzone/ROOT/zbe  3.51T   311M      1.42T     1%    /
data/zone/ngzone/ROOT/zbe/svc  3.51T  1.56M      1.42T     1%    /lib/svc
data/zone/ngzone/ROOT/zbe/fm  3.51T  1.59M      1.42T     1%    /usr/lib/fm

Creating a new BE within the zone will fail:

ngzone# beadm create -v test
be_mount_callback: no entry for data/zone/ngzone/ROOT/test/fm in vfstab, skipping ...
be_mount_callback: no entry for data/zone/ngzone/ROOT/test/svc in vfstab, skipping ...
_update_vfstab: Failed to update device field for vfstab entry data/zone/ngzone/ROOT/zbe/svc
be_copy: failed to update new BE's vfstab (test)
be_copy: destroying partially created boot environment
Unable to create test.
Invalid argument.
zsh: exit 176   beadm create -v test

This is a bug in libbe's be_copy() function which calls be_update_vfstab() with the wrong parameters.

ngzone# dtrace -n 'pid$target::be_update_vfstab:entry{trace(copyinstr(arg1))}' -c 'beadm create test'
dtrace: description 'pid$target::be_update_vfstab:entry' matched 1 probe
CPU     ID                    FUNCTION:NAME
 25  91387           be_update_vfstab:entry   data
Unable to create test.
Invalid argument.

be_copy_zones() gets this right when updating child linked zones, which is why the operation works when run from the GZ.

gz# cat /data/zone/ngzone/root/etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
/devices        -               /devices        devfs   -       no      -
/proc           -               /proc           proc    -       no      -
ctfs            -               /system/contract ctfs   -       no      -
objfs           -               /system/object  objfs   -       no      -
sharefs         -               /etc/dfs/sharetab       sharefs -       no     -
fd              -               /dev/fd         fd      -       no      -
swap            -               /tmp            tmpfs   -       yes     -

data/zone/ngzone/ROOT/zbe/svc - /lib/svc zfs - no -
data/zone/ngzone/ROOT/zbe/fm - /usr/lib/fm zfs - no -

gz# beadm create test
Created successfully

gz# beadm mount test /a
Mounted successfully on: '/a'
gz# cat /a/data/zone/ngzone/root/etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
/devices        -       /devices        devfs   -       no      -
/proc   -       /proc   proc    -       no      -
ctfs    -       /system/contract        ctfs    -       no      -
objfs   -       /system/object  objfs   -       no      -
sharefs -       /etc/dfs/sharetab       sharefs -       no      -
fd      -       /dev/fd fd      -       no      -
swap    -       /tmp    tmpfs   -       yes     -
data/zone/ngzone/ROOT/zbe-1/svc    -       /lib/svc        zfs     -       no     -
data/zone/ngzone/ROOT/zbe-1/fm     -       /usr/lib/fm     zfs     -       no     -

History

#1

Updated by Andy Fiddaman about 2 months ago

  • Description updated (diff)
#2

Updated by Andy Fiddaman about 2 months ago

  • Description updated (diff)
#4

Updated by Andy Fiddaman about 2 months ago

Testing:

NGZ create

ngzone# beadm create test
Created successfully

ngzone# beadm mount test /a
Mounted successfully on: '/a'

ngzone# grep ROOT /a/etc/vfstab
data/zone/ngzone/ROOT/test/svc     -       /lib/svc        zfs     -       no     -
data/zone/ngzone/ROOT/test/fm      -       /usr/lib/fm     zfs     -       no     -

ngzone# dtrace -n 'pid$target::be_update_vfstab:entry{trace(copyinstr(arg1))}' -c 'beadm create test2'
dtrace: description 'pid$target::be_update_vfstab:entry' matched 1 probe
CPU     ID                    FUNCTION:NAME
 26  14996           be_update_vfstab:entry   data/zone/ngzone
Created successfully
dtrace: pid 2980 has exited

GZ create

gz# beadm create test
Created successfully

gz# beadm mount test /a
Mounted successfully on: '/a'
gz# cat /a/data/zone/ngzone/root/etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
/devices        -       /devices        devfs   -       no      -
/proc   -       /proc   proc    -       no      -
ctfs    -       /system/contract        ctfs    -       no      -
objfs   -       /system/object  objfs   -       no      -
sharefs -       /etc/dfs/sharetab       sharefs -       no      -
fd      -       /dev/fd fd      -       no      -
swap    -       /tmp    tmpfs   -       yes     -
data/zone/ngzone/ROOT/zbe-1/svc    -       /lib/svc        zfs     -       no     -
data/zone/ngzone/ROOT/zbe-1/fm     -       /usr/lib/fm     zfs     -       no     -

NGZ rename

ngzone# beadm create test
Created successfully
ngzone# beadm rename test test2
Renamed successfully
ngzone# beadm mount test2 /a
Mounted successfully on: '/a'
ngzone# cat /a/etc/vfstab
#device         device          mount           FS      fsck    mount   mount
#to mount       to fsck         point           type    pass    at boot options
#
/devices        -       /devices        devfs   -       no      -
/proc   -       /proc   proc    -       no      -
ctfs    -       /system/contract        ctfs    -       no      -
objfs   -       /system/object  objfs   -       no      -
sharefs -       /etc/dfs/sharetab       sharefs -       no      -
fd      -       /dev/fd fd      -       no      -
swap    -       /tmp    tmpfs   -       yes     -
data/zone/ngzone/ROOT/test2/svc    -       /lib/svc        zfs     -       no      -
data/zone/ngzone/ROOT/test2/fm     -       /usr/lib/fm     zfs     -       no      -
#5

Updated by Electric Monk about 1 month ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 02123a497a63fe1acfaf63446b5b19101fa6c347

commit  02123a497a63fe1acfaf63446b5b19101fa6c347
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2020-01-06T22:17:37.000Z

    12141 libbe cannot handle vfstab updates in NGZ
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: C Fraire <cfraire@me.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF