1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 /* 13 * Copyright (c) 2014, 2018 by Delphix. All rights reserved. 14 */ 15 16 #ifndef _BQUEUE_H 17 #define _BQUEUE_H 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 #include <sys/zfs_context.h> 24 25 typedef struct bqueue { 26 list_t bq_list; 27 size_t bq_size; 28 list_t bq_dequeuing_list; 29 size_t bq_dequeuing_size; 30 list_t bq_enqueuing_list; 31 size_t bq_enqueuing_size; 32 kmutex_t bq_lock; 33 kcondvar_t bq_add_cv; 34 kcondvar_t bq_pop_cv; 35 size_t bq_maxsize; 36 uint_t bq_fill_fraction; 37 size_t bq_node_offset; 38 } bqueue_t; 39 40 typedef struct bqueue_node { 41 list_node_t bqn_node; 42 size_t bqn_size; 43 } bqueue_node_t; 44 45 46 int bqueue_init(bqueue_t *, uint_t, size_t, size_t); 47 void bqueue_destroy(bqueue_t *); 48 void bqueue_enqueue(bqueue_t *, void *, size_t); 49 void bqueue_enqueue_flush(bqueue_t *, void *, size_t); 50 void *bqueue_dequeue(bqueue_t *); 51 52 #ifdef __cplusplus 53 } 54 #endif 55 56 #endif /* _BQUEUE_H */ 57