]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/dsl_dir.h
ztest: scrub ddt repair
[mirror_zfs.git] / include / sys / dsl_dir.h
index 2477e89af64ac037a4404f13bab1676be0cc4761..067bcfb6afe9a39db01a8309bed8b0809410b643 100644 (file)
@@ -20,7 +20,9 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+ * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  */
 
 #ifndef        _SYS_DSL_DIR_H
@@ -31,6 +33,7 @@
 #include <sys/dsl_synctask.h>
 #include <sys/refcount.h>
 #include <sys/zfs_context.h>
+#include <sys/dsl_crypt.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -38,6 +41,16 @@ extern "C" {
 
 struct dsl_dataset;
 
+/*
+ * DD_FIELD_* are strings that are used in the "extensified" dsl_dir zap object.
+ * They should be of the format <reverse-dns>:<field>.
+ */
+
+#define        DD_FIELD_FILESYSTEM_COUNT       "com.joyent:filesystem_count"
+#define        DD_FIELD_SNAPSHOT_COUNT         "com.joyent:snapshot_count"
+#define        DD_FIELD_CRYPTO_KEY_OBJ         "com.datto:crypto_key_obj"
+#define        DD_FIELD_LAST_REMAP_TXG         "com.delphix:last_remap_txg"
+
 typedef enum dd_used {
        DD_USED_HEAD,
        DD_USED_SNAP,
@@ -75,12 +88,16 @@ typedef struct dsl_dir_phys {
 } dsl_dir_phys_t;
 
 struct dsl_dir {
+       dmu_buf_user_t dd_dbu;
+
        /* These are immutable; no lock needed: */
        uint64_t dd_object;
-       dsl_dir_phys_t *dd_phys;
-       dmu_buf_t *dd_dbuf;
+       uint64_t dd_crypto_obj;
        dsl_pool_t *dd_pool;
 
+       /* Stable until user eviction; no lock needed: */
+       dmu_buf_t *dd_dbuf;
+
        /* protected by lock on pool's dp_dirty_dirs list */
        txg_node_t dd_dirty_link;
 
@@ -89,8 +106,8 @@ struct dsl_dir {
 
        /* Protected by dd_lock */
        kmutex_t dd_lock;
-       list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
-       timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
+       list_t dd_props; /* list of dsl_prop_record_t's */
+       inode_timespec_t dd_snap_cmtime; /* last snapshot namespace change */
        uint64_t dd_origin_txg;
 
        /* gross estimate of space used by in-flight tx's */
@@ -99,10 +116,17 @@ struct dsl_dir {
        int64_t dd_space_towrite[TXG_SIZE];
 
        /* protected by dd_lock; keep at end of struct for better locality */
-       char dd_myname[MAXNAMELEN];
+       char dd_myname[ZFS_MAX_DATASET_NAME_LEN];
 };
 
+static inline dsl_dir_phys_t *
+dsl_dir_phys(dsl_dir_t *dd)
+{
+       return (dd->dd_dbuf->db_data);
+}
+
 void dsl_dir_rele(dsl_dir_t *dd, void *tag);
+void dsl_dir_async_rele(dsl_dir_t *dd, void *tag);
 int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
     dsl_dir_t **, const char **tail);
 int dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
@@ -111,14 +135,29 @@ void dsl_dir_name(dsl_dir_t *dd, char *buf);
 int dsl_dir_namelen(dsl_dir_t *dd);
 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
     const char *name, dmu_tx_t *tx);
+
+uint64_t dsl_dir_get_used(dsl_dir_t *dd);
+uint64_t dsl_dir_get_compressed(dsl_dir_t *dd);
+uint64_t dsl_dir_get_quota(dsl_dir_t *dd);
+uint64_t dsl_dir_get_reservation(dsl_dir_t *dd);
+uint64_t dsl_dir_get_compressratio(dsl_dir_t *dd);
+uint64_t dsl_dir_get_logicalused(dsl_dir_t *dd);
+uint64_t dsl_dir_get_usedsnap(dsl_dir_t *dd);
+uint64_t dsl_dir_get_usedds(dsl_dir_t *dd);
+uint64_t dsl_dir_get_usedrefreserv(dsl_dir_t *dd);
+uint64_t dsl_dir_get_usedchild(dsl_dir_t *dd);
+void dsl_dir_get_origin(dsl_dir_t *dd, char *buf);
+int dsl_dir_get_filesystem_count(dsl_dir_t *dd, uint64_t *count);
+int dsl_dir_get_snapshot_count(dsl_dir_t *dd, uint64_t *count);
+
 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
     dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
+int dsl_dir_get_remaptxg(dsl_dir_t *dd, uint64_t *count);
 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
-    uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
-    dmu_tx_t *tx);
+    uint64_t asize, boolean_t netfree, void **tr_cookiep, dmu_tx_t *tx);
 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
@@ -129,30 +168,37 @@ int dsl_dir_set_quota(const char *ddname, zprop_source_t source,
     uint64_t quota);
 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
     uint64_t reservation);
+int dsl_dir_activate_fs_ss_limit(const char *);
+int dsl_fs_ss_limit_check(dsl_dir_t *, uint64_t, zfs_prop_t, dsl_dir_t *,
+    cred_t *);
+void dsl_fs_ss_count_adjust(dsl_dir_t *, int64_t, const char *, dmu_tx_t *);
+int dsl_dir_update_last_remap_txg(dsl_dir_t *, uint64_t);
 int dsl_dir_rename(const char *oldname, const char *newname);
-int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space);
+int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd,
+    uint64_t fs_cnt, uint64_t ss_cnt, uint64_t space, cred_t *);
 boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
     uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
-timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
+inode_timespec_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
 void dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value,
     dmu_tx_t *tx);
+void dsl_dir_zapify(dsl_dir_t *dd, dmu_tx_t *tx);
+boolean_t dsl_dir_is_zapified(dsl_dir_t *dd);
 
 /* internal reserved dir name */
 #define        MOS_DIR_NAME "$MOS"
 #define        ORIGIN_DIR_NAME "$ORIGIN"
-#define        XLATION_DIR_NAME "$XLATION"
 #define        FREE_DIR_NAME "$FREE"
+#define        LEAK_DIR_NAME "$LEAK"
 
 #ifdef ZFS_DEBUG
 #define        dprintf_dd(dd, fmt, ...) do { \
        if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
-       char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
-           KM_PUSHPAGE); \
+       char *__ds_name = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP); \
        dsl_dir_name(dd, __ds_name); \
        dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
-       kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \
+       kmem_free(__ds_name, ZFS_MAX_DATASET_NAME_LEN); \
        } \
 _NOTE(CONSTCOND) } while (0)
 #else