Print this page
NEX-16159 Time spent sharing SMB filesystems could be reduced by optimizing smb_getdataset for default mount points (lint fix)
Reviewed by: Jean McCormack <jean.mccormack@nexenta.com>
NEX-16159 Time spent sharing SMB filesystems could be reduced by optimizing smb_getdataset for default mount points
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-2346 SMB server debug logging cleanup after NEX-2314
NEX-816 smbadm dumps core during first join attempt
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>
re #12435 rb3958 r10 is added 2 times to panic info
re #12393 rb3935 Kerberos and smbd disagree about who is our AD server

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libsmb/common/smb_util.c
          +++ new/usr/src/lib/smbsrv/libsmb/common/smb_util.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   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  #include <ctype.h>
  27   27  #include <stdio.h>
  28   28  #include <stdarg.h>
  29   29  #include <unistd.h>
  30   30  #include <sys/fcntl.h>
  31   31  #include <string.h>
  32   32  #include <strings.h>
  33   33  #include <stdlib.h>
↓ open down ↓ 586 lines elided ↑ open up ↑
 620  620          return (belong ? response : B_FALSE);
 621  621  }
 622  622  
 623  623  /*
 624  624   * Resolve the ZFS dataset from a path.
 625  625   * Returns,
 626  626   *      0  = On success.
 627  627   *      -1 = Failure to open /etc/mnttab file or to get ZFS dataset.
 628  628   */
 629  629  int
 630      -smb_getdataset(const char *path, char *dataset, size_t len)
      630 +smb_getdataset(libzfs_handle_t *libhdl, const char *path, char *dataset,
      631 +    size_t len)
 631  632  {
 632  633          char tmppath[MAXPATHLEN];
 633  634          char *cp;
 634  635          FILE *fp;
 635  636          struct mnttab mnttab;
 636  637          struct mnttab mntpref;
 637  638          int rc = -1;
 638  639  
      640 +        /*
      641 +         * Optimisation: if the path is the default mountpoint then
      642 +         * the dataset name can be determined from path.
      643 +         * Attempt to open dataset by derived name and, if successful,
      644 +         * check if its mountpoint matches path.
      645 +         */
      646 +        if (libhdl != NULL) {
      647 +                zfs_handle_t *hdl;
      648 +                char mountpnt[ZFS_MAXPROPLEN];
      649 +                char *dsname = (char *)path + strspn(path, "/");
      650 +
      651 +                hdl = zfs_open(libhdl, dsname, ZFS_TYPE_FILESYSTEM);
      652 +                if (hdl != NULL) {
      653 +                        if ((zfs_prop_get(hdl, ZFS_PROP_MOUNTPOINT, mountpnt,
      654 +                            sizeof (mountpnt), NULL, NULL, 0, B_FALSE) == 0) &&
      655 +                            (strcmp(mountpnt, path) == 0)) {
      656 +                                zfs_close(hdl);
      657 +                                (void) strlcpy(dataset, dsname, len);
      658 +                                return (0);
      659 +                        }
      660 +                        zfs_close(hdl);
      661 +                }
      662 +        }
      663 +
      664 +        /*
      665 +         * Couldn't find a filesystem optimistically, use mnttab
      666 +         */
 639  667          if ((fp = fopen(MNTTAB, "r")) == NULL)
 640  668                  return (-1);
 641  669  
 642  670          (void) memset(&mnttab, '\0', sizeof (mnttab));
 643  671          (void) strlcpy(tmppath, path, MAXPATHLEN);
 644  672          cp = tmppath;
 645  673  
 646  674          while (*cp != '\0') {
 647  675                  resetmnttab(fp);
 648  676                  (void) memset(&mntpref, '\0', sizeof (mntpref));
↓ open down ↓ 435 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX