diff options
Diffstat (limited to 'fs/ceph/metric.c')
-rw-r--r-- | fs/ceph/metric.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c new file mode 100644 index 000000000000..873a3769fa0d --- /dev/null +++ b/fs/ceph/metric.c @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#include <linux/types.h> +#include <linux/percpu_counter.h> + +#include "metric.h" + +int ceph_metric_init(struct ceph_client_metric *m) +{ + int ret; + + if (!m) + return -EINVAL; + + atomic64_set(&m->total_dentries, 0); + ret = percpu_counter_init(&m->d_lease_hit, 0, GFP_KERNEL); + if (ret) + return ret; + ret = percpu_counter_init(&m->d_lease_mis, 0, GFP_KERNEL); + if (ret) { + percpu_counter_destroy(&m->d_lease_hit); + return ret; + } + + return 0; +} + +void ceph_metric_destroy(struct ceph_client_metric *m) +{ + if (!m) + return; + + percpu_counter_destroy(&m->d_lease_mis); + percpu_counter_destroy(&m->d_lease_hit); +} |