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 (MPOOL_IS_AVAIL(pnode
))
23 void mpool_stat_get_bytes(const mpool_t
*mpool
, size_t *avail
, size_t *used
)
25 const blkhead_t
*phead
;
26 const blknode_t
*pnode
;
31 for (i
= 0; i
< mpool
->nblocks
; i
++) {
32 phead
= &mpool
->blktable
[i
];
33 LIST_FOREACH(pnode
, phead
, next_chunk
) {
34 if (MPOOL_IS_AVAIL(pnode
))
35 *avail
+= 1 << pnode
->logsize
;
37 *used
+= 1 << pnode
->logsize
;
42 size_t mpool_stat_get_blocks(const mpool_t
*mpool
)
44 return mpool
->nblocks
;
47 size_t mpool_stat_get_block_length(const mpool_t
*mpool
, size_t pos
)
49 const blknode_t
*pnode
;
52 if (pos
>= mpool
->nblocks
)
53 return 0; /* FIXME: Better error handling */
56 LIST_FOREACH(pnode
, &mpool
->blktable
[pos
], next_chunk
)
63 size_t mpool_stat_get_splits(const mpool_t
*mpool
)
65 return mpool
->nsplits
;
68 size_t mpool_stat_get_merges(const mpool_t
*mpool
)
70 return mpool
->nmerges
;