* Allocate an ABD that must be linear, along with its own underlying data * buffer. Only use this when it would be very annoying to write your ABD * consumer with a scattered ABD. */
| 246 | * consumer with a scattered ABD. |
| 247 | */ |
| 248 | abd_t * |
| 249 | abd_alloc_linear(size_t size, boolean_t is_metadata) |
| 250 | { |
| 251 | abd_t *abd = abd_alloc_struct(0); |
| 252 | |
| 253 | VERIFY3U(size, <=, SPA_MAXBLOCKSIZE); |
| 254 | |
| 255 | abd->abd_flags = ABD_FLAG_LINEAR | ABD_FLAG_OWNER; |
| 256 | if (is_metadata) { |
| 257 | abd->abd_flags |= ABD_FLAG_META; |
| 258 | } |
| 259 | abd->abd_size = size; |
| 260 | abd->abd_parent = NULL; |
| 261 | zfs_refcount_create(&abd->abd_children); |
| 262 | |
| 263 | if (is_metadata) { |
| 264 | ABD_LINEAR_BUF(abd) = zio_buf_alloc(size); |
| 265 | } else { |
| 266 | ABD_LINEAR_BUF(abd) = zio_data_buf_alloc(size); |
| 267 | } |
| 268 | |
| 269 | abd_update_linear_stats(abd, ABDSTAT_INCR); |
| 270 | |
| 271 | return (abd); |
| 272 | } |
| 273 | |
| 274 | static void |
| 275 | abd_free_linear(abd_t *abd) |