Print this page
8115 parallel zfs mount

@@ -20,11 +20,11 @@
  */
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
- * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
  */
 
 #ifndef _LIBZFS_IMPL_H
 #define _LIBZFS_IMPL_H
 

@@ -31,10 +31,11 @@
 #include <sys/fs/zfs.h>
 #include <sys/spa.h>
 #include <sys/nvpair.h>
 #include <sys/dmu.h>
 #include <sys/zfs_ioctl.h>
+#include <synch.h>
 
 #include <libuutil.h>
 #include <libzfs.h>
 #include <libshare.h>
 #include <libzfs_core.h>

@@ -71,10 +72,17 @@
         char libzfs_desc[1024];
         int libzfs_printerr;
         int libzfs_storeerr; /* stuff error messages into buffer */
         void *libzfs_sharehdl; /* libshare handle */
         boolean_t libzfs_mnttab_enable;
+        /*
+         * We need a lock to handle the case where parallel mount threads
+         * are populating the mnttab cache simultaneously. The lock only
+         * protects the integrity of of the avl tree, and does not protect
+         * the contents of the mnttab entries themselves.
+         */
+        mutex_t libzfs_mnttab_cache_lock;
         avl_tree_t libzfs_mnttab_cache;
         int libzfs_pool_iter;
         topo_hdl_t *libzfs_topo_hdl;
         libzfs_fru_t **libzfs_fru_hash;
         libzfs_fru_t *libzfs_fru_list;