Project

General

Profile

Actions

Bug #12141

closed

libbe cannot handle vfstab updates in NGZ

Added by Andy Fiddaman almost 2 years ago. Updated almost 2 years ago.

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

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

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     -
Actions

Also available in: Atom PDF