Whamcloud - gitweb
- make HEAD from b_post_cmd3
[fs/lustre-release.git] / lustre / mdd / mdd_lproc.c
1 /* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  mdd/mdd_lproc.c
5  *  Lustre Metadata Server (mdd) routines
6  *
7  *  Copyright (C) 2006 Cluster File Systems, Inc.
8  *   Author: Wang Di <wangdi@clusterfs.com>
9  *
10  *   This file is part of the Lustre file system, http://www.lustre.org
11  *   Lustre is a trademark of Cluster File Systems, Inc.
12  *
13  *   You may have signed or agreed to another license before downloading
14  *   this software.  If so, you are bound by the terms and conditions
15  *   of that agreement, and the following does not apply to you.  See the
16  *   LICENSE file included with this distribution for more information.
17  *
18  *   If you did not agree to a different license, then this copy of Lustre
19  *   is open source software; you can redistribute it and/or modify it
20  *   under the terms of version 2 of the GNU General Public License as
21  *   published by the Free Software Foundation.
22  *
23  *   In either case, Lustre is distributed in the hope that it will be
24  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *   license text for more details.
27  */
28 #ifndef EXPORT_SYMTAB
29 # define EXPORT_SYMTAB
30 #endif
31 #define DEBUG_SUBSYSTEM S_MDS
32
33 #include <linux/module.h>
34 #include <obd.h>
35 #include <obd_class.h>
36 #include <lustre_ver.h>
37 #include <obd_support.h>
38 #include <lprocfs_status.h>
39 #include <lu_time.h>
40
41 #include <lustre/lustre_idl.h>
42
43 #include "mdd_internal.h"
44
45 static const char *mdd_counter_names[LPROC_MDD_NR] = {
46 };
47
48 int mdd_procfs_init(struct mdd_device *mdd, const char *name)
49 {
50         struct lu_device    *ld = &mdd->mdd_md_dev.md_lu_dev;
51         struct obd_type     *type;
52         int                  rc;
53         ENTRY;
54
55         type = ld->ld_type->ldt_obd_type;
56
57         LASSERT(name != NULL);
58         LASSERT(type != NULL);
59
60         /* Find the type procroot and add the proc entry for this device */
61         mdd->mdd_proc_entry = lprocfs_register(name, type->typ_procroot,
62                                                NULL, NULL);
63         if (IS_ERR(mdd->mdd_proc_entry)) {
64                 rc = PTR_ERR(mdd->mdd_proc_entry);
65                 CERROR("Error %d setting up lprocfs for %s\n",
66                        rc, name);
67                 mdd->mdd_proc_entry = NULL;
68                 GOTO(out, rc);
69         }
70
71         rc = lu_time_init(&mdd->mdd_stats,
72                           mdd->mdd_proc_entry,
73                           mdd_counter_names, ARRAY_SIZE(mdd_counter_names));
74         EXIT;
75 out:
76         if (rc)
77                mdd_procfs_fini(mdd);
78         return rc;
79 }
80
81 int mdd_procfs_fini(struct mdd_device *mdd)
82 {
83         if (mdd->mdd_stats)
84                 lu_time_fini(&mdd->mdd_stats);
85
86         if (mdd->mdd_proc_entry) {
87                  lprocfs_remove(&mdd->mdd_proc_entry);
88                  mdd->mdd_proc_entry = NULL;
89         }
90         RETURN(0);
91 }
92
93 void mdd_lprocfs_time_start(const struct lu_env *env)
94 {
95         lu_lprocfs_time_start(env);
96 }
97
98 void mdd_lprocfs_time_end(const struct lu_env *env, struct mdd_device *mdd,
99                           int idx)
100 {
101         lu_lprocfs_time_end(env, mdd->mdd_stats, idx);
102 }