Print this page
4046 dsl_dataset_t ds_dir->dd_lock is highly contended
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>

@@ -98,13 +98,12 @@
         if (ds == NULL) {
                 dsl_pool_mos_diduse_space(tx->tx_pool,
                     used, compressed, uncompressed);
                 return;
         }
-        dmu_buf_will_dirty(ds->ds_dbuf, tx);
 
-        mutex_enter(&ds->ds_dir->dd_lock);
+        dmu_buf_will_dirty(ds->ds_dbuf, tx);
         mutex_enter(&ds->ds_lock);
         delta = parent_delta(ds, used);
         ds->ds_phys->ds_referenced_bytes += used;
         ds->ds_phys->ds_compressed_bytes += compressed;
         ds->ds_phys->ds_uncompressed_bytes += uncompressed;

@@ -112,11 +111,10 @@
         mutex_exit(&ds->ds_lock);
         dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD, delta,
             compressed, uncompressed, tx);
         dsl_dir_transfer_space(ds->ds_dir, used - delta,
             DD_USED_REFRSRV, DD_USED_HEAD, tx);
-        mutex_exit(&ds->ds_dir->dd_lock);
 }
 
 int
 dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
     boolean_t async)

@@ -147,11 +145,10 @@
                 int64_t delta;
 
                 dprintf_bp(bp, "freeing ds=%llu", ds->ds_object);
                 dsl_free(tx->tx_pool, tx->tx_txg, bp);
 
-                mutex_enter(&ds->ds_dir->dd_lock);
                 mutex_enter(&ds->ds_lock);
                 ASSERT(ds->ds_phys->ds_unique_bytes >= used ||
                     !DS_UNIQUE_IS_ACCURATE(ds));
                 delta = parent_delta(ds, -used);
                 ds->ds_phys->ds_unique_bytes -= used;

@@ -158,11 +155,10 @@
                 mutex_exit(&ds->ds_lock);
                 dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
                     delta, -compressed, -uncompressed, tx);
                 dsl_dir_transfer_space(ds->ds_dir, -used - delta,
                     DD_USED_REFRSRV, DD_USED_HEAD, tx);
-                mutex_exit(&ds->ds_dir->dd_lock);
         } else {
                 dprintf_bp(bp, "putting on dead list: %s", "");
                 if (async) {
                         /*
                          * We are here as part of zio's write done callback,

@@ -589,35 +585,10 @@
                         }
                 }
         }
 }
 
-static int
-dsl_dataset_namelen(dsl_dataset_t *ds)
-{
-        int result;
-
-        if (ds == NULL) {
-                result = 3;     /* "mos" */
-        } else {
-                result = dsl_dir_namelen(ds->ds_dir);
-                VERIFY0(dsl_dataset_get_snapname(ds));
-                if (ds->ds_snapname[0]) {
-                        ++result;       /* adding one for the @-sign */
-                        if (!MUTEX_HELD(&ds->ds_lock)) {
-                                mutex_enter(&ds->ds_lock);
-                                result += strlen(ds->ds_snapname);
-                                mutex_exit(&ds->ds_lock);
-                        } else {
-                                result += strlen(ds->ds_snapname);
-                        }
-                }
-        }
-
-        return (result);
-}
-
 void
 dsl_dataset_rele(dsl_dataset_t *ds, void *tag)
 {
         dmu_buf_rele(ds->ds_dbuf, tag);
 }