blob: 5c7a15dd7bd2d1ef08fc930c411d3e358158fe07 [file] [log] [blame]
Peng Taod7e09d02013-05-02 16:46:55 +08001/*
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 *
Andreas Dilger1dc563a2015-11-08 18:09:37 -050030 * Copyright (c) 2011, 2015, Intel Corporation.
Peng Taod7e09d02013-05-02 16:46:55 +080031 */
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
Peng Taod7e09d02013-05-02 16:46:55 +080038#include <linux/vfs.h>
Greg Kroah-Hartman05932302014-07-11 22:04:56 -070039#include "../include/obd_class.h"
40#include "../include/lprocfs_status.h"
Darshana Padmadas171aee12015-03-28 23:13:55 +053041#include "mdc_internal.h"
Peng Taod7e09d02013-05-02 16:46:55 +080042
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040043static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
44 struct attribute *attr,
45 char *buf)
Peng Taod7e09d02013-05-02 16:46:55 +080046{
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040047 int len;
48 struct obd_device *dev = container_of(kobj, struct obd_device,
49 obd_kobj);
Peng Taod7e09d02013-05-02 16:46:55 +080050 struct client_obd *cli = &dev->u.cli;
Peng Taod7e09d02013-05-02 16:46:55 +080051
John L. Hammond7d53d8f2016-03-30 19:48:36 -040052 spin_lock(&cli->cl_loi_list_lock);
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040053 len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
John L. Hammond7d53d8f2016-03-30 19:48:36 -040054 spin_unlock(&cli->cl_loi_list_lock);
Joe Perches91b3a682015-03-01 19:58:57 -080055
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040056 return len;
Peng Taod7e09d02013-05-02 16:46:55 +080057}
58
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040059static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
60 struct attribute *attr,
61 const char *buffer,
62 size_t count)
Peng Taod7e09d02013-05-02 16:46:55 +080063{
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040064 struct obd_device *dev = container_of(kobj, struct obd_device,
65 obd_kobj);
Peng Taod7e09d02013-05-02 16:46:55 +080066 struct client_obd *cli = &dev->u.cli;
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040067 int rc;
68 unsigned long val;
Peng Taod7e09d02013-05-02 16:46:55 +080069
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040070 rc = kstrtoul(buffer, 10, &val);
Peng Taod7e09d02013-05-02 16:46:55 +080071 if (rc)
72 return rc;
73
74 if (val < 1 || val > MDC_MAX_RIF_MAX)
75 return -ERANGE;
76
John L. Hammond7d53d8f2016-03-30 19:48:36 -040077 spin_lock(&cli->cl_loi_list_lock);
Peng Taod7e09d02013-05-02 16:46:55 +080078 cli->cl_max_rpcs_in_flight = val;
John L. Hammond7d53d8f2016-03-30 19:48:36 -040079 spin_unlock(&cli->cl_loi_list_lock);
Peng Taod7e09d02013-05-02 16:46:55 +080080
81 return count;
82}
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040083LUSTRE_RW_ATTR(max_rpcs_in_flight);
Peng Taod7e09d02013-05-02 16:46:55 +080084
Peng Tao73bb1da2013-05-29 21:40:55 +080085LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
86
Peng Tao73bb1da2013-05-29 21:40:55 +080087LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
Peng Tao73bb1da2013-05-29 21:40:55 +080088LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
89LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
90LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
91LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
92
Oleg Drokin2ee26222d2015-05-21 15:32:20 -040093/*
94 * Note: below sysfs entry is provided, but not currently in use, instead
95 * sbi->sb_md_brw_size is used, the per obd variable should be used
96 * when DNE is enabled, and dir pages are managed in MDC layer.
97 * Don't forget to enable sysfs store function then.
98 */
99static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
100 struct attribute *attr,
101 char *buf)
Peng Tao73bb1da2013-05-29 21:40:55 +0800102{
Oleg Drokin2ee26222d2015-05-21 15:32:20 -0400103 struct obd_device *dev = container_of(kobj, struct obd_device,
104 obd_kobj);
105 struct client_obd *cli = &dev->u.cli;
106
107 return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
Peng Tao73bb1da2013-05-29 21:40:55 +0800108}
Oleg Drokin2ee26222d2015-05-21 15:32:20 -0400109LUSTRE_RO_ATTR(max_pages_per_rpc);
Peng Tao73bb1da2013-05-29 21:40:55 +0800110
111LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
112LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
Peng Taod7e09d02013-05-02 16:46:55 +0800113
114static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
Radek Dostalea7893b2014-07-27 23:22:57 +0200115 { "ping", &mdc_ping_fops, NULL, 0222 },
116 { "connect_flags", &mdc_connect_flags_fops, NULL, 0 },
Radek Dostalea7893b2014-07-27 23:22:57 +0200117 /*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
118 { "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 },
119 { "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 },
Radek Dostalea7893b2014-07-27 23:22:57 +0200120 { "timeouts", &mdc_timeouts_fops, NULL, 0 },
121 { "import", &mdc_import_fops, NULL, 0 },
122 { "state", &mdc_state_fops, NULL, 0 },
Radek Dostalea7893b2014-07-27 23:22:57 +0200123 { "pinger_recov", &mdc_pinger_recov_fops, NULL, 0 },
124 { NULL }
Peng Taod7e09d02013-05-02 16:46:55 +0800125};
126
Oleg Drokin2ee26222d2015-05-21 15:32:20 -0400127static struct attribute *mdc_attrs[] = {
128 &lustre_attr_max_rpcs_in_flight.attr,
129 &lustre_attr_max_pages_per_rpc.attr,
130 NULL,
131};
132
133static struct attribute_group mdc_attr_group = {
134 .attrs = mdc_attrs,
135};
136
Peng Taod7e09d02013-05-02 16:46:55 +0800137void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
138{
Oleg Drokin2ee26222d2015-05-21 15:32:20 -0400139 lvars->sysfs_vars = &mdc_attr_group;
Srikrishan Malik444014d2014-08-11 23:57:28 +0530140 lvars->obd_vars = lprocfs_mdc_obd_vars;
Peng Taod7e09d02013-05-02 16:46:55 +0800141}