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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2015, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 #define DEBUG_SUBSYSTEM S_CLASS
34 #include <linux/vfs.h>
35 #include <obd_class.h>
36 #include <lprocfs_status.h>
37 #include "mdc_internal.h"
39 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
42 struct obd_device *dev = container_of(kobj, struct obd_device,
45 return sprintf(buf, "%u\n", !dev->u.cli.cl_import->imp_deactive);
48 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
49 const char *buffer, size_t count)
51 struct obd_device *dev = container_of(kobj, struct obd_device,
56 rc = kstrtoul(buffer, 10, &val);
64 if (dev->u.cli.cl_import->imp_deactive == val) {
65 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
69 CDEBUG(D_CONFIG, "activate %lu: ignoring repeat request\n", val);
73 LUSTRE_RW_ATTR(active);
75 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
76 struct attribute *attr,
80 struct obd_device *dev = container_of(kobj, struct obd_device,
84 max = obd_get_max_rpcs_in_flight(&dev->u.cli);
85 len = sprintf(buf, "%u\n", max);
90 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
91 struct attribute *attr,
95 struct obd_device *dev = container_of(kobj, struct obd_device,
100 rc = kstrtoul(buffer, 10, &val);
104 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
110 LUSTRE_RW_ATTR(max_rpcs_in_flight);
112 static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
113 struct attribute *attr,
116 struct obd_device *dev = container_of(kobj, struct obd_device,
121 max = dev->u.cli.cl_max_mod_rpcs_in_flight;
122 len = sprintf(buf, "%hu\n", max);
127 static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
128 struct attribute *attr,
132 struct obd_device *dev = container_of(kobj, struct obd_device,
137 rc = kstrtou16(buffer, 10, &val);
141 rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
147 LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
149 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
151 struct obd_device *dev = seq->private;
153 return obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
156 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
157 const char __user *buf,
158 size_t len, loff_t *off)
160 struct seq_file *seq = file->private_data;
161 struct obd_device *dev = seq->private;
162 struct client_obd *cli = &dev->u.cli;
164 lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
168 LPROC_SEQ_FOPS(mdc_rpc_stats);
170 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
172 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
173 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
174 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
175 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
176 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
179 * Note: below sysfs entry is provided, but not currently in use, instead
180 * sbi->sb_md_brw_size is used, the per obd variable should be used
181 * when DNE is enabled, and dir pages are managed in MDC layer.
182 * Don't forget to enable sysfs store function then.
184 static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
185 struct attribute *attr,
188 struct obd_device *dev = container_of(kobj, struct obd_device,
190 struct client_obd *cli = &dev->u.cli;
192 return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
194 LUSTRE_RO_ATTR(max_pages_per_rpc);
196 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
197 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
199 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
200 { "ping", &mdc_ping_fops, NULL, 0222 },
201 { "connect_flags", &mdc_connect_flags_fops, NULL, 0 },
202 /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
203 { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 },
204 { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 },
205 { "timeouts", &mdc_timeouts_fops, NULL, 0 },
206 { "import", &mdc_import_fops, NULL, 0 },
207 { "state", &mdc_state_fops, NULL, 0 },
208 { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 },
209 { .name = "rpc_stats",
210 .fops = &mdc_rpc_stats_fops },
214 static struct attribute *mdc_attrs[] = {
215 &lustre_attr_active.attr,
216 &lustre_attr_max_rpcs_in_flight.attr,
217 &lustre_attr_max_mod_rpcs_in_flight.attr,
218 &lustre_attr_max_pages_per_rpc.attr,
222 static const struct attribute_group mdc_attr_group = {
226 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
228 lvars->sysfs_vars = &mdc_attr_group;
229 lvars->obd_vars = lprocfs_mdc_obd_vars;