Print this page
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>

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
  */
 
 /*
  * This is a helper file to get/set Windows SD. This is used by
  * SRVSVC service.

@@ -57,17 +58,20 @@
         char mp[ZFS_MAXPROPLEN];
         libzfs_handle_t *libhd;
         zfs_handle_t *zfshd;
         int ret = 0;
 
-        ret = smb_getdataset(si->shr_path, dataset, MAXPATHLEN);
-        if (ret != 0)
-                return (ret);
-
         if ((libhd = libzfs_init()) == NULL)
                 return (-1);
 
+        ret = smb_getdataset(libhd, si->shr_path, dataset, MAXPATHLEN);
+        if (ret != 0) {
+                libzfs_fini(libhd);
+                return (ret);
+        }
+
+
         if ((zfshd = zfs_open(libhd, dataset, ZFS_TYPE_DATASET)) == NULL) {
                 libzfs_fini(libhd);
                 return (-1);
         }