]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - module/zfs/dsl_bookmark.c
New upstream version 0.7.2
[mirror_zfs-debian.git] / module / zfs / dsl_bookmark.c
index 447a3a2dc3a2de6df39c4061b78772cf11ab0b4a..a6ca1ebab3b24163ab08dd5fa3a0fb8a943395f3 100644 (file)
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 2013, 2014 by Delphix. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc.
  */
 
 #include <sys/zfs_context.h>
@@ -34,10 +36,10 @@ static int
 dsl_bookmark_hold_ds(dsl_pool_t *dp, const char *fullname,
     dsl_dataset_t **dsp, void *tag, char **shortnamep)
 {
-       char buf[MAXNAMELEN];
+       char buf[ZFS_MAX_DATASET_NAME_LEN];
        char *hashp;
 
-       if (strlen(fullname) >= MAXNAMELEN)
+       if (strlen(fullname) >= ZFS_MAX_DATASET_NAME_LEN)
                return (SET_ERROR(ENAMETOOLONG));
        hashp = strchr(fullname, '#');
        if (hashp == NULL)
@@ -59,16 +61,14 @@ dsl_dataset_bmark_lookup(dsl_dataset_t *ds, const char *shortname,
 {
        objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
        uint64_t bmark_zapobj = ds->ds_bookmarks;
-       matchtype_t mt;
+       matchtype_t mt = 0;
        int err;
 
        if (bmark_zapobj == 0)
                return (SET_ERROR(ESRCH));
 
        if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
-               mt = MT_FIRST;
-       else
-               mt = MT_EXACT;
+               mt = MT_NORMALIZE;
 
        err = zap_lookup_norm(mos, bmark_zapobj, shortname, sizeof (uint64_t),
            sizeof (*bmark_phys) / sizeof (uint64_t), bmark_phys, mt,
@@ -342,12 +342,10 @@ dsl_dataset_bookmark_remove(dsl_dataset_t *ds, const char *name, dmu_tx_t *tx)
 {
        objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
        uint64_t bmark_zapobj = ds->ds_bookmarks;
-       matchtype_t mt;
+       matchtype_t mt = 0;
 
        if (dsl_dataset_phys(ds)->ds_flags & DS_FLAG_CI_DATASET)
-               mt = MT_FIRST;
-       else
-               mt = MT_EXACT;
+               mt = MT_NORMALIZE;
 
        return (zap_remove_norm(mos, bmark_zapobj, name, mt, tx));
 }
@@ -360,6 +358,9 @@ dsl_bookmark_destroy_check(void *arg, dmu_tx_t *tx)
        int rv = 0;
        nvpair_t *pair;
 
+       ASSERT(nvlist_empty(dbda->dbda_success));
+       ASSERT(nvlist_empty(dbda->dbda_errors));
+
        if (!spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_BOOKMARKS))
                return (0);
 
@@ -389,7 +390,10 @@ dsl_bookmark_destroy_check(void *arg, dmu_tx_t *tx)
                        }
                }
                if (error == 0) {
-                       fnvlist_add_boolean(dbda->dbda_success, fullname);
+                       if (dmu_tx_is_syncing(tx)) {
+                               fnvlist_add_boolean(dbda->dbda_success,
+                                   fullname);
+                       }
                } else {
                        fnvlist_add_int32(dbda->dbda_errors, fullname, error);
                        rv = error;