4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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
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
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2015, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 #define DEBUG_SUBSYSTEM S_CLASS
38 #include <linux/version.h>
39 #include <linux/vfs.h>
40 #include <obd_class.h>
41 #include <lprocfs_status.h>
43 #include "mdc_internal.h"
46 static int mdc_active_seq_show(struct seq_file *m, void *v)
48 struct obd_device *dev = m->private;
50 LPROCFS_CLIMP_CHECK(dev);
51 seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
52 LPROCFS_CLIMP_EXIT(dev);
56 static ssize_t mdc_active_seq_write(struct file *file,
57 const char __user *buffer,
58 size_t count, loff_t *off)
60 struct obd_device *dev;
64 dev = ((struct seq_file *)file->private_data)->private;
65 rc = lprocfs_str_to_s64(buffer, count, &val);
68 if (val < 0 || val > 1)
72 if (dev->u.cli.cl_import->imp_deactive == val)
73 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
75 CDEBUG(D_CONFIG, "activate "LPD64": ignoring repeat request\n",
80 LPROC_SEQ_FOPS(mdc_active);
82 static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
84 struct obd_device *dev = m->private;
87 max = obd_get_max_rpcs_in_flight(&dev->u.cli);
88 seq_printf(m, "%u\n", max);
93 static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
94 const char __user *buffer,
98 struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
102 rc = lprocfs_str_to_s64(buffer, count, &val);
106 if (val < 0 || val > UINT_MAX)
109 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
115 LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
118 static int mdc_max_mod_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
120 struct obd_device *dev = m->private;
123 max = obd_get_max_mod_rpcs_in_flight(&dev->u.cli);
124 seq_printf(m, "%hu\n", max);
129 static ssize_t mdc_max_mod_rpcs_in_flight_seq_write(struct file *file,
130 const char __user *buffer,
134 struct obd_device *dev =
135 ((struct seq_file *)file->private_data)->private;
139 rc = lprocfs_str_to_s64(buffer, count, &val);
143 if (val < 0 || val > USHRT_MAX)
146 rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
152 LPROC_SEQ_FOPS(mdc_max_mod_rpcs_in_flight);
155 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
157 struct obd_device *dev = seq->private;
159 return obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
163 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
164 const char __user *buf,
165 size_t len, loff_t *off)
167 struct seq_file *seq = file->private_data;
168 struct obd_device *dev = seq->private;
169 struct client_obd *cli = &dev->u.cli;
171 lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
175 LPROC_SEQ_FOPS(mdc_rpc_stats);
178 LPROC_SEQ_FOPS_WO_TYPE(mdc, ping);
180 LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
181 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
182 LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
183 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
184 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
185 LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
186 LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
187 LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
188 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
189 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
190 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
191 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
193 static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
195 return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
197 LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
199 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
200 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
202 struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
204 .fops = &mdc_uuid_fops },
206 .fops = &mdc_ping_fops,
208 { .name = "connect_flags",
209 .fops = &mdc_connect_flags_fops },
210 { .name = "blocksize",
211 .fops = &mdc_blksize_fops },
212 { .name = "kbytestotal",
213 .fops = &mdc_kbytestotal_fops },
214 { .name = "kbytesfree",
215 .fops = &mdc_kbytesfree_fops },
216 { .name = "kbytesavail",
217 .fops = &mdc_kbytesavail_fops },
218 { .name = "filestotal",
219 .fops = &mdc_filestotal_fops },
220 { .name = "filesfree",
221 .fops = &mdc_filesfree_fops },
222 { .name = "mds_server_uuid",
223 .fops = &mdc_server_uuid_fops },
224 { .name = "mds_conn_uuid",
225 .fops = &mdc_conn_uuid_fops },
227 * FIXME: below proc entry is provided, but not in used, instead
228 * sbi->sb_md_brw_size is used, the per obd variable should be used
229 * when CMD is enabled, and dir pages are managed in MDC layer.
230 * Remember to enable proc write function.
232 { .name = "max_pages_per_rpc",
233 .fops = &mdc_obd_max_pages_per_rpc_fops },
234 { .name = "max_rpcs_in_flight",
235 .fops = &mdc_max_rpcs_in_flight_fops },
236 { .name = "max_mod_rpcs_in_flight",
237 .fops = &mdc_max_mod_rpcs_in_flight_fops },
238 { .name = "timeouts",
239 .fops = &mdc_timeouts_fops },
241 .fops = &mdc_import_fops },
243 .fops = &mdc_state_fops },
244 { .name = "pinger_recov",
245 .fops = &mdc_pinger_recov_fops },
246 { .name = "rpc_stats",
247 .fops = &mdc_rpc_stats_fops },
249 .fops = &mdc_active_fops },
252 #endif /* CONFIG_PROC_FS */