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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_mount.c
          +++ new/usr/src/lib/libzfs/common/libzfs_mount.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23      - * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  25      - * Copyright (c) 2014, 2017 by Delphix. All rights reserved.
       24 + */
       25 +
       26 +/*
       27 + * Copyright 2019 Nexenta Systems, Inc.
       28 + * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
  26   29   * Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
  27   30   * Copyright 2017 Joyent, Inc.
  28   31   * Copyright 2017 RackTop Systems.
  29   32   * Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  30   33   */
  31   34  
  32   35  /*
  33   36   * Routines to manage ZFS mounts.  We separate all the nasty routines that have
  34   37   * to deal with the OS.  The following functions are the main entry points --
  35   38   * they are used by mount and unmount and when changing a filesystem's
↓ open down ↓ 578 lines elided ↑ open up ↑
 614  617  static sa_handle_t (*_sa_init_arg)(int, void *);
 615  618  static int (*_sa_service)(sa_handle_t);
 616  619  static void (*_sa_fini)(sa_handle_t);
 617  620  static sa_share_t (*_sa_find_share)(sa_handle_t, char *);
 618  621  static int (*_sa_enable_share)(sa_share_t, char *);
 619  622  static int (*_sa_disable_share)(sa_share_t, char *);
 620  623  static char *(*_sa_errorstr)(int);
 621  624  static int (*_sa_parse_legacy_options)(sa_group_t, char *, char *);
 622  625  static boolean_t (*_sa_needs_refresh)(sa_handle_t *);
 623  626  static libzfs_handle_t *(*_sa_get_zfs_handle)(sa_handle_t);
 624      -static int (*_sa_zfs_process_share)(sa_handle_t, sa_group_t, sa_share_t,
 625      -    char *, char *, zprop_source_t, char *, char *, char *);
      627 +static int (* _sa_get_zfs_share)(sa_handle_t, char *, zfs_handle_t *);
 626  628  static void (*_sa_update_sharetab_ts)(sa_handle_t);
 627  629  
 628  630  /*
 629  631   * _zfs_init_libshare()
 630  632   *
 631  633   * Find the libshare.so.1 entry points that we use here and save the
 632  634   * values to be used later. This is triggered by the runtime loader.
 633  635   * Make sure the correct ISA version is loaded.
 634  636   */
 635  637  
↓ open down ↓ 27 lines elided ↑ open up ↑
 663  665                      "sa_enable_share");
 664  666                  _sa_disable_share = (int (*)(sa_share_t, char *))dlsym(libshare,
 665  667                      "sa_disable_share");
 666  668                  _sa_errorstr = (char *(*)(int))dlsym(libshare, "sa_errorstr");
 667  669                  _sa_parse_legacy_options = (int (*)(sa_group_t, char *, char *))
 668  670                      dlsym(libshare, "sa_parse_legacy_options");
 669  671                  _sa_needs_refresh = (boolean_t (*)(sa_handle_t *))
 670  672                      dlsym(libshare, "sa_needs_refresh");
 671  673                  _sa_get_zfs_handle = (libzfs_handle_t *(*)(sa_handle_t))
 672  674                      dlsym(libshare, "sa_get_zfs_handle");
 673      -                _sa_zfs_process_share = (int (*)(sa_handle_t, sa_group_t,
 674      -                    sa_share_t, char *, char *, zprop_source_t, char *,
 675      -                    char *, char *))dlsym(libshare, "sa_zfs_process_share");
      675 +                _sa_get_zfs_share = (int (*)(sa_handle_t, char *,
      676 +                    zfs_handle_t *)) dlsym(libshare, "sa_get_zfs_share");
 676  677                  _sa_update_sharetab_ts = (void (*)(sa_handle_t))
 677  678                      dlsym(libshare, "sa_update_sharetab_ts");
 678  679                  if (_sa_init == NULL || _sa_init_arg == NULL ||
 679  680                      _sa_fini == NULL || _sa_find_share == NULL ||
 680  681                      _sa_enable_share == NULL || _sa_disable_share == NULL ||
 681  682                      _sa_errorstr == NULL || _sa_parse_legacy_options == NULL ||
 682  683                      _sa_needs_refresh == NULL || _sa_get_zfs_handle == NULL ||
 683      -                    _sa_zfs_process_share == NULL || _sa_service == NULL ||
      684 +                    _sa_get_zfs_share == NULL || _sa_service == NULL ||
 684  685                      _sa_update_sharetab_ts == NULL) {
 685  686                          _sa_init = NULL;
 686  687                          _sa_init_arg = NULL;
 687  688                          _sa_service = NULL;
 688  689                          _sa_fini = NULL;
 689  690                          _sa_disable_share = NULL;
 690  691                          _sa_enable_share = NULL;
 691  692                          _sa_errorstr = NULL;
 692  693                          _sa_parse_legacy_options = NULL;
 693  694                          (void) dlclose(libshare);
 694  695                          _sa_needs_refresh = NULL;
 695  696                          _sa_get_zfs_handle = NULL;
 696      -                        _sa_zfs_process_share = NULL;
      697 +                        _sa_get_zfs_share = NULL;
 697  698                          _sa_update_sharetab_ts = NULL;
 698  699                  }
 699  700          }
 700  701  }
 701  702  
 702  703  /*
 703  704   * zfs_init_libshare(zhandle, service)
 704  705   *
 705  706   * Initialize the libshare API if it hasn't already been initialized.
 706  707   * In all cases it returns 0 if it succeeded and an error if not. The
↓ open down ↓ 166 lines elided ↑ open up ↑
 873  874                          continue;
 874  875                  ret = zfs_init_libshare_arg(hdl, service, zhp);
 875  876                  if (ret != SA_OK) {
 876  877                          (void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
 877  878                              dgettext(TEXT_DOMAIN, "cannot share '%s': %s"),
 878  879                              zfs_get_name(zhp), _sa_errorstr != NULL ?
 879  880                              _sa_errorstr(ret) : "");
 880  881                          return (-1);
 881  882                  }
 882  883  
 883      -                /*
 884      -                 * If the 'zoned' property is set, then zfs_is_mountable()
 885      -                 * will have already bailed out if we are in the global zone.
 886      -                 * But local zones cannot be NFS servers, so we ignore it for
 887      -                 * local zones as well.
 888      -                 */
 889      -                if (zfs_prop_get_int(zhp, ZFS_PROP_ZONED))
 890      -                        continue;
 891      -
 892  884                  share = zfs_sa_find_share(hdl->libzfs_sharehdl, mountpoint);
 893  885                  if (share == NULL) {
 894  886                          /*
 895  887                           * This may be a new file system that was just
 896      -                         * created so isn't in the internal cache
 897      -                         * (second time through). Rather than
 898      -                         * reloading the entire configuration, we can
 899      -                         * assume ZFS has done the checking and it is
 900      -                         * safe to add this to the internal
 901      -                         * configuration.
      888 +                         * created so isn't in the internal cache.
      889 +                         * Rather than reloading the entire configuration,
      890 +                         * we can add just this one share to the cache.
 902  891                           */
 903      -                        if (_sa_zfs_process_share(hdl->libzfs_sharehdl,
 904      -                            NULL, NULL, mountpoint,
 905      -                            proto_table[*curr_proto].p_name, sourcetype,
 906      -                            shareopts, sourcestr, zhp->zfs_name) != SA_OK) {
      892 +                        if ((_sa_get_zfs_share == NULL) ||
      893 +                            (_sa_get_zfs_share(hdl->libzfs_sharehdl, "zfs", zhp)
      894 +                            != SA_OK)) {
 907  895                                  (void) zfs_error_fmt(hdl,
 908  896                                      proto_table[*curr_proto].p_share_err,
 909  897                                      dgettext(TEXT_DOMAIN, "cannot share '%s'"),
 910  898                                      zfs_get_name(zhp));
 911  899                                  return (-1);
 912  900                          }
 913  901                          share = zfs_sa_find_share(hdl->libzfs_sharehdl,
 914  902                              mountpoint);
 915  903                  }
 916  904                  if (share != NULL) {
↓ open down ↓ 820 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX