29 #include <sys/dsl_dataset.h>
30 #include <sys/dsl_synctask.h>
31 #include <sys/dmu_tx.h>
32 #include <sys/dsl_pool.h>
33 #include <sys/dsl_dir.h>
34 #include <sys/dmu_traverse.h>
35 #include <sys/dsl_scan.h>
36 #include <sys/dmu_objset.h>
37 #include <sys/zap.h>
38 #include <sys/zfeature.h>
39 #include <sys/zfs_ioctl.h>
40 #include <sys/dsl_deleg.h>
41
42 typedef struct dmu_snapshots_destroy_arg {
43 nvlist_t *dsda_snaps;
44 nvlist_t *dsda_successful_snaps;
45 boolean_t dsda_defer;
46 nvlist_t *dsda_errlist;
47 } dmu_snapshots_destroy_arg_t;
48
49 /*
50 * ds must be owned.
51 */
52 static int
53 dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
54 {
55 if (!dsl_dataset_is_snapshot(ds))
56 return (SET_ERROR(EINVAL));
57
58 if (dsl_dataset_long_held(ds))
59 return (SET_ERROR(EBUSY));
60
61 /*
62 * Only allow deferred destroy on pools that support it.
63 * NOTE: deferred destroy is only supported on snapshots.
64 */
65 if (defer) {
66 if (spa_version(ds->ds_dir->dd_pool->dp_spa) <
67 SPA_VERSION_USERREFS)
68 return (SET_ERROR(ENOTSUP));
69 return (0);
70 }
71
72 /*
|
29 #include <sys/dsl_dataset.h>
30 #include <sys/dsl_synctask.h>
31 #include <sys/dmu_tx.h>
32 #include <sys/dsl_pool.h>
33 #include <sys/dsl_dir.h>
34 #include <sys/dmu_traverse.h>
35 #include <sys/dsl_scan.h>
36 #include <sys/dmu_objset.h>
37 #include <sys/zap.h>
38 #include <sys/zfeature.h>
39 #include <sys/zfs_ioctl.h>
40 #include <sys/dsl_deleg.h>
41
42 typedef struct dmu_snapshots_destroy_arg {
43 nvlist_t *dsda_snaps;
44 nvlist_t *dsda_successful_snaps;
45 boolean_t dsda_defer;
46 nvlist_t *dsda_errlist;
47 } dmu_snapshots_destroy_arg_t;
48
49 int
50 dsl_destroy_snapshot_check_impl(dsl_dataset_t *ds, boolean_t defer)
51 {
52 if (!dsl_dataset_is_snapshot(ds))
53 return (SET_ERROR(EINVAL));
54
55 if (dsl_dataset_long_held(ds))
56 return (SET_ERROR(EBUSY));
57
58 /*
59 * Only allow deferred destroy on pools that support it.
60 * NOTE: deferred destroy is only supported on snapshots.
61 */
62 if (defer) {
63 if (spa_version(ds->ds_dir->dd_pool->dp_spa) <
64 SPA_VERSION_USERREFS)
65 return (SET_ERROR(ENOTSUP));
66 return (0);
67 }
68
69 /*
|