Whamcloud - gitweb
LU-6822 nrs: remove obsolete assertion in nrs_orr_start()
[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, 2014, 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 #include "mdc_internal.h"
44
45 #ifdef CONFIG_PROC_FS
46
47 static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
48 {
49         struct obd_device *dev = m->private;
50         __u32 max;
51         int rc;
52
53         max = obd_get_max_rpcs_in_flight(&dev->u.cli);
54         rc = seq_printf(m, "%u\n", max);
55
56         return rc;
57 }
58
59 static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
60                                                 const char __user *buffer,
61                                                 size_t count,
62                                                 loff_t *off)
63 {
64         struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
65         int val;
66         int rc;
67
68         rc = lprocfs_write_helper(buffer, count, &val);
69         if (rc == 0)
70                 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
71
72         if (rc != 0)
73                 count = rc;
74
75         return count;
76 }
77 LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
78
79
80 static int mdc_max_mod_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
81 {
82         struct obd_device *dev = m->private;
83         __u16 max;
84         int rc;
85
86         max = obd_get_max_mod_rpcs_in_flight(&dev->u.cli);
87         rc = seq_printf(m, "%hu\n", max);
88
89         return rc;
90 }
91
92 static ssize_t mdc_max_mod_rpcs_in_flight_seq_write(struct file *file,
93                                                     const char *buffer,
94                                                     size_t count,
95                                                     loff_t *off)
96 {
97         struct obd_device *dev =
98                         ((struct seq_file *)file->private_data)->private;
99         int val;
100         int rc;
101
102         rc = lprocfs_write_helper(buffer, count, &val);
103         if (rc != 0)
104                 return rc;
105
106         if (val < 0 || val > USHRT_MAX)
107                 return -ERANGE;
108
109         rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
110         if (rc != 0)
111                 count = rc;
112
113         return count;
114 }
115 LPROC_SEQ_FOPS(mdc_max_mod_rpcs_in_flight);
116
117
118 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
119 {
120         struct obd_device *dev = seq->private;
121
122         return obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
123 }
124
125
126 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
127                                        const char __user *buf,
128                                        size_t len, loff_t *off)
129 {
130         struct seq_file *seq = file->private_data;
131         struct obd_device *dev = seq->private;
132         struct client_obd *cli = &dev->u.cli;
133
134         lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
135
136         return len;
137 }
138 LPROC_SEQ_FOPS(mdc_rpc_stats);
139
140
141 LPROC_SEQ_FOPS_WO_TYPE(mdc, ping);
142
143 LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
144 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
145 LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
146 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
147 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
148 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
149 LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
150 LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
151 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
152 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
153 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
154 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
155
156 static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
157 {
158         return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
159 }
160 LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
161
162 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
163 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
164
165 struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
166         { .name =       "uuid",
167           .fops =       &mdc_uuid_fops          },
168         { .name =       "ping",
169           .fops =       &mdc_ping_fops,
170           .proc_mode =  0222                    },
171         { .name =       "connect_flags",
172           .fops =       &mdc_connect_flags_fops },
173         { .name =       "blocksize",
174           .fops =       &mdc_blksize_fops       },
175         { .name =       "kbytestotal",
176           .fops =       &mdc_kbytestotal_fops   },
177         { .name =       "kbytesfree",
178           .fops =       &mdc_kbytesfree_fops    },
179         { .name =       "kbytesavail",
180           .fops =       &mdc_kbytesavail_fops   },
181         { .name =       "filestotal",
182           .fops =       &mdc_filestotal_fops    },
183         { .name =       "filesfree",
184           .fops =       &mdc_filesfree_fops     },
185         { .name =       "mds_server_uuid",
186           .fops =       &mdc_server_uuid_fops   },
187         { .name =       "mds_conn_uuid",
188           .fops =       &mdc_conn_uuid_fops     },
189         /*
190          * FIXME: below proc entry is provided, but not in used, instead
191          * sbi->sb_md_brw_size is used, the per obd variable should be used
192          * when CMD is enabled, and dir pages are managed in MDC layer.
193          * Remember to enable proc write function.
194          */
195         { .name =       "max_pages_per_rpc",
196           .fops =       &mdc_obd_max_pages_per_rpc_fops },
197         { .name =       "max_rpcs_in_flight",
198           .fops =       &mdc_max_rpcs_in_flight_fops    },
199         { .name =       "max_mod_rpcs_in_flight",
200           .fops =       &mdc_max_mod_rpcs_in_flight_fops        },
201         { .name =       "timeouts",
202           .fops =       &mdc_timeouts_fops              },
203         { .name =       "import",
204           .fops =       &mdc_import_fops                },
205         { .name =       "state",
206           .fops =       &mdc_state_fops                 },
207         { .name =       "pinger_recov",
208           .fops =       &mdc_pinger_recov_fops          },
209         { .name =       "rpc_stats",
210           .fops =       &mdc_rpc_stats_fops             },
211         { NULL }
212 };
213 #endif /* CONFIG_PROC_FS */