Whamcloud - gitweb
LU-3319 lprocfs: client side cleanups
[fs/lustre-release.git] / lustre / mdc / lproc_mdc.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  */
36 #define DEBUG_SUBSYSTEM S_CLASS
37
38 #include <linux/version.h>
39 #include <linux/vfs.h>
40 #include <obd_class.h>
41 #include <lprocfs_status.h>
42
43 #ifdef LPROCFS
44
45 static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
46 {
47         struct obd_device *dev = m->private;
48         struct client_obd *cli = &dev->u.cli;
49         int rc;
50
51         client_obd_list_lock(&cli->cl_loi_list_lock);
52         rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
53         client_obd_list_unlock(&cli->cl_loi_list_lock);
54         return rc;
55 }
56
57 static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
58                                                 const char *buffer,
59                                                 size_t count,
60                                                 loff_t *off)
61 {
62         struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
63         struct client_obd *cli = &dev->u.cli;
64         int val, rc;
65
66         rc = lprocfs_write_helper(buffer, count, &val);
67         if (rc)
68                 return rc;
69
70         if (val < 1 || val > MDC_MAX_RIF_MAX)
71                 return -ERANGE;
72
73         client_obd_list_lock(&cli->cl_loi_list_lock);
74         cli->cl_max_rpcs_in_flight = val;
75         client_obd_list_unlock(&cli->cl_loi_list_lock);
76
77         return count;
78 }
79 LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
80
81 LPROC_SEQ_FOPS_WO_TYPE(mdc, ping);
82
83 LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
84 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
85 LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
86 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
87 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
88 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
89 LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
90 LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
91 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
92 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
93 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
94 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
95
96 static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
97 {
98         return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
99 }
100 LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
101
102 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
103 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
104
105 struct lprocfs_seq_vars lprocfs_mdc_obd_vars[] = {
106         { .name =       "uuid",
107           .fops =       &mdc_uuid_fops          },
108         { .name =       "ping",
109           .fops =       &mdc_ping_fops,
110           .proc_mode =  0222                    },
111         { .name =       "connect_flags",
112           .fops =       &mdc_connect_flags_fops },
113         { .name =       "blocksize",
114           .fops =       &mdc_blksize_fops       },
115         { .name =       "kbytestotal",
116           .fops =       &mdc_kbytestotal_fops   },
117         { .name =       "kbytesfree",
118           .fops =       &mdc_kbytesfree_fops    },
119         { .name =       "kbytesavail",
120           .fops =       &mdc_kbytesavail_fops   },
121         { .name =       "filestotal",
122           .fops =       &mdc_filestotal_fops    },
123         { .name =       "filesfree",
124           .fops =       &mdc_filesfree_fops     },
125         { .name =       "mds_server_uuid",
126           .fops =       &mdc_server_uuid_fops   },
127         { .name =       "mds_conn_uuid",
128           .fops =       &mdc_conn_uuid_fops     },
129         /*
130          * FIXME: below proc entry is provided, but not in used, instead
131          * sbi->sb_md_brw_size is used, the per obd variable should be used
132          * when CMD is enabled, and dir pages are managed in MDC layer.
133          * Remember to enable proc write function.
134          */
135         { .name =       "max_pages_per_rpc",
136           .fops =       &mdc_obd_max_pages_per_rpc_fops },
137         { .name =       "max_rpcs_in_flight",
138           .fops =       &mdc_max_rpcs_in_flight_fops    },
139         { .name =       "timeouts",
140           .fops =       &mdc_timeouts_fops              },
141         { .name =       "import",
142           .fops =       &mdc_import_fops                },
143         { .name =       "state",
144           .fops =       &mdc_state_fops                 },
145         { .name =       "pinger_recov",
146           .fops =       &mdc_pinger_recov_fops          },
147         { 0 }
148 };
149 #endif /* LPROCFS */