summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2021-03-26 11:19:35 -0700
committerGitHub <[email protected]>2021-03-26 11:19:35 -0700
commit2b56a634579e4cdab8d84ccba138e701a6d3bc64 (patch)
tree55314e7c98899656160baa6591b362271cb25f32 /include
parentb85f47efd094dc9ebe210c364e235c6ef99f8417 (diff)
Use a helper function to clarify gang block size
For gang blocks, `DVA_GET_ASIZE()` is the total space allocated for the gang DVA including its children BP's. The space allocated at each DVA's vdev/offset is `vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE)`. This commit makes this relationship more clear by using a helper function, `vdev_gang_header_asize()`, for the space allocated at the gang block's vdev/offset. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matthew Ahrens <[email protected]> Closes #11744
Diffstat (limited to 'include')
-rw-r--r--include/sys/spa.h6
-rw-r--r--include/sys/vdev.h9
2 files changed, 15 insertions, 0 deletions
diff --git a/include/sys/spa.h b/include/sys/spa.h
index 8391be832..c960478ef 100644
--- a/include/sys/spa.h
+++ b/include/sys/spa.h
@@ -405,6 +405,12 @@ typedef struct blkptr {
/*
* Macros to get and set fields in a bp or DVA.
*/
+
+/*
+ * Note, for gang blocks, DVA_GET_ASIZE() is the total space allocated for
+ * this gang DVA including its children BP's. The space allocated at this
+ * DVA's vdev/offset is vdev_gang_header_asize(vdev).
+ */
#define DVA_GET_ASIZE(dva) \
BF64_GET_SB((dva)->dva_word[0], 0, SPA_ASIZEBITS, SPA_MINBLOCKSHIFT, 0)
#define DVA_SET_ASIZE(dva, x) \
diff --git a/include/sys/vdev.h b/include/sys/vdev.h
index d1ef6b5b5..f235bfc8c 100644
--- a/include/sys/vdev.h
+++ b/include/sys/vdev.h
@@ -133,6 +133,15 @@ extern int64_t vdev_deflated_space(vdev_t *vd, int64_t space);
extern uint64_t vdev_psize_to_asize(vdev_t *vd, uint64_t psize);
+/*
+ * Return the amount of space allocated for a gang block header.
+ */
+static inline uint64_t
+vdev_gang_header_asize(vdev_t *vd)
+{
+ return (vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE));
+}
+
extern int vdev_fault(spa_t *spa, uint64_t guid, vdev_aux_t aux);
extern int vdev_degrade(spa_t *spa, uint64_t guid, vdev_aux_t aux);
extern int vdev_online(spa_t *spa, uint64_t guid, uint64_t flags,