HomeFreeBSD

Fix "zfs destroy" when "sharenfs=on" is used

Description

Fix "zfs destroy" when "sharenfs=on" is used

When using "zfs destroy" on a dataset that is using "sharenfs=on" and
has been automatically exported (by libzfs), the dataset will not be
automatically unexported as it should be. This workflow appears to have
been broken by this commit: 3fd3e56cfd543d7d7a1bf502bfc0db6e24139668

In that change, the "zfs_unmount" function was modified to use the
"mnt.mnt_special" field when determining the mount point that is being
unmounted, rather than "mnt.mnt_mountp".

As a result, when "mntpt" is passed into "zfs_unshare_proto", it's value
is now the dataset name rather than the mountpoint. Thus, when this
value is used with the "is_shared" function (via "zfs_unshare_proto") it
will not find a match (since that function assumes it'll be passed the
mountpoint) and incorrectly reports that the dataset is not shared.

This can be easily reproduced with the following commands:

$ sudo zpool create tank xvdb
$ sudo zfs create -o sharenfs=on tank/fish
$ sudo zfs destroy tank/fish

$ sudo zfs list -r tank
NAME   USED  AVAIL  REFER  MOUNTPOINT
tank  97.5K  7.27G    24K  /tank

$ sudo exportfs
/tank/fish      <world>
$ sudo cat /etc/dfs/sharetab
/tank/fish      -       nfs     rw,crossmnt

At this point, the "tank/fish" filesystem doesn't exist, but it's still
listed as exported when looking at "exportfs" and "/etc/dfs/sharetab".

Also note, this change brings us back in-sync with the illumos code, as
it pertains to this one line; on illumos, "mnt.mnt_mountp" is used.

Reviewed by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: George Wilson <george.wilson@delphix.com>
Signed-off-by: Prakash Surya <prakash.surya@delphix.com>
Issue #6143
Closes #7941

Details

Provenance
Prakash Surya <prakash.surya@delphix.com>Authored on Sep 21 2018, 3:47 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Oct 3 2018, 5:17 PM
Parents
rGc955398b527f: OpenZFS 9677 - panic from zio_write_gang_block()
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG1bf490ba930e: Fix "zfs destroy" when "sharenfs=on" is used (authored by Prakash Surya <prakash.surya@delphix.com>).Oct 3 2018, 5:17 PM