]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/dsl_dataset.c
Fix typo/etc in module/zfs/zfs_ctldir.c
[mirror_zfs.git] / module / zfs / dsl_dataset.c
index ad944e5b8ea21c10093584a1fa32cbc9f7603cd9..966c2cc93d13093baefcef469f0ad3fc033825be 100644 (file)
@@ -621,6 +621,13 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
                        ds->ds_reserved = ds->ds_quota = 0;
                }
 
+               if (err == 0 && ds->ds_dir->dd_crypto_obj != 0 &&
+                   ds->ds_is_snapshot &&
+                   zap_contains(mos, dsobj, DS_FIELD_IVSET_GUID) != 0) {
+                       dp->dp_spa->spa_errata =
+                           ZPOOL_ERRATA_ZOL_8308_ENCRYPTION;
+               }
+
                dsl_deadlist_open(&ds->ds_deadlist,
                    mos, dsl_dataset_phys(ds)->ds_deadlist_obj);
                uint64_t remap_deadlist_obj =
@@ -643,10 +650,14 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
                        if (ds->ds_prev)
                                dsl_dataset_rele(ds->ds_prev, ds);
                        dsl_dir_rele(ds->ds_dir, ds);
+                       list_destroy(&ds->ds_prop_cbs);
+                       list_destroy(&ds->ds_sendstreams);
                        mutex_destroy(&ds->ds_lock);
                        mutex_destroy(&ds->ds_opening_lock);
                        mutex_destroy(&ds->ds_sendstream_lock);
+                       mutex_destroy(&ds->ds_remap_deadlist_lock);
                        zfs_refcount_destroy(&ds->ds_longholds);
+                       rrw_destroy(&ds->ds_bp_rwlock);
                        kmem_free(ds, sizeof (dsl_dataset_t));
                        if (err != 0) {
                                dmu_buf_rele(dbuf, tag);
@@ -1702,6 +1713,30 @@ dsl_dataset_snapshot_sync_impl(dsl_dataset_t *ds, const char *snapname,
                    sizeof (remap_deadlist_obj), 1, &remap_deadlist_obj, tx));
        }
 
+       /*
+        * Create a ivset guid for this snapshot if the dataset is
+        * encrypted. This may be overridden by a raw receive. A
+        * previous implementation of this code did not have this
+        * field as part of the on-disk format for ZFS encryption
+        * (see errata #4). As part of the remediation for this
+        * issue, we ask the user to enable the bookmark_v2 feature
+        * which is now a dependency of the encryption feature. We
+        * use this as a heuristic to determine when the user has
+        * elected to correct any datasets created with the old code.
+        * As a result, we only do this step if the bookmark_v2
+        * feature is enabled, which limits the number of states a
+        * given pool / dataset can be in with regards to terms of
+        * correcting the issue.
+        */
+       if (ds->ds_dir->dd_crypto_obj != 0 &&
+           spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_BOOKMARK_V2)) {
+               uint64_t ivset_guid = unique_create();
+
+               dmu_object_zapify(mos, dsobj, DMU_OT_DSL_DATASET, tx);
+               VERIFY0(zap_add(mos, dsobj, DS_FIELD_IVSET_GUID,
+                   sizeof (ivset_guid), 1, &ivset_guid, tx));
+       }
+
        ASSERT3U(dsl_dataset_phys(ds)->ds_prev_snap_txg, <, tx->tx_txg);
        dsl_dataset_phys(ds)->ds_prev_snap_obj = dsobj;
        dsl_dataset_phys(ds)->ds_prev_snap_txg = crtxg;