GNU Linux-libre 4.9-gnu1
[releases.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         __u32 max;
47
48         max = obd_get_max_rpcs_in_flight(&dev->u.cli);
49         len = sprintf(buf, "%u\n", max);
50
51         return len;
52 }
53
54 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
55                                         struct attribute *attr,
56                                         const char *buffer,
57                                         size_t count)
58 {
59         struct obd_device *dev = container_of(kobj, struct obd_device,
60                                               obd_kobj);
61         int rc;
62         unsigned long val;
63
64         rc = kstrtoul(buffer, 10, &val);
65         if (rc)
66                 return rc;
67
68         rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
69         if (rc)
70                 count = rc;
71
72         return count;
73 }
74 LUSTRE_RW_ATTR(max_rpcs_in_flight);
75
76 LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
77
78 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
79 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
80 LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
81 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
82 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
83
84 /*
85  * Note: below sysfs entry is provided, but not currently in use, instead
86  * sbi->sb_md_brw_size is used, the per obd variable should be used
87  * when DNE is enabled, and dir pages are managed in MDC layer.
88  * Don't forget to enable sysfs store function then.
89  */
90 static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
91                                       struct attribute *attr,
92                                       char *buf)
93 {
94         struct obd_device *dev = container_of(kobj, struct obd_device,
95                                               obd_kobj);
96         struct client_obd *cli = &dev->u.cli;
97
98         return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
99 }
100 LUSTRE_RO_ATTR(max_pages_per_rpc);
101
102 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
103 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
104
105 static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
106         { "ping",               &mdc_ping_fops,                 NULL, 0222 },
107         { "connect_flags",      &mdc_connect_flags_fops,        NULL, 0 },
108         /*{ "filegroups",       lprocfs_rd_filegroups,          NULL, 0 },*/
109         { "mds_server_uuid",    &mdc_server_uuid_fops,          NULL, 0 },
110         { "mds_conn_uuid",      &mdc_conn_uuid_fops,            NULL, 0 },
111         { "timeouts",           &mdc_timeouts_fops,             NULL, 0 },
112         { "import",             &mdc_import_fops,               NULL, 0 },
113         { "state",              &mdc_state_fops,                NULL, 0 },
114         { "pinger_recov",       &mdc_pinger_recov_fops,         NULL, 0 },
115         { NULL }
116 };
117
118 static struct attribute *mdc_attrs[] = {
119         &lustre_attr_max_rpcs_in_flight.attr,
120         &lustre_attr_max_pages_per_rpc.attr,
121         NULL,
122 };
123
124 static struct attribute_group mdc_attr_group = {
125         .attrs = mdc_attrs,
126 };
127
128 void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
129 {
130         lvars->sysfs_vars   = &mdc_attr_group;
131         lvars->obd_vars     = lprocfs_mdc_obd_vars;
132 }