4 void mpool_stat_get_nodes(const mpool_t
*mpool
, size_t *avail
, size_t *used
)
6 const blkhead_t
*phead
;
7 const blknode_t
*pnode
;
12 for (i
= 0; i
< mpool
->nblocks
; i
++) {
13 phead
= &mpool
->blktable
[i
];
14 LIST_FOREACH(pnode
, phead
, next_chunk
) {
15 /*if (pnode->flags & MP_NODE_AVAIL)*/
16 if (MPOOL_IS_AVAIL(pnode
))
24 void mpool_stat_get_bytes(const mpool_t
*mpool
, size_t *avail
, size_t *used
)
26 const blkhead_t
*phead
;
27 const blknode_t
*pnode
;
32 for (i
= 0; i
< mpool
->nblocks
; i
++) {
33 phead
= &mpool
->blktable
[i
];
34 LIST_FOREACH(pnode
, phead
, next_chunk
) {
35 /*if (pnode->flags & MP_NODE_AVAIL)*/
36 if (MPOOL_IS_AVAIL(pnode
))
37 *avail
+= 1 << pnode
->logsize
;
39 *used
+= 1 << pnode
->logsize
;
44 size_t mpool_stat_get_blocks(const mpool_t
*mpool
)
46 return mpool
->nblocks
;
49 size_t mpool_stat_get_block_length(const mpool_t
*mpool
, size_t pos
)
51 const blknode_t
*pnode
;
54 if (pos
>= mpool
->nblocks
)
55 return 0; /* FIXME: Better error handling */
58 LIST_FOREACH(pnode
, &mpool
->blktable
[pos
], next_chunk
)
65 size_t mpool_stat_get_splits(const mpool_t
*mpool
)
67 return mpool
->nsplits
;
70 size_t mpool_stat_get_merges(const mpool_t
*mpool
)
72 return mpool
->nmerges
;