1 // SPDX-License-Identifier: GPL-2.0
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 only,
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License version 2 for more details (a copy is included
15 * in the LICENSE file that accompanied this code).
17 * You should have received a copy of the GNU General Public License
18 * version 2 along with this program; If not, see
19 * http://www.gnu.org/licenses/gpl-2.0.html
24 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Use is subject to license terms.
27 * Copyright (c) 2011, 2015, Intel Corporation.
30 * This file is part of Lustre, http://www.lustre.org/
31 * Lustre is a trademark of Sun Microsystems, Inc.
33 #define DEBUG_SUBSYSTEM S_CLASS
35 #include <linux/vfs.h>
36 #include <obd_class.h>
37 #include <lprocfs_status.h>
38 #include "mdc_internal.h"
40 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
43 struct obd_device *dev = container_of(kobj, struct obd_device,
46 return sprintf(buf, "%u\n", !dev->u.cli.cl_import->imp_deactive);
49 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
50 const char *buffer, size_t count)
52 struct obd_device *dev = container_of(kobj, struct obd_device,
57 rc = kstrtoul(buffer, 10, &val);
65 if (dev->u.cli.cl_import->imp_deactive == val) {
66 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
70 CDEBUG(D_CONFIG, "activate %lu: ignoring repeat request\n", val);
74 LUSTRE_RW_ATTR(active);
76 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
77 struct attribute *attr,
81 struct obd_device *dev = container_of(kobj, struct obd_device,
85 max = obd_get_max_rpcs_in_flight(&dev->u.cli);
86 len = sprintf(buf, "%u\n", max);
91 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
92 struct attribute *attr,
96 struct obd_device *dev = container_of(kobj, struct obd_device,
101 rc = kstrtoul(buffer, 10, &val);
105 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
111 LUSTRE_RW_ATTR(max_rpcs_in_flight);
113 static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
114 struct attribute *attr,
117 struct obd_device *dev = container_of(kobj, struct obd_device,
122 max = dev->u.cli.cl_max_mod_rpcs_in_flight;
123 len = sprintf(buf, "%hu\n", max);
128 static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
129 struct attribute *attr,
133 struct obd_device *dev = container_of(kobj, struct obd_device,
138 rc = kstrtou16(buffer, 10, &val);
142 rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
148 LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
150 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
152 struct obd_device *dev = seq->private;
154 return obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
157 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
158 const char __user *buf,
159 size_t len, loff_t *off)
161 struct seq_file *seq = file->private_data;
162 struct obd_device *dev = seq->private;
163 struct client_obd *cli = &dev->u.cli;
165 lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
169 LPROC_SEQ_FOPS(mdc_rpc_stats);
171 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
173 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
174 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
175 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
176 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
177 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
180 * Note: below sysfs entry is provided, but not currently in use, instead
181 * sbi->sb_md_brw_size is used, the per obd variable should be used
182 * when DNE is enabled, and dir pages are managed in MDC layer.
183 * Don't forget to enable sysfs store function then.
185 static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
186 struct attribute *attr,
189 struct obd_device *dev = container_of(kobj, struct obd_device,
191 struct client_obd *cli = &dev->u.cli;
193 return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
195 LUSTRE_RO_ATTR(max_pages_per_rpc);
197 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
198 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
200 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
201 { "ping", &mdc_ping_fops, NULL, 0222 },
202 { "connect_flags", &mdc_connect_flags_fops, NULL, 0 },
203 /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
204 { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 },
205 { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 },
206 { "timeouts", &mdc_timeouts_fops, NULL, 0 },
207 { "import", &mdc_import_fops, NULL, 0 },
208 { "state", &mdc_state_fops, NULL, 0 },
209 { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 },
210 { .name = "rpc_stats",
211 .fops = &mdc_rpc_stats_fops },
215 static struct attribute *mdc_attrs[] = {
216 &lustre_attr_active.attr,
217 &lustre_attr_max_rpcs_in_flight.attr,
218 &lustre_attr_max_mod_rpcs_in_flight.attr,
219 &lustre_attr_max_pages_per_rpc.attr,
223 static const struct attribute_group mdc_attr_group = {
227 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
229 lvars->sysfs_vars = &mdc_attr_group;
230 lvars->obd_vars = lprocfs_mdc_obd_vars;