2 * Copyright (c) 2013 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 * by Antonio Huete Jimenez <tuxillo@quantumachine.net>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <sys/sysctl.h>
39 #include "libhammer.h"
43 dosysctl(const char *sname
, int64_t *value
)
49 error
= sysctlbyname(sname
, value
, &len
, NULL
, 0);
55 libhammer_stats_redo(int64_t *value
)
57 return (dosysctl("vfs.hammer.stats_redo", value
));
61 libhammer_stats_undo(int64_t *value
)
63 return (dosysctl("vfs.hammer.stats_undo", value
));
67 libhammer_stats_commits(int64_t *value
)
69 return (dosysctl("vfs.hammer.stats_commits", value
));
73 libhammer_stats_inode_flushes(int64_t *value
)
75 return (dosysctl("vfs.hammer.stats_inode_flushes", value
));
79 libhammer_stats_disk_write(int64_t *value
)
81 return (dosysctl("vfs.hammer.stats_disk_write", value
));
85 libhammer_stats_disk_read(int64_t *value
)
87 return (dosysctl("vfs.hammer.stats_disk_read", value
));
91 libhammer_stats_file_iopsw(int64_t *value
)
93 return (dosysctl("vfs.hammer.stats_file_iopsw", value
));
97 libhammer_stats_file_iopsr(int64_t *value
)
99 return (dosysctl("vfs.hammer.stats_file_iopsr", value
));
103 libhammer_stats_file_write(int64_t *value
)
105 return (dosysctl("vfs.hammer.stats_file_write", value
));
109 libhammer_stats_file_read(int64_t *value
)
111 return (dosysctl("vfs.hammer.stats_file_read", value
));
115 libhammer_stats_record_iterations(int64_t *value
)
117 return (dosysctl("vfs.hammer.stats_record_iterations", value
));
121 libhammer_stats_root_iterations(int64_t *value
)
123 return (dosysctl("vfs.hammer.stats_btree_root_iterations", value
));
127 libhammer_stats_btree_iterations(int64_t *value
)
129 return (dosysctl("vfs.hammer.stats_btree_iterations", value
));
133 libhammer_stats_btree_splits(int64_t *value
)
135 return (dosysctl("vfs.hammer.stats_btree_splits", value
));
139 libhammer_stats_btree_elements(int64_t *value
)
141 return (dosysctl("vfs.hammer.stats_btree_elements", value
));
145 libhammer_stats_btree_deletes(int64_t *value
)
147 return (dosysctl("vfs.hammer.stats_btree_deletes", value
));
151 libhammer_stats_btree_inserts(int64_t *value
)
153 return (dosysctl("vfs.hammer.stats_btree_inserts", value
));
157 libhammer_stats_btree_lookups(int64_t *value
)
159 return (dosysctl("vfs.hammer.stats_btree_lookups", value
));
163 libhammer_stats_btree_searches(int64_t *value
)
165 return (dosysctl("vfs.hammer.stats_btree_searches", value
));
169 libhammer_btree_stats(struct libhammer_btree_stats
*bstats
)
171 if (libhammer_stats_btree_elements(&bstats
->elements
) < 0)
173 if (libhammer_stats_btree_iterations(&bstats
->iterations
) < 0)
175 if (libhammer_stats_btree_splits(&bstats
->splits
) < 0)
177 if (libhammer_stats_btree_inserts(&bstats
->inserts
) < 0)
179 if (libhammer_stats_btree_deletes(&bstats
->deletes
) < 0)
181 if (libhammer_stats_btree_lookups(&bstats
->lookups
) < 0)
183 if (libhammer_stats_btree_searches(&bstats
->searches
) < 0)
189 libhammer_io_stats(struct libhammer_io_stats
*iostats
)
191 if (libhammer_stats_undo(&iostats
->undo
) < 0)
193 if (libhammer_stats_commits(&iostats
->commits
) < 0)
195 if (libhammer_stats_inode_flushes(&iostats
->inode_flushes
) < 0)
197 if (libhammer_stats_disk_write(&iostats
->dev_writes
) < 0)
199 if (libhammer_stats_disk_read(&iostats
->dev_reads
) < 0)
201 if (libhammer_stats_file_iopsw(&iostats
->file_iop_writes
) < 0)
203 if (libhammer_stats_file_iopsr(&iostats
->file_iop_reads
) < 0)
205 if (libhammer_stats_file_write(&iostats
->file_writes
) < 0)
207 if (libhammer_stats_file_read(&iostats
->file_reads
) < 0)