Print this page
2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Chris Siden <christopher.siden@delphix.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ztest/ztest.c
          +++ new/usr/src/cmd/ztest/ztest.c
↓ open down ↓ 2244 lines elided ↑ open up ↑
2245 2245  {
2246 2246          ztest_shared_opts_t *zo = &ztest_opts;
2247 2247          spa_t *spa;
2248 2248          nvlist_t *nvroot;
2249 2249  
2250 2250          /*
2251 2251           * Attempt to create using a bad file.
2252 2252           */
2253 2253          nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
2254 2254          VERIFY3U(ENOENT, ==,
2255      -            spa_create("ztest_bad_file", nvroot, NULL, NULL, NULL));
     2255 +            spa_create("ztest_bad_file", nvroot, NULL, NULL));
2256 2256          nvlist_free(nvroot);
2257 2257  
2258 2258          /*
2259 2259           * Attempt to create using a bad mirror.
2260 2260           */
2261 2261          nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 2, 1);
2262 2262          VERIFY3U(ENOENT, ==,
2263      -            spa_create("ztest_bad_mirror", nvroot, NULL, NULL, NULL));
     2263 +            spa_create("ztest_bad_mirror", nvroot, NULL, NULL));
2264 2264          nvlist_free(nvroot);
2265 2265  
2266 2266          /*
2267 2267           * Attempt to create an existing pool.  It shouldn't matter
2268 2268           * what's in the nvroot; we should fail with EEXIST.
2269 2269           */
2270 2270          (void) rw_rdlock(&ztest_name_lock);
2271 2271          nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
2272      -        VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL));
     2272 +        VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL));
2273 2273          nvlist_free(nvroot);
2274 2274          VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
2275 2275          VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool));
2276 2276          spa_close(spa, FTAG);
2277 2277  
2278 2278          (void) rw_unlock(&ztest_name_lock);
2279 2279  }
2280 2280  
2281 2281  static vdev_t *
2282 2282  vdev_lookup_by_path(vdev_t *vd, const char *path)
↓ open down ↓ 766 lines elided ↑ open up ↑
3049 3049  
3050 3050  static boolean_t
3051 3051  ztest_snapshot_create(char *osname, uint64_t id)
3052 3052  {
3053 3053          char snapname[MAXNAMELEN];
3054 3054          int error;
3055 3055  
3056 3056          (void) snprintf(snapname, MAXNAMELEN, "%s@%llu", osname,
3057 3057              (u_longlong_t)id);
3058 3058  
3059      -        error = dmu_objset_snapshot(osname, strchr(snapname, '@') + 1,
3060      -            NULL, NULL, B_FALSE, B_FALSE, -1);
     3059 +        error = dmu_objset_snapshot_one(osname, strchr(snapname, '@') + 1);
3061 3060          if (error == ENOSPC) {
3062 3061                  ztest_record_enospc(FTAG);
3063 3062                  return (B_FALSE);
3064 3063          }
3065 3064          if (error != 0 && error != EEXIST)
3066 3065                  fatal(0, "ztest_snapshot_create(%s) = %d", snapname, error);
3067 3066          return (B_TRUE);
3068 3067  }
3069 3068  
3070 3069  static boolean_t
↓ open down ↓ 179 lines elided ↑ open up ↑
3250 3249          (void) rw_rdlock(&ztest_name_lock);
3251 3250  
3252 3251          ztest_dsl_dataset_cleanup(osname, id);
3253 3252  
3254 3253          (void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
3255 3254          (void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
3256 3255          (void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
3257 3256          (void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
3258 3257          (void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
3259 3258  
3260      -        error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
3261      -            NULL, NULL, B_FALSE, B_FALSE, -1);
     3259 +        error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1);
3262 3260          if (error && error != EEXIST) {
3263 3261                  if (error == ENOSPC) {
3264 3262                          ztest_record_enospc(FTAG);
3265 3263                          goto out;
3266 3264                  }
3267 3265                  fatal(0, "dmu_take_snapshot(%s) = %d", snap1name, error);
3268 3266          }
3269 3267  
3270 3268          error = dmu_objset_hold(snap1name, FTAG, &clone);
3271 3269          if (error)
↓ open down ↓ 2 lines elided ↑ open up ↑
3274 3272          error = dmu_objset_clone(clone1name, dmu_objset_ds(clone), 0);
3275 3273          dmu_objset_rele(clone, FTAG);
3276 3274          if (error) {
3277 3275                  if (error == ENOSPC) {
3278 3276                          ztest_record_enospc(FTAG);
3279 3277                          goto out;
3280 3278                  }
3281 3279                  fatal(0, "dmu_objset_create(%s) = %d", clone1name, error);
3282 3280          }
3283 3281  
3284      -        error = dmu_objset_snapshot(clone1name, strchr(snap2name, '@')+1,
3285      -            NULL, NULL, B_FALSE, B_FALSE, -1);
     3282 +        error = dmu_objset_snapshot_one(clone1name, strchr(snap2name, '@') + 1);
3286 3283          if (error && error != EEXIST) {
3287 3284                  if (error == ENOSPC) {
3288 3285                          ztest_record_enospc(FTAG);
3289 3286                          goto out;
3290 3287                  }
3291 3288                  fatal(0, "dmu_open_snapshot(%s) = %d", snap2name, error);
3292 3289          }
3293 3290  
3294      -        error = dmu_objset_snapshot(clone1name, strchr(snap3name, '@')+1,
3295      -            NULL, NULL, B_FALSE, B_FALSE, -1);
     3291 +        error = dmu_objset_snapshot_one(clone1name, strchr(snap3name, '@') + 1);
3296 3292          if (error && error != EEXIST) {
3297 3293                  if (error == ENOSPC) {
3298 3294                          ztest_record_enospc(FTAG);
3299 3295                          goto out;
3300 3296                  }
3301 3297                  fatal(0, "dmu_open_snapshot(%s) = %d", snap3name, error);
3302 3298          }
3303 3299  
3304 3300          error = dmu_objset_hold(snap3name, FTAG, &clone);
3305 3301          if (error)
↓ open down ↓ 1167 lines elided ↑ open up ↑
4473 4469           * Clean up from any previous run.
4474 4470           */
4475 4471          (void) dmu_objset_destroy(clonename, B_FALSE);
4476 4472          (void) dsl_dataset_user_release(osname, snapname, tag, B_FALSE);
4477 4473          (void) dmu_objset_destroy(fullname, B_FALSE);
4478 4474  
4479 4475          /*
4480 4476           * Create snapshot, clone it, mark snap for deferred destroy,
4481 4477           * destroy clone, verify snap was also destroyed.
4482 4478           */
4483      -        error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
4484      -            FALSE, -1);
     4479 +        error = dmu_objset_snapshot_one(osname, snapname);
4485 4480          if (error) {
4486 4481                  if (error == ENOSPC) {
4487 4482                          ztest_record_enospc("dmu_objset_snapshot");
4488 4483                          goto out;
4489 4484                  }
4490 4485                  fatal(0, "dmu_objset_snapshot(%s) = %d", fullname, error);
4491 4486          }
4492 4487  
4493 4488          error = dmu_objset_hold(fullname, FTAG, &origin);
4494 4489          if (error)
↓ open down ↓ 21 lines elided ↑ open up ↑
4516 4511  
4517 4512          error = dmu_objset_hold(fullname, FTAG, &origin);
4518 4513          if (error != ENOENT)
4519 4514                  fatal(0, "dmu_objset_hold(%s) = %d", fullname, error);
4520 4515  
4521 4516          /*
4522 4517           * Create snapshot, add temporary hold, verify that we can't
4523 4518           * destroy a held snapshot, mark for deferred destroy,
4524 4519           * release hold, verify snapshot was destroyed.
4525 4520           */
4526      -        error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
4527      -            FALSE, -1);
     4521 +        error = dmu_objset_snapshot_one(osname, snapname);
4528 4522          if (error) {
4529 4523                  if (error == ENOSPC) {
4530 4524                          ztest_record_enospc("dmu_objset_snapshot");
4531 4525                          goto out;
4532 4526                  }
4533 4527                  fatal(0, "dmu_objset_snapshot(%s) = %d", fullname, error);
4534 4528          }
4535 4529  
4536 4530          error = dsl_dataset_user_hold(osname, snapname, tag, B_FALSE,
4537 4531              B_TRUE, -1);
↓ open down ↓ 1067 lines elided ↑ open up ↑
5605 5599          zs->zs_mirrors = ztest_opts.zo_mirrors;
5606 5600          nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0,
5607 5601              0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
5608 5602          props = make_random_props();
5609 5603          for (int i = 0; i < SPA_FEATURES; i++) {
5610 5604                  char buf[1024];
5611 5605                  (void) snprintf(buf, sizeof (buf), "feature@%s",
5612 5606                      spa_feature_table[i].fi_uname);
5613 5607                  VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
5614 5608          }
5615      -        VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props,
5616      -            NULL, NULL));
     5609 +        VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
5617 5610          nvlist_free(nvroot);
5618 5611  
5619 5612          VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
5620 5613          zs->zs_metaslab_sz =
5621 5614              1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
5622 5615  
5623 5616          spa_close(spa, FTAG);
5624 5617  
5625 5618          kernel_fini();
5626 5619  
↓ open down ↓ 384 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX