mirror_zfs/lib/libzfs
Prakash Surya 1bf490ba93 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: 3fd3e56cfd

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
2018-10-03 10:17:58 -07:00
..
.gitignore Add a pkgconfig file 2014-08-28 07:59:43 -07:00
libzfs_changelist.c changelist should be able to iter on mounts 2018-10-02 12:30:58 -07:00
libzfs_config.c OpenZFS 4521 - zfstest is trying to execute evil "zfs unmount -a" 2017-02-03 13:24:44 -08:00
libzfs_core.pc.in Add a pkgconfig file 2014-08-28 07:59:43 -07:00
libzfs_crypto.c Added encryption support for zfs recv -o / -x 2018-08-15 09:48:49 -07:00
libzfs_dataset.c OpenZFS 9616 - Bogus error when attempting to set property on read-only pool 2018-10-03 09:49:30 -07:00
libzfs_diff.c Update build system and packaging 2018-05-29 16:00:33 -07:00
libzfs_import.c OpenZFS 9457 - libzfs_import.c:add_config() has a memory leak 2018-07-24 17:12:06 -07:00
libzfs_iter.c changelist should be able to iter on mounts 2018-10-02 12:30:58 -07:00
libzfs_mount.c Fix "zfs destroy" when "sharenfs=on" is used 2018-10-03 10:17:58 -07:00
libzfs_pool.c Pool allocation classes 2018-09-05 18:33:36 -07:00
libzfs_sendrecv.c Added encryption support for zfs recv -o / -x 2018-08-15 09:48:49 -07:00
libzfs_status.c Add pool state /proc entry, "SUSPENDED" pools 2018-06-06 09:33:54 -07:00
libzfs_util.c Add basic zfs ioc input nvpair validation 2018-09-02 12:14:01 -07:00
libzfs.pc.in Add a pkgconfig file 2014-08-28 07:59:43 -07:00
Makefile.am Support -fsanitize=address with --enable-asan 2018-01-10 10:49:27 -08:00
THIRDPARTYLICENSE.openssl Encryption patch follow-up 2017-10-11 16:54:48 -04:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00