summaryrefslogtreecommitdiffstats
path: root/fs/ceph/metric.c
blob: 873a3769fa0d50ed19254eb1bdfbcd396c5b06af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}