* Allocate an ABD, along with its own underlying data buffers. Use this if you * don't care whether the ABD is linear or not. */
| 165 | * don't care whether the ABD is linear or not. |
| 166 | */ |
| 167 | abd_t * |
| 168 | abd_alloc(size_t size, boolean_t is_metadata) |
| 169 | { |
| 170 | if (!zfs_abd_scatter_enabled || abd_size_alloc_linear(size)) |
| 171 | return (abd_alloc_linear(size, is_metadata)); |
| 172 | |
| 173 | VERIFY3U(size, <=, SPA_MAXBLOCKSIZE); |
| 174 | |
| 175 | abd_t *abd = abd_alloc_struct(size); |
| 176 | abd->abd_flags = ABD_FLAG_OWNER; |
| 177 | abd->abd_u.abd_scatter.abd_offset = 0; |
| 178 | abd_alloc_chunks(abd, size); |
| 179 | |
| 180 | if (is_metadata) { |
| 181 | abd->abd_flags |= ABD_FLAG_META; |
| 182 | } |
| 183 | abd->abd_size = size; |
| 184 | abd->abd_parent = NULL; |
| 185 | zfs_refcount_create(&abd->abd_children); |
| 186 | |
| 187 | abd_update_scatter_stats(abd, ABDSTAT_INCR); |
| 188 | |
| 189 | return (abd); |
| 190 | } |
| 191 | |
| 192 | static void |
| 193 | abd_free_scatter(abd_t *abd) |