aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sys/abd.h1
-rw-r--r--module/zfs/abd.c22
2 files changed, 18 insertions, 5 deletions
diff --git a/include/sys/abd.h b/include/sys/abd.h
index 67bf5e802..567b88c0f 100644
--- a/include/sys/abd.h
+++ b/include/sys/abd.h
@@ -93,6 +93,7 @@ abd_t *abd_get_offset_size(abd_t *, size_t, size_t);
abd_t *abd_get_offset_struct(abd_t *, abd_t *, size_t, size_t);
abd_t *abd_get_zeros(size_t);
abd_t *abd_get_from_buf(void *, size_t);
+abd_t *abd_get_from_buf_struct(abd_t *, void *, size_t);
void abd_cache_reap_now(void);
/*
diff --git a/module/zfs/abd.c b/module/zfs/abd.c
index f1df6082f..c8c4d2270 100644
--- a/module/zfs/abd.c
+++ b/module/zfs/abd.c
@@ -603,13 +603,11 @@ abd_get_zeros(size_t size)
}
/*
- * Allocate a linear ABD structure for buf.
+ * Create a linear ABD for an existing buf.
*/
-abd_t *
-abd_get_from_buf(void *buf, size_t size)
+static abd_t *
+abd_get_from_buf_impl(abd_t *abd, void *buf, size_t size)
{
- abd_t *abd = abd_alloc_struct(0);
-
VERIFY3U(size, <=, SPA_MAXBLOCKSIZE);
/*
@@ -625,6 +623,20 @@ abd_get_from_buf(void *buf, size_t size)
return (abd);
}
+abd_t *
+abd_get_from_buf(void *buf, size_t size)
+{
+ abd_t *abd = abd_alloc_struct(0);
+ return (abd_get_from_buf_impl(abd, buf, size));
+}
+
+abd_t *
+abd_get_from_buf_struct(abd_t *abd, void *buf, size_t size)
+{
+ abd_init_struct(abd);
+ return (abd_get_from_buf_impl(abd, buf, size));
+}
+
/*
* Get the raw buffer associated with a linear ABD.
*/