Print this page
11083 support NFS server in zone
Portions contributed by: Dan Kruchinin <dan.kruchinin@nexenta.com>
Portions contributed by: Stepan Zastupov <stepan.zastupov@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Portions contributed by: Mike Zeller <mike@mikezeller.net>
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>
Portions contributed by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Jason King <jbk@joyent.com>
Reviewed by: C Fraire <cfraire@me.com>
Change-Id: I22f289d357503f9b48a0bc2482cc4328a6d43d16
        
*** 18,30 ****
   *
   * CDDL HEADER END
   */
  
  /*
-  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
!  * Copyright (c) 2014, 2017 by Delphix. All rights reserved.
   * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
   * Copyright 2017 Joyent, Inc.
   * Copyright 2017 RackTop Systems.
   * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
   */
--- 18,33 ----
   *
   * CDDL HEADER END
   */
  
  /*
   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
!  */
! 
! /*
!  * Copyright 2019 Nexenta Systems, Inc.
!  * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
   * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
   * Copyright 2017 Joyent, Inc.
   * Copyright 2017 RackTop Systems.
   * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
   */
*** 619,630 ****
  static int (*_sa_disable_share)(sa_share_t, char *);
  static char *(*_sa_errorstr)(int);
  static int (*_sa_parse_legacy_options)(sa_group_t, char *, char *);
  static boolean_t (*_sa_needs_refresh)(sa_handle_t *);
  static libzfs_handle_t *(*_sa_get_zfs_handle)(sa_handle_t);
! static int (*_sa_zfs_process_share)(sa_handle_t, sa_group_t, sa_share_t,
!     char *, char *, zprop_source_t, char *, char *, char *);
  static void (*_sa_update_sharetab_ts)(sa_handle_t);
  
  /*
   * _zfs_init_libshare()
   *
--- 622,632 ----
  static int (*_sa_disable_share)(sa_share_t, char *);
  static char *(*_sa_errorstr)(int);
  static int (*_sa_parse_legacy_options)(sa_group_t, char *, char *);
  static boolean_t (*_sa_needs_refresh)(sa_handle_t *);
  static libzfs_handle_t *(*_sa_get_zfs_handle)(sa_handle_t);
! static int (* _sa_get_zfs_share)(sa_handle_t, char *, zfs_handle_t *);
  static void (*_sa_update_sharetab_ts)(sa_handle_t);
  
  /*
   * _zfs_init_libshare()
   *
*** 668,688 ****
                      dlsym(libshare, "sa_parse_legacy_options");
                  _sa_needs_refresh = (boolean_t (*)(sa_handle_t *))
                      dlsym(libshare, "sa_needs_refresh");
                  _sa_get_zfs_handle = (libzfs_handle_t *(*)(sa_handle_t))
                      dlsym(libshare, "sa_get_zfs_handle");
!                 _sa_zfs_process_share = (int (*)(sa_handle_t, sa_group_t,
!                     sa_share_t, char *, char *, zprop_source_t, char *,
!                     char *, char *))dlsym(libshare, "sa_zfs_process_share");
                  _sa_update_sharetab_ts = (void (*)(sa_handle_t))
                      dlsym(libshare, "sa_update_sharetab_ts");
                  if (_sa_init == NULL || _sa_init_arg == NULL ||
                      _sa_fini == NULL || _sa_find_share == NULL ||
                      _sa_enable_share == NULL || _sa_disable_share == NULL ||
                      _sa_errorstr == NULL || _sa_parse_legacy_options == NULL ||
                      _sa_needs_refresh == NULL || _sa_get_zfs_handle == NULL ||
!                     _sa_zfs_process_share == NULL || _sa_service == NULL ||
                      _sa_update_sharetab_ts == NULL) {
                          _sa_init = NULL;
                          _sa_init_arg = NULL;
                          _sa_service = NULL;
                          _sa_fini = NULL;
--- 670,689 ----
                      dlsym(libshare, "sa_parse_legacy_options");
                  _sa_needs_refresh = (boolean_t (*)(sa_handle_t *))
                      dlsym(libshare, "sa_needs_refresh");
                  _sa_get_zfs_handle = (libzfs_handle_t *(*)(sa_handle_t))
                      dlsym(libshare, "sa_get_zfs_handle");
!                 _sa_get_zfs_share = (int (*)(sa_handle_t, char *,
!                     zfs_handle_t *)) dlsym(libshare, "sa_get_zfs_share");
                  _sa_update_sharetab_ts = (void (*)(sa_handle_t))
                      dlsym(libshare, "sa_update_sharetab_ts");
                  if (_sa_init == NULL || _sa_init_arg == NULL ||
                      _sa_fini == NULL || _sa_find_share == NULL ||
                      _sa_enable_share == NULL || _sa_disable_share == NULL ||
                      _sa_errorstr == NULL || _sa_parse_legacy_options == NULL ||
                      _sa_needs_refresh == NULL || _sa_get_zfs_handle == NULL ||
!                     _sa_get_zfs_share == NULL || _sa_service == NULL ||
                      _sa_update_sharetab_ts == NULL) {
                          _sa_init = NULL;
                          _sa_init_arg = NULL;
                          _sa_service = NULL;
                          _sa_fini = NULL;
*** 691,701 ****
                          _sa_errorstr = NULL;
                          _sa_parse_legacy_options = NULL;
                          (void) dlclose(libshare);
                          _sa_needs_refresh = NULL;
                          _sa_get_zfs_handle = NULL;
!                         _sa_zfs_process_share = NULL;
                          _sa_update_sharetab_ts = NULL;
                  }
          }
  }
  
--- 692,702 ----
                          _sa_errorstr = NULL;
                          _sa_parse_legacy_options = NULL;
                          (void) dlclose(libshare);
                          _sa_needs_refresh = NULL;
                          _sa_get_zfs_handle = NULL;
!                         _sa_get_zfs_share = NULL;
                          _sa_update_sharetab_ts = NULL;
                  }
          }
  }
  
*** 878,911 ****
                              zfs_get_name(zhp), _sa_errorstr != NULL ?
                              _sa_errorstr(ret) : "");
                          return (-1);
                  }
  
-                 /*
-                  * If the 'zoned' property is set, then zfs_is_mountable()
-                  * will have already bailed out if we are in the global zone.
-                  * But local zones cannot be NFS servers, so we ignore it for
-                  * local zones as well.
-                  */
-                 if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED))
-                         continue;
- 
                  share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint);
                  if (share == NULL) {
                          /*
                           * This may be a new file system that was just
!                          * created so isn't in the internal cache
!                          * (second time through). Rather than
!                          * reloading the entire configuration, we can
!                          * assume ZFS has done the checking and it is
!                          * safe to add this to the internal
!                          * configuration.
                           */
!                         if (_sa_zfs_process_share(hdl->libzfs_sharehdl,
!                             NULL, NULL, mountpoint,
!                             proto_table[*curr_proto].p_name, sourcetype,
!                             shareopts, sourcestr, zhp->zfs_name) != SA_OK) {
                                  (void) zfs_error_fmt(hdl,
                                      proto_table[*curr_proto].p_share_err,
                                      dgettext(TEXT_DOMAIN, "cannot share '%s'"),
                                      zfs_get_name(zhp));
                                  return (-1);
--- 879,899 ----
                              zfs_get_name(zhp), _sa_errorstr != NULL ?
                              _sa_errorstr(ret) : "");
                          return (-1);
                  }
  
                  share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint);
                  if (share == NULL) {
                          /*
                           * This may be a new file system that was just
!                          * created so isn't in the internal cache.
!                          * Rather than reloading the entire configuration,
!                          * we can add just this one share to the cache.
                           */
!                         if ((_sa_get_zfs_share == NULL) ||
!                             (_sa_get_zfs_share(hdl->libzfs_sharehdl, "zfs", zhp)
!                             != SA_OK)) {
                                  (void) zfs_error_fmt(hdl,
                                      proto_table[*curr_proto].p_share_err,
                                      dgettext(TEXT_DOMAIN, "cannot share '%s'"),
                                      zfs_get_name(zhp));
                                  return (-1);