Print this page
NEX-19178 Changing the NFS export path makes the SMB share offline
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
@@ -20,21 +20,23 @@
*/
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+
/*
- * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, 2016 by Delphix. All rights reserved.
* Copyright 2017 RackTop Systems.
+ * Copyright 2019 Nexenta Systems, Inc.
*/
#include <stdio.h>
#include <libzfs.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
+#include <zone.h>
#include <libshare.h>
#include "libshare_impl.h"
#include <libintl.h>
#include <sys/mnttab.h>
#include <sys/mntent.h>
@@ -236,10 +238,11 @@
get_legacy_mountpoint(const char *path, char *dataset, size_t dlen,
char *mountpoint, size_t mlen)
{
FILE *fp;
struct mnttab entry;
+ int rc = 1;
if ((fp = fopen(MNTTAB, "r")) == NULL) {
return (1);
}
@@ -254,15 +257,16 @@
(void) strlcpy(mountpoint, entry.mnt_mountp,
mlen);
if (dlen > 0)
(void) strlcpy(dataset, entry.mnt_special,
dlen);
+ rc = 0;
break;
}
}
(void) fclose(fp);
- return (1);
+ return (rc);
}
/*
* Verifies that a specific zfs filesystem handle meets the criteria necessary
@@ -815,10 +819,17 @@
*/
if (!zfs_is_mounted(fs_handle, NULL))
return (SA_SYSTEM_ERR);
+ /*
+ * Ignore "zoned" datasets in global zone.
+ */
+ if (getzoneid() == GLOBAL_ZONEID &&
+ zfs_prop_get_int(fs_handle, ZFS_PROP_ZONED))
+ return (SA_SYSTEM_ERR);
+
nfs = nfs_inherited = B_FALSE;
if (zfs_prop_get(fs_handle, ZFS_PROP_SHARENFS, nfsshareopts,
sizeof (nfsshareopts), &source, nfssourcestr,
ZFS_MAXPROPLEN, B_FALSE) == 0 &&
@@ -973,10 +984,33 @@
* pointer to a cached value that will be freed when
* sa_fini() is called.
*/
return (err);
}
+
+/*
+ * Initializes shares for only the dataset specified fs_handle.
+ * This is used as a performance optimization relative to sa_get_zfs_shares.
+ */
+int
+sa_get_zfs_share(sa_handle_t handle, char *groupname, zfs_handle_t *fs_handle)
+{
+ sa_group_t zfsgroup;
+ libzfs_handle_t *zfs_libhandle;
+ int err;
+
+ if ((err = prep_zfs_handle_and_group(handle, groupname, &zfs_libhandle,
+ &zfsgroup, &err)) != SA_OK) {
+ return (err);
+ }
+ /* Not an error, this could be a legacy condition */
+ if (zfsgroup == NULL)
+ return (SA_OK);
+
+ err = sa_get_zfs_share_common(handle, fs_handle, NULL, zfsgroup);
+ return (err);
+}
/*
* Initializes only the handles specified in the sharearg for use with libshare.
* This is used as a performance optimization relative to sa_get_zfs_shares.
*/