Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / staging / lustre / 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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2015, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  */
32 #define DEBUG_SUBSYSTEM S_CLASS
33
34 #include <linux/vfs.h>
35 #include "../include/obd_class.h"
36 #include "../include/lprocfs_status.h"
37 #include "mdc_internal.h"
38
39 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
40                                        struct attribute *attr,
41                                        char *buf)
42 {
43         int len;
44         struct obd_device *dev = container_of(kobj, struct obd_device,
45                                               obd_kobj);
46         struct client_obd *cli = &dev->u.cli;
47
48         spin_lock(&cli->cl_loi_list_lock);
49         len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
50         spin_unlock(&cli->cl_loi_list_lock);
51
52         return len;
53 }
54
55 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
56                                         struct attribute *attr,
57                                         const char *buffer,
58                                         size_t count)
59 {
60         struct obd_device *dev = container_of(kobj, struct obd_device,
61                                               obd_kobj);
62         struct client_obd *cli = &dev->u.cli;
63         int rc;
64         unsigned long val;
65
66         rc = kstrtoul(buffer, 10, &val);
67         if (rc)
68                 return rc;
69
70         if (val < 1 || val > MDC_MAX_RIF_MAX)
71                 return -ERANGE;
72
73         spin_lock(&cli->cl_loi_list_lock);
74         cli->cl_max_rpcs_in_flight = val;
75         spin_unlock(&cli->cl_loi_list_lock);
76
77         return count;
78 }
79 LUSTRE_RW_ATTR(max_rpcs_in_flight);
80
81 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
82
83 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
84 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
85 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
86 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
87 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
88
89 /*
90  * Note: below sysfs entry is provided, but not currently in use, instead
91  * sbi->sb_md_brw_size is used, the per obd variable should be used
92  * when DNE is enabled, and dir pages are managed in MDC layer.
93  * Don't forget to enable sysfs store function then.
94  */
95 static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
96                                       struct attribute *attr,
97                                       char *buf)
98 {
99         struct obd_device *dev = container_of(kobj, struct obd_device,
100                                               obd_kobj);
101         struct client_obd *cli = &dev->u.cli;
102
103         return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
104 }
105 LUSTRE_RO_ATTR(max_pages_per_rpc);
106
107 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
108 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
109
110 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
111         { "ping",               &mdc_ping_fops,                 NULL, 0222 },
112         { "connect_flags",      &mdc_connect_flags_fops,        NULL, 0 },
113         /*{ "filegroups",       lprocfs_rd_filegroups,          NULL, 0 },*/
114         { "mds_server_uuid",    &mdc_server_uuid_fops,          NULL, 0 },
115         { "mds_conn_uuid",      &mdc_conn_uuid_fops,            NULL, 0 },
116         { "timeouts",           &mdc_timeouts_fops,             NULL, 0 },
117         { "import",             &mdc_import_fops,               NULL, 0 },
118         { "state",              &mdc_state_fops,                NULL, 0 },
119         { "pinger_recov",       &mdc_pinger_recov_fops,         NULL, 0 },
120         { NULL }
121 };
122
123 static struct attribute *mdc_attrs[] = {
124         &lustre_attr_max_rpcs_in_flight.attr,
125         &lustre_attr_max_pages_per_rpc.attr,
126         NULL,
127 };
128
129 static struct attribute_group mdc_attr_group = {
130         .attrs = mdc_attrs,
131 };
132
133 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
134 {
135         lvars->sysfs_vars   = &mdc_attr_group;
136         lvars->obd_vars     = lprocfs_mdc_obd_vars;
137 }