]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/space_map.h
OpenZFS 7614, 9064 - zfs device evacuation/removal
[mirror_zfs.git] / include / sys / space_map.h
index a59e6d37d43a11546c16ddf296338aab12b96035..457300d053285a0158066b6d2c69bc66660a9457 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 /*
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
  */
 
 #ifndef _SYS_SPACE_MAP_H
@@ -73,6 +73,9 @@ typedef struct space_map_phys {
  * The space map object defines a region of space, its size, how much is
  * allocated, and the on-disk object that stores this information.
  * Consumers of space maps may only access the members of this structure.
+ *
+ * Note: the space_map may not be accessed concurrently; consumers
+ * must provide external locking if required.
  */
 typedef struct space_map {
        uint64_t        sm_start;       /* start of map */
@@ -85,7 +88,6 @@ typedef struct space_map {
        uint32_t        sm_blksz;       /* block size for space map */
        dmu_buf_t       *sm_dbuf;       /* space_map_phys_t dbuf */
        space_map_phys_t *sm_phys;      /* on-disk space map */
-       kmutex_t        *sm_lock;       /* pointer to lock that protects map */
 } space_map_t;
 
 /*
@@ -133,7 +135,11 @@ typedef enum {
        SM_FREE
 } maptype_t;
 
+typedef int (*sm_cb_t)(maptype_t type, uint64_t offset, uint64_t size,
+    void *arg);
+
 int space_map_load(space_map_t *sm, range_tree_t *rt, maptype_t maptype);
+int space_map_iterate(space_map_t *sm, sm_cb_t callback, void *arg);
 
 void space_map_histogram_clear(space_map_t *sm);
 void space_map_histogram_add(space_map_t *sm, range_tree_t *rt,
@@ -150,9 +156,10 @@ void space_map_write(space_map_t *sm, range_tree_t *rt, maptype_t maptype,
 void space_map_truncate(space_map_t *sm, dmu_tx_t *tx);
 uint64_t space_map_alloc(objset_t *os, dmu_tx_t *tx);
 void space_map_free(space_map_t *sm, dmu_tx_t *tx);
+void space_map_free_obj(objset_t *os, uint64_t smobj, dmu_tx_t *tx);
 
 int space_map_open(space_map_t **smp, objset_t *os, uint64_t object,
-    uint64_t start, uint64_t size, uint8_t shift, kmutex_t *lp);
+    uint64_t start, uint64_t size, uint8_t shift);
 void space_map_close(space_map_t *sm);
 
 int64_t space_map_alloc_delta(space_map_t *sm);