1 /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
7 * Copyright (C) 2006 Cluster File Systems, Inc.
8 * Author: Wang Di <wangdi@clusterfs.com>
9 * Author: Yury Umanets <umka@clusterfs.com>
11 * This file is part of the Lustre file system, http://www.lustre.org
12 * Lustre is a trademark of Cluster File Systems, Inc.
14 * You may have signed or agreed to another license before downloading
15 * this software. If so, you are bound by the terms and conditions
16 * of that agreement, and the following does not apply to you. See the
17 * LICENSE file included with this distribution for more information.
19 * If you did not agree to a different license, then this copy of Lustre
20 * is open source software; you can redistribute it and/or modify it
21 * under the terms of version 2 of the GNU General Public License as
22 * published by the Free Software Foundation.
24 * In either case, Lustre is distributed in the hope that it will be
25 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
26 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * license text for more details.
30 # define EXPORT_SYMTAB
32 #define DEBUG_SUBSYSTEM S_MDS
34 #include <linux/module.h>
36 #include <obd_class.h>
37 #include <lustre_ver.h>
38 #include <obd_support.h>
39 #include <lprocfs_status.h>
42 #include <lustre/lustre_idl.h>
44 #include "cmm_internal.h"
46 static const char *cmm_counter_names[LPROC_CMM_NR] = {
47 [LPROC_CMM_SPLIT_CHECK] = "split_check",
48 [LPROC_CMM_SPLIT] = "split",
49 [LPROC_CMM_LOOKUP] = "lookup",
50 [LPROC_CMM_CREATE] = "create"
53 int cmm_procfs_init(struct cmm_device *cmm, const char *name)
55 struct lu_device *ld = &cmm->cmm_md_dev.md_lu_dev;
56 struct obd_type *type;
60 type = ld->ld_type->ldt_obd_type;
62 LASSERT(name != NULL);
63 LASSERT(type != NULL);
65 /* Find the type procroot and add the proc entry for this device. */
66 cmm->cmm_proc_entry = lprocfs_register(name, type->typ_procroot,
68 if (IS_ERR(cmm->cmm_proc_entry)) {
69 rc = PTR_ERR(cmm->cmm_proc_entry);
70 CERROR("Error %d setting up lprocfs for %s\n",
72 cmm->cmm_proc_entry = NULL;
76 rc = lu_time_init(&cmm->cmm_stats,
78 cmm_counter_names, ARRAY_SIZE(cmm_counter_names));
87 int cmm_procfs_fini(struct cmm_device *cmm)
90 lu_time_fini(&cmm->cmm_stats);
92 if (cmm->cmm_proc_entry) {
93 lprocfs_remove(&cmm->cmm_proc_entry);
94 cmm->cmm_proc_entry = NULL;
99 void cmm_lprocfs_time_start(const struct lu_env *env)
101 lu_lprocfs_time_start(env);
104 void cmm_lprocfs_time_end(const struct lu_env *env, struct cmm_device *cmm,
107 lu_lprocfs_time_end(env, cmm->cmm_stats, idx);