Whamcloud - gitweb
b=14184
[fs/lustre-release.git] / lustre / mdc / lproc_mdc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  *
24  */
25 #define DEBUG_SUBSYSTEM S_CLASS
26
27 #include <linux/version.h>
28 #include <linux/vfs.h>
29 #include <obd_class.h>
30 #include <lprocfs_status.h>
31
32 #ifdef LPROCFS
33
34 static int mdc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
35                                      int count, int *eof, void *data)
36 {
37         struct obd_device *dev = data;
38         struct client_obd *cli = &dev->u.cli;
39         int rc;
40
41         spin_lock(&cli->cl_loi_list_lock);
42         rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight);
43         spin_unlock(&cli->cl_loi_list_lock);
44         return rc;
45 }
46
47 static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
48                                      unsigned long count, void *data)
49 {
50         struct obd_device *dev = data;
51         struct client_obd *cli = &dev->u.cli;
52         int val, rc;
53
54         rc = lprocfs_write_helper(buffer, count, &val);
55         if (rc)
56                 return rc;
57
58         if (val < 1 || val > MDC_MAX_RIF_MAX)
59                 return -ERANGE;
60
61         spin_lock(&cli->cl_loi_list_lock);
62         cli->cl_max_rpcs_in_flight = val;
63         spin_unlock(&cli->cl_loi_list_lock);
64
65         return count;
66 }
67 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
68         { "uuid",            lprocfs_rd_uuid,        0, 0 },
69         { "ping",            0, lprocfs_wr_ping,        0 },
70         { "connect_flags",   lprocfs_rd_connect_flags, 0, 0 },
71         { "blocksize",       lprocfs_rd_blksize,     0, 0 },
72         { "kbytestotal",     lprocfs_rd_kbytestotal, 0, 0 },
73         { "kbytesfree",      lprocfs_rd_kbytesfree,  0, 0 },
74         { "kbytesavail",     lprocfs_rd_kbytesavail, 0, 0 },
75         { "filestotal",      lprocfs_rd_filestotal,  0, 0 },
76         { "filesfree",       lprocfs_rd_filesfree,   0, 0 },
77         //{ "filegroups",      lprocfs_rd_filegroups,  0, 0 },
78         { "mds_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
79         { "mds_conn_uuid",   lprocfs_rd_conn_uuid,   0, 0 },
80         { "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight,
81                                 mdc_wr_max_rpcs_in_flight, 0 },
82         { "sptlrpc",         sptlrpc_lprocfs_rd, 0, 0 },
83         { 0 }
84 };
85
86 static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
87         { "num_refs",        lprocfs_rd_numrefs,     0, 0 },
88         { 0 }
89 };
90
91 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
92 {
93     lvars->module_vars  = lprocfs_mdc_module_vars;
94     lvars->obd_vars     = lprocfs_mdc_obd_vars;
95 }
96 #endif /* LPROCFS */
97