• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-12-stable/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/

Lines Matching defs:abd

88 #include <sys/abd.h>
169 extern inline boolean_t abd_is_linear(abd_t *abd);
171 extern inline void abd_copy_from_buf(abd_t *abd, const void *buf, size_t size);
172 extern inline void abd_copy_to_buf(void* buf, abd_t *abd, size_t size);
173 extern inline int abd_cmp_buf(abd_t *abd, const void *buf, size_t size);
174 extern inline void abd_zero(abd_t *abd, size_t size);
237 abd_scatter_chunkcnt(abd_t *abd)
239 ASSERT(!abd_is_linear(abd));
241 abd->abd_u.abd_scatter.abd_offset + abd->abd_size));
245 abd_verify(abd_t *abd)
247 ASSERT3U(abd->abd_size, >, 0);
248 ASSERT3U(abd->abd_size, <=, SPA_MAXBLOCKSIZE);
249 ASSERT3U(abd->abd_flags, ==, abd->abd_flags & (ABD_FLAG_LINEAR |
251 IMPLY(abd->abd_parent != NULL, !(abd->abd_flags & ABD_FLAG_OWNER));
252 IMPLY(abd->abd_flags & ABD_FLAG_META, abd->abd_flags & ABD_FLAG_OWNER);
253 if (abd_is_linear(abd)) {
254 ASSERT3P(abd->abd_u.abd_linear.abd_buf, !=, NULL);
256 ASSERT3U(abd->abd_u.abd_scatter.abd_offset, <,
258 size_t n = abd_scatter_chunkcnt(abd);
261 abd->abd_u.abd_scatter.abd_chunks[i], !=, NULL);
270 abd_t *abd = kmem_alloc(size, KM_PUSHPAGE);
271 ASSERT3P(abd, !=, NULL);
274 return (abd);
278 abd_free_struct(abd_t *abd)
280 size_t chunkcnt = abd_is_linear(abd) ? 0 : abd_scatter_chunkcnt(abd);
282 kmem_free(abd, size);
299 abd_t *abd = abd_alloc_struct(n);
301 abd->abd_flags = ABD_FLAG_OWNER;
303 abd->abd_flags |= ABD_FLAG_META;
305 abd->abd_size = size;
306 abd->abd_parent = NULL;
307 zfs_refcount_create(&abd->abd_children);
309 abd->abd_u.abd_scatter.abd_offset = 0;
310 abd->abd_u.abd_scatter.abd_chunk_size = zfs_abd_chunk_size;
315 abd->abd_u.abd_scatter.abd_chunks[i] = c;
323 return (abd);
327 abd_free_scatter(abd_t *abd)
329 size_t n = abd_scatter_chunkcnt(abd);
331 abd_free_chunk(abd->abd_u.abd_scatter.abd_chunks[i]);
334 zfs_refcount_destroy(&abd->abd_children);
336 ABDSTAT_INCR(abdstat_scatter_data_size, -(int)abd->abd_size);
338 abd->abd_size - n * zfs_abd_chunk_size);
340 abd_free_struct(abd);
351 abd_t *abd = abd_alloc_struct(0);
355 abd->abd_flags = ABD_FLAG_LINEAR | ABD_FLAG_OWNER;
357 abd->abd_flags |= ABD_FLAG_META;
359 abd->abd_size = size;
360 abd->abd_parent = NULL;
361 zfs_refcount_create(&abd->abd_children);
364 abd->abd_u.abd_linear.abd_buf = zio_buf_alloc(size);
366 abd->abd_u.abd_linear.abd_buf = zio_data_buf_alloc(size);
372 return (abd);
376 abd_free_linear(abd_t *abd)
378 if (abd->abd_flags & ABD_FLAG_META) {
379 zio_buf_free(abd->abd_u.abd_linear.abd_buf, abd->abd_size);
381 zio_data_buf_free(abd->abd_u.abd_linear.abd_buf, abd->abd_size);
384 zfs_refcount_destroy(&abd->abd_children);
386 ABDSTAT_INCR(abdstat_linear_data_size, -(int)abd->abd_size);
388 abd_free_struct(abd);
396 abd_free(abd_t *abd)
398 abd_verify(abd);
399 ASSERT3P(abd->abd_parent, ==, NULL);
400 ASSERT(abd->abd_flags & ABD_FLAG_OWNER);
401 if (abd_is_linear(abd))
402 abd_free_linear(abd);
404 abd_free_scatter(abd);
446 abd_t *abd;
452 abd = abd_alloc_struct(0);
459 abd->abd_flags = ABD_FLAG_LINEAR;
461 abd->abd_u.abd_linear.abd_buf =
468 abd = abd_alloc_struct(chunkcnt);
475 abd->abd_flags = 0;
477 abd->abd_u.abd_scatter.abd_offset =
479 abd->abd_u.abd_scatter.abd_chunk_size = zfs_abd_chunk_size;
482 (void) memcpy(&abd->abd_u.abd_scatter.abd_chunks,
488 abd->abd_size = sabd->abd_size - off;
489 abd->abd_parent = sabd;
490 zfs_refcount_create(&abd->abd_children);
491 (void) zfs_refcount_add_many(&sabd->abd_children, abd->abd_size, abd);
493 return (abd);
503 abd_t *abd = abd_alloc_struct(0);
512 abd->abd_flags = ABD_FLAG_LINEAR;
513 abd->abd_size = size;
514 abd->abd_parent = NULL;
515 zfs_refcount_create(&abd->abd_children);
517 abd->abd_u.abd_linear.abd_buf = buf;
519 return (abd);
527 abd_put(abd_t *abd)
529 abd_verify(abd);
530 ASSERT(!(abd->abd_flags & ABD_FLAG_OWNER));
532 if (abd->abd_parent != NULL) {
533 (void) zfs_refcount_remove_many(&abd->abd_parent->abd_children,
534 abd->abd_size, abd);
537 zfs_refcount_destroy(&abd->abd_children);
538 abd_free_struct(abd);
545 abd_to_buf(abd_t *abd)
547 ASSERT(abd_is_linear(abd));
548 abd_verify(abd);
549 return (abd->abd_u.abd_linear.abd_buf);
559 abd_borrow_buf(abd_t *abd, size_t n)
562 abd_verify(abd);
563 ASSERT3U(abd->abd_size, >=, n);
564 if (abd_is_linear(abd)) {
565 buf = abd_to_buf(abd);
569 (void) zfs_refcount_add_many(&abd->abd_children, n, buf);
575 abd_borrow_buf_copy(abd_t *abd, size_t n)
577 void *buf = abd_borrow_buf(abd, n);
578 if (!abd_is_linear(abd)) {
579 abd_copy_to_buf(buf, abd, n);
588 * be copied back to abd, use abd_return_buf_copy() instead.
591 abd_return_buf(abd_t *abd, void *buf, size_t n)
593 abd_verify(abd);
594 ASSERT3U(abd->abd_size, >=, n);
595 if (abd_is_linear(abd)) {
596 ASSERT3P(buf, ==, abd_to_buf(abd));
598 ASSERT0(abd_cmp_buf(abd, buf, n));
601 (void) zfs_refcount_remove_many(&abd->abd_children, n, buf);
605 abd_return_buf_copy(abd_t *abd, void *buf, size_t n)
607 if (!abd_is_linear(abd)) {
608 abd_copy_from_buf(abd, buf, n);
610 abd_return_buf(abd, buf, n);
620 abd_take_ownership_of_buf(abd_t *abd, boolean_t is_metadata)
622 ASSERT(abd_is_linear(abd));
623 ASSERT(!(abd->abd_flags & ABD_FLAG_OWNER));
624 abd_verify(abd);
626 abd->abd_flags |= ABD_FLAG_OWNER;
628 abd->abd_flags |= ABD_FLAG_META;
632 ABDSTAT_INCR(abdstat_linear_data_size, abd->abd_size);
636 abd_release_ownership_of_buf(abd_t *abd)
638 ASSERT(abd_is_linear(abd));
639 ASSERT(abd->abd_flags & ABD_FLAG_OWNER);
640 abd_verify(abd);
642 abd->abd_flags &= ~ABD_FLAG_OWNER;
644 abd->abd_flags &= ~ABD_FLAG_META;
647 ABDSTAT_INCR(abdstat_linear_data_size, -(int)abd->abd_size);
677 abd_iter_init(struct abd_iter *aiter, abd_t *abd)
679 abd_verify(abd);
680 aiter->iter_abd = abd;
757 abd_iterate_func(abd_t *abd, size_t off, size_t size,
763 abd_verify(abd);
764 ASSERT3U(off + size, <=, abd->abd_size);
766 abd_iter_init(&aiter, abd);
805 * Copy abd to buf. (off is the offset in abd.)
808 abd_copy_to_buf_off(void *buf, abd_t *abd, size_t off, size_t size)
812 (void) abd_iterate_func(abd, off, size, abd_copy_to_buf_off_cb,
829 * Compare the contents of abd to buf. (off is the offset in abd.)
832 abd_cmp_buf_off(abd_t *abd, const void *buf, size_t off, size_t size)
836 return (abd_iterate_func(abd, off, size, abd_cmp_buf_off_cb, &ba_ptr));
851 * Copy from buf to abd. (off is the offset in abd.)
854 abd_copy_from_buf_off(abd_t *abd, const void *buf, size_t off, size_t size)
858 (void) abd_iterate_func(abd, off, size, abd_copy_from_buf_off_cb,
871 * Zero out the abd from a particular offset to the end.
874 abd_zero_off(abd_t *abd, size_t off, size_t size)
876 (void) abd_iterate_func(abd, off, size, abd_zero_off_cb, NULL);