blob: 9bad57d65db45ae85be21b671d21820c2b63b488 [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
Oleg Drokin6a5b99a2016-06-14 23:33:40 -040018 * http://www.gnu.org/licenses/gpl-2.0.html
Peng Taod7e09d02013-05-02 16:46:55 +080019 *
Peng Taod7e09d02013-05-02 16:46:55 +080020 * 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 *
Andreas Dilger1dc563a2015-11-08 18:09:37 -050026 * Copyright (c) 2011, 2015, Intel Corporation.
Peng Taod7e09d02013-05-02 16:46:55 +080027 */
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
Greg Kroah-Hartmane27db142014-07-11 22:29:36 -070034#include "../include/obd_support.h"
35#include "../include/obd.h"
36#include "../include/lprocfs_status.h"
37#include "../include/lustre/lustre_idl.h"
38#include "../include/lustre_net.h"
39#include "../include/obd_class.h"
Peng Taod7e09d02013-05-02 16:46:55 +080040#include "ptlrpc_internal.h"
41
Jon Bernardb3c986d2015-01-20 14:55:28 -050042static struct ll_rpc_opcode {
Kristina Martsenko2a763282013-11-11 21:35:01 +020043 __u32 opcode;
44 const char *opname;
Peng Taod7e09d02013-05-02 16:46:55 +080045} ll_rpc_opcode_table[LUSTRE_MAX_OPCODES] = {
46 { OST_REPLY, "ost_reply" },
47 { OST_GETATTR, "ost_getattr" },
48 { OST_SETATTR, "ost_setattr" },
49 { OST_READ, "ost_read" },
50 { OST_WRITE, "ost_write" },
Mike Rapoportb2952d62015-09-03 11:49:13 +030051 { OST_CREATE, "ost_create" },
Peng Taod7e09d02013-05-02 16:46:55 +080052 { OST_DESTROY, "ost_destroy" },
53 { OST_GET_INFO, "ost_get_info" },
54 { OST_CONNECT, "ost_connect" },
55 { OST_DISCONNECT, "ost_disconnect" },
56 { OST_PUNCH, "ost_punch" },
57 { OST_OPEN, "ost_open" },
58 { OST_CLOSE, "ost_close" },
59 { OST_STATFS, "ost_statfs" },
60 { 14, NULL }, /* formerly OST_SAN_READ */
61 { 15, NULL }, /* formerly OST_SAN_WRITE */
62 { OST_SYNC, "ost_sync" },
63 { OST_SET_INFO, "ost_set_info" },
64 { OST_QUOTACHECK, "ost_quotacheck" },
65 { OST_QUOTACTL, "ost_quotactl" },
66 { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" },
67 { MDS_GETATTR, "mds_getattr" },
68 { MDS_GETATTR_NAME, "mds_getattr_lock" },
69 { MDS_CLOSE, "mds_close" },
70 { MDS_REINT, "mds_reint" },
71 { MDS_READPAGE, "mds_readpage" },
72 { MDS_CONNECT, "mds_connect" },
73 { MDS_DISCONNECT, "mds_disconnect" },
74 { MDS_GETSTATUS, "mds_getstatus" },
75 { MDS_STATFS, "mds_statfs" },
76 { MDS_PIN, "mds_pin" },
77 { MDS_UNPIN, "mds_unpin" },
78 { MDS_SYNC, "mds_sync" },
79 { MDS_DONE_WRITING, "mds_done_writing" },
80 { MDS_SET_INFO, "mds_set_info" },
81 { MDS_QUOTACHECK, "mds_quotacheck" },
82 { MDS_QUOTACTL, "mds_quotactl" },
83 { MDS_GETXATTR, "mds_getxattr" },
84 { MDS_SETXATTR, "mds_setxattr" },
85 { MDS_WRITEPAGE, "mds_writepage" },
86 { MDS_IS_SUBDIR, "mds_is_subdir" },
87 { MDS_GET_INFO, "mds_get_info" },
88 { MDS_HSM_STATE_GET, "mds_hsm_state_get" },
89 { MDS_HSM_STATE_SET, "mds_hsm_state_set" },
90 { MDS_HSM_ACTION, "mds_hsm_action" },
91 { MDS_HSM_PROGRESS, "mds_hsm_progress" },
92 { MDS_HSM_REQUEST, "mds_hsm_request" },
93 { MDS_HSM_CT_REGISTER, "mds_hsm_ct_register" },
94 { MDS_HSM_CT_UNREGISTER, "mds_hsm_ct_unregister" },
95 { MDS_SWAP_LAYOUTS, "mds_swap_layouts" },
96 { LDLM_ENQUEUE, "ldlm_enqueue" },
97 { LDLM_CONVERT, "ldlm_convert" },
98 { LDLM_CANCEL, "ldlm_cancel" },
99 { LDLM_BL_CALLBACK, "ldlm_bl_callback" },
100 { LDLM_CP_CALLBACK, "ldlm_cp_callback" },
101 { LDLM_GL_CALLBACK, "ldlm_gl_callback" },
102 { LDLM_SET_INFO, "ldlm_set_info" },
103 { MGS_CONNECT, "mgs_connect" },
104 { MGS_DISCONNECT, "mgs_disconnect" },
105 { MGS_EXCEPTION, "mgs_exception" },
106 { MGS_TARGET_REG, "mgs_target_reg" },
107 { MGS_TARGET_DEL, "mgs_target_del" },
108 { MGS_SET_INFO, "mgs_set_info" },
109 { MGS_CONFIG_READ, "mgs_config_read" },
110 { OBD_PING, "obd_ping" },
Mikhail Pershin65f1c782013-11-26 10:04:55 +0800111 { OBD_LOG_CANCEL, "llog_cancel" },
Peng Taod7e09d02013-05-02 16:46:55 +0800112 { OBD_QC_CALLBACK, "obd_quota_callback" },
113 { OBD_IDX_READ, "dt_index_read" },
Mikhail Pershin65f1c782013-11-26 10:04:55 +0800114 { LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_open" },
Peng Taod7e09d02013-05-02 16:46:55 +0800115 { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" },
Greg Donald1d8cb702014-08-25 20:07:19 -0500116 { LLOG_ORIGIN_HANDLE_READ_HEADER, "llog_origin_handle_read_header" },
Peng Taod7e09d02013-05-02 16:46:55 +0800117 { LLOG_ORIGIN_HANDLE_WRITE_REC, "llog_origin_handle_write_rec" },
118 { LLOG_ORIGIN_HANDLE_CLOSE, "llog_origin_handle_close" },
119 { LLOG_ORIGIN_CONNECT, "llog_origin_connect" },
120 { LLOG_CATINFO, "llog_catinfo" },
121 { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" },
122 { LLOG_ORIGIN_HANDLE_DESTROY, "llog_origin_handle_destroy" },
123 { QUOTA_DQACQ, "quota_acquire" },
124 { QUOTA_DQREL, "quota_release" },
125 { SEQ_QUERY, "seq_query" },
126 { SEC_CTX_INIT, "sec_ctx_init" },
Greg Donald1d8cb702014-08-25 20:07:19 -0500127 { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" },
Peng Taod7e09d02013-05-02 16:46:55 +0800128 { SEC_CTX_FINI, "sec_ctx_fini" },
129 { FLD_QUERY, "fld_query" },
wang dib78c2b9b2016-04-28 12:07:34 -0400130 { FLD_READ, "fld_read" },
Peng Taod7e09d02013-05-02 16:46:55 +0800131};
132
Jon Bernardb3c986d2015-01-20 14:55:28 -0500133static struct ll_eopcode {
Kristina Martsenko2a763282013-11-11 21:35:01 +0200134 __u32 opcode;
135 const char *opname;
Peng Taod7e09d02013-05-02 16:46:55 +0800136} ll_eopcode_table[EXTRA_LAST_OPC] = {
137 { LDLM_GLIMPSE_ENQUEUE, "ldlm_glimpse_enqueue" },
138 { LDLM_PLAIN_ENQUEUE, "ldlm_plain_enqueue" },
139 { LDLM_EXTENT_ENQUEUE, "ldlm_extent_enqueue" },
140 { LDLM_FLOCK_ENQUEUE, "ldlm_flock_enqueue" },
141 { LDLM_IBITS_ENQUEUE, "ldlm_ibits_enqueue" },
142 { MDS_REINT_SETATTR, "mds_reint_setattr" },
143 { MDS_REINT_CREATE, "mds_reint_create" },
144 { MDS_REINT_LINK, "mds_reint_link" },
145 { MDS_REINT_UNLINK, "mds_reint_unlink" },
146 { MDS_REINT_RENAME, "mds_reint_rename" },
147 { MDS_REINT_OPEN, "mds_reint_open" },
148 { MDS_REINT_SETXATTR, "mds_reint_setxattr" },
149 { BRW_READ_BYTES, "read_bytes" },
150 { BRW_WRITE_BYTES, "write_bytes" },
151};
152
153const char *ll_opcode2str(__u32 opcode)
154{
155 /* When one of the assertions below fail, chances are that:
156 * 1) A new opcode was added in include/lustre/lustre_idl.h,
157 * but is missing from the table above.
158 * or 2) The opcode space was renumbered or rearranged,
159 * and the opcode_offset() function in
160 * ptlrpc_internal.h needs to be modified.
161 */
162 __u32 offset = opcode_offset(opcode);
Mike Rapoport50ffcb72015-10-13 16:03:40 +0300163
Peng Taod7e09d02013-05-02 16:46:55 +0800164 LASSERTF(offset < LUSTRE_MAX_OPCODES,
165 "offset %u >= LUSTRE_MAX_OPCODES %u\n",
166 offset, LUSTRE_MAX_OPCODES);
167 LASSERTF(ll_rpc_opcode_table[offset].opcode == opcode,
168 "ll_rpc_opcode_table[%u].opcode %u != opcode %u\n",
169 offset, ll_rpc_opcode_table[offset].opcode, opcode);
170 return ll_rpc_opcode_table[offset].opname;
171}
172
Jon Bernardb3c986d2015-01-20 14:55:28 -0500173static const char *ll_eopcode2str(__u32 opcode)
Peng Taod7e09d02013-05-02 16:46:55 +0800174{
175 LASSERT(ll_eopcode_table[opcode].opcode == opcode);
176 return ll_eopcode_table[opcode].opname;
177}
Jon Bernardb3c986d2015-01-20 14:55:28 -0500178
Dmitry Eremin700815d2015-05-21 15:32:11 -0400179static void
180ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
181 char *name,
182 struct dentry **debugfs_root_ret,
183 struct lprocfs_stats **stats_ret)
Peng Taod7e09d02013-05-02 16:46:55 +0800184{
Dmitry Eremin700815d2015-05-21 15:32:11 -0400185 struct dentry *svc_debugfs_entry;
Peng Taod7e09d02013-05-02 16:46:55 +0800186 struct lprocfs_stats *svc_stats;
187 int i, rc;
188 unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
189 LPROCFS_CNTR_STDDEV;
190
Oleg Drokin8b382082016-02-16 00:46:58 -0500191 LASSERT(!*debugfs_root_ret);
192 LASSERT(!*stats_ret);
Peng Taod7e09d02013-05-02 16:46:55 +0800193
Oleg Drokincd94f232016-08-21 18:04:34 -0400194 svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES + LUSTRE_MAX_OPCODES,
Greg Donald1d8cb702014-08-25 20:07:19 -0500195 0);
Oleg Drokin8b382082016-02-16 00:46:58 -0500196 if (!svc_stats)
Peng Taod7e09d02013-05-02 16:46:55 +0800197 return;
198
Oleg Drokin8b382082016-02-16 00:46:58 -0500199 if (dir) {
Dmitry Eremin700815d2015-05-21 15:32:11 -0400200 svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL);
201 if (IS_ERR(svc_debugfs_entry)) {
Peng Taod7e09d02013-05-02 16:46:55 +0800202 lprocfs_free_stats(&svc_stats);
203 return;
204 }
205 } else {
Dmitry Eremin700815d2015-05-21 15:32:11 -0400206 svc_debugfs_entry = root;
Peng Taod7e09d02013-05-02 16:46:55 +0800207 }
208
209 lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR,
210 svc_counter_config, "req_waittime", "usec");
211 lprocfs_counter_init(svc_stats, PTLRPC_REQQDEPTH_CNTR,
212 svc_counter_config, "req_qdepth", "reqs");
213 lprocfs_counter_init(svc_stats, PTLRPC_REQACTIVE_CNTR,
214 svc_counter_config, "req_active", "reqs");
215 lprocfs_counter_init(svc_stats, PTLRPC_TIMEOUT,
216 svc_counter_config, "req_timeout", "sec");
217 lprocfs_counter_init(svc_stats, PTLRPC_REQBUF_AVAIL_CNTR,
218 svc_counter_config, "reqbuf_avail", "bufs");
219 for (i = 0; i < EXTRA_LAST_OPC; i++) {
220 char *units;
221
Kristina Martsenko3949015e2013-11-11 21:34:58 +0200222 switch (i) {
Peng Taod7e09d02013-05-02 16:46:55 +0800223 case BRW_WRITE_BYTES:
224 case BRW_READ_BYTES:
225 units = "bytes";
226 break;
227 default:
228 units = "reqs";
229 break;
230 }
231 lprocfs_counter_init(svc_stats, PTLRPC_LAST_CNTR + i,
232 svc_counter_config,
233 ll_eopcode2str(i), units);
234 }
235 for (i = 0; i < LUSTRE_MAX_OPCODES; i++) {
236 __u32 opcode = ll_rpc_opcode_table[i].opcode;
Mike Rapoport50ffcb72015-10-13 16:03:40 +0300237
Peng Taod7e09d02013-05-02 16:46:55 +0800238 lprocfs_counter_init(svc_stats,
239 EXTRA_MAX_OPCODES + i, svc_counter_config,
240 ll_opcode2str(opcode), "usec");
241 }
242
Dmitry Eremin700815d2015-05-21 15:32:11 -0400243 rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats);
Peng Taod7e09d02013-05-02 16:46:55 +0800244 if (rc < 0) {
Oleg Drokin8b382082016-02-16 00:46:58 -0500245 if (dir)
Dmitry Eremin700815d2015-05-21 15:32:11 -0400246 ldebugfs_remove(&svc_debugfs_entry);
Peng Taod7e09d02013-05-02 16:46:55 +0800247 lprocfs_free_stats(&svc_stats);
248 } else {
Oleg Drokin8b382082016-02-16 00:46:58 -0500249 if (dir)
Dmitry Eremin700815d2015-05-21 15:32:11 -0400250 *debugfs_root_ret = svc_debugfs_entry;
Peng Taod7e09d02013-05-02 16:46:55 +0800251 *stats_ret = svc_stats;
252 }
253}
254
255static int
Peng Tao73bb1da2013-05-29 21:40:55 +0800256ptlrpc_lprocfs_req_history_len_seq_show(struct seq_file *m, void *v)
Peng Taod7e09d02013-05-02 16:46:55 +0800257{
Peng Tao73bb1da2013-05-29 21:40:55 +0800258 struct ptlrpc_service *svc = m->private;
Peng Taod7e09d02013-05-02 16:46:55 +0800259 struct ptlrpc_service_part *svcpt;
Chris Hannad0bfef32015-06-03 10:28:26 -0400260 int total = 0;
261 int i;
Peng Taod7e09d02013-05-02 16:46:55 +0800262
Peng Taod7e09d02013-05-02 16:46:55 +0800263 ptlrpc_service_for_each_part(svcpt, i, svc)
264 total += svcpt->scp_hist_nrqbds;
265
Joe Perches8faeebd2015-02-21 18:53:28 -0800266 seq_printf(m, "%d\n", total);
267 return 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800268}
Mike Rapoportc9f6bb92015-10-13 16:03:42 +0300269
Peng Tao73bb1da2013-05-29 21:40:55 +0800270LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_req_history_len);
Peng Taod7e09d02013-05-02 16:46:55 +0800271
272static int
Peng Tao73bb1da2013-05-29 21:40:55 +0800273ptlrpc_lprocfs_req_history_max_seq_show(struct seq_file *m, void *n)
Peng Taod7e09d02013-05-02 16:46:55 +0800274{
Peng Tao73bb1da2013-05-29 21:40:55 +0800275 struct ptlrpc_service *svc = m->private;
Peng Taod7e09d02013-05-02 16:46:55 +0800276 struct ptlrpc_service_part *svcpt;
Chris Hannad0bfef32015-06-03 10:28:26 -0400277 int total = 0;
278 int i;
Peng Taod7e09d02013-05-02 16:46:55 +0800279
Peng Taod7e09d02013-05-02 16:46:55 +0800280 ptlrpc_service_for_each_part(svcpt, i, svc)
281 total += svc->srv_hist_nrqbds_cpt_max;
282
Joe Perches8faeebd2015-02-21 18:53:28 -0800283 seq_printf(m, "%d\n", total);
284 return 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800285}
286
Peng Tao73bb1da2013-05-29 21:40:55 +0800287static ssize_t
Tristan Lelonge84962e2014-12-05 22:43:20 -0800288ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
Chris Hannad0bfef32015-06-03 10:28:26 -0400289 const char __user *buffer,
290 size_t count, loff_t *off)
Peng Taod7e09d02013-05-02 16:46:55 +0800291{
Peng Tao73bb1da2013-05-29 21:40:55 +0800292 struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
Chris Hannad0bfef32015-06-03 10:28:26 -0400293 int bufpages;
294 int val;
295 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800296
297 rc = lprocfs_write_helper(buffer, count, &val);
298 if (rc < 0)
299 return rc;
300
301 if (val < 0)
302 return -ERANGE;
303
304 /* This sanity check is more of an insanity check; we can still
305 * hose a kernel by allowing the request history to grow too
Oleg Drokindadfcda2016-02-24 22:00:38 -0500306 * far.
307 */
Kirill A. Shutemov09cbfea2016-04-01 15:29:47 +0300308 bufpages = (svc->srv_buf_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
Peng Tao4f6cc9a2013-07-15 22:27:04 +0800309 if (val > totalram_pages / (2 * bufpages))
Peng Taod7e09d02013-05-02 16:46:55 +0800310 return -ERANGE;
311
312 spin_lock(&svc->srv_lock);
313
314 if (val == 0)
315 svc->srv_hist_nrqbds_cpt_max = 0;
316 else
317 svc->srv_hist_nrqbds_cpt_max = max(1, (val / svc->srv_ncpts));
318
319 spin_unlock(&svc->srv_lock);
320
321 return count;
322}
Mike Rapoportc9f6bb92015-10-13 16:03:42 +0300323
Peng Tao73bb1da2013-05-29 21:40:55 +0800324LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
Peng Taod7e09d02013-05-02 16:46:55 +0800325
Oleg Drokin673a6792015-05-21 15:32:09 -0400326static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr,
327 char *buf)
328{
329 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
330 srv_kobj);
331
332 return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
Peng Taod7e09d02013-05-02 16:46:55 +0800333}
334
Oleg Drokin673a6792015-05-21 15:32:09 -0400335static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr,
336 const char *buffer, size_t count)
Peng Taod7e09d02013-05-02 16:46:55 +0800337{
Oleg Drokin673a6792015-05-21 15:32:09 -0400338 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
339 srv_kobj);
340 unsigned long val;
341 int rc = kstrtoul(buffer, 10, &val);
Peng Taod7e09d02013-05-02 16:46:55 +0800342
343 if (rc < 0)
344 return rc;
345
346 if (val / svc->srv_ncpts < PTLRPC_NTHRS_INIT)
347 return -ERANGE;
348
349 spin_lock(&svc->srv_lock);
350 if (val > svc->srv_nthrs_cpt_limit * svc->srv_ncpts) {
351 spin_unlock(&svc->srv_lock);
352 return -ERANGE;
353 }
354
355 svc->srv_nthrs_cpt_init = val / svc->srv_ncpts;
356
357 spin_unlock(&svc->srv_lock);
358
359 return count;
360}
Oleg Drokin673a6792015-05-21 15:32:09 -0400361LUSTRE_RW_ATTR(threads_min);
Peng Taod7e09d02013-05-02 16:46:55 +0800362
Oleg Drokin673a6792015-05-21 15:32:09 -0400363static ssize_t threads_started_show(struct kobject *kobj,
364 struct attribute *attr,
365 char *buf)
Peng Taod7e09d02013-05-02 16:46:55 +0800366{
Oleg Drokin673a6792015-05-21 15:32:09 -0400367 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
368 srv_kobj);
Peng Taod7e09d02013-05-02 16:46:55 +0800369 struct ptlrpc_service_part *svcpt;
Oleg Drokin673a6792015-05-21 15:32:09 -0400370 int total = 0;
371 int i;
Peng Taod7e09d02013-05-02 16:46:55 +0800372
373 ptlrpc_service_for_each_part(svcpt, i, svc)
374 total += svcpt->scp_nthrs_running;
375
Oleg Drokin673a6792015-05-21 15:32:09 -0400376 return sprintf(buf, "%d\n", total);
Peng Taod7e09d02013-05-02 16:46:55 +0800377}
Oleg Drokin673a6792015-05-21 15:32:09 -0400378LUSTRE_RO_ATTR(threads_started);
Peng Taod7e09d02013-05-02 16:46:55 +0800379
Oleg Drokin673a6792015-05-21 15:32:09 -0400380static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr,
381 char *buf)
Peng Taod7e09d02013-05-02 16:46:55 +0800382{
Oleg Drokin673a6792015-05-21 15:32:09 -0400383 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
384 srv_kobj);
Peng Taod7e09d02013-05-02 16:46:55 +0800385
Oleg Drokin673a6792015-05-21 15:32:09 -0400386 return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
Peng Taod7e09d02013-05-02 16:46:55 +0800387}
388
Oleg Drokin673a6792015-05-21 15:32:09 -0400389static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr,
390 const char *buffer, size_t count)
Peng Taod7e09d02013-05-02 16:46:55 +0800391{
Oleg Drokin673a6792015-05-21 15:32:09 -0400392 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
393 srv_kobj);
394 unsigned long val;
395 int rc = kstrtoul(buffer, 10, &val);
Peng Taod7e09d02013-05-02 16:46:55 +0800396
397 if (rc < 0)
398 return rc;
399
400 if (val / svc->srv_ncpts < PTLRPC_NTHRS_INIT)
401 return -ERANGE;
402
403 spin_lock(&svc->srv_lock);
404 if (val < svc->srv_nthrs_cpt_init * svc->srv_ncpts) {
405 spin_unlock(&svc->srv_lock);
406 return -ERANGE;
407 }
408
409 svc->srv_nthrs_cpt_limit = val / svc->srv_ncpts;
410
411 spin_unlock(&svc->srv_lock);
412
413 return count;
414}
Oleg Drokin673a6792015-05-21 15:32:09 -0400415LUSTRE_RW_ATTR(threads_max);
Peng Taod7e09d02013-05-02 16:46:55 +0800416
417/**
418 * \addtogoup nrs
419 * @{
420 */
Peng Taod7e09d02013-05-02 16:46:55 +0800421
422/**
423 * Translates \e ptlrpc_nrs_pol_state values to human-readable strings.
424 *
425 * \param[in] state The policy state
426 */
427static const char *nrs_state2str(enum ptlrpc_nrs_pol_state state)
428{
429 switch (state) {
430 default:
431 LBUG();
432 case NRS_POL_STATE_INVALID:
433 return "invalid";
434 case NRS_POL_STATE_STOPPED:
435 return "stopped";
436 case NRS_POL_STATE_STOPPING:
437 return "stopping";
438 case NRS_POL_STATE_STARTING:
439 return "starting";
440 case NRS_POL_STATE_STARTED:
441 return "started";
442 }
443}
444
445/**
446 * Obtains status information for \a policy.
447 *
448 * Information is copied in \a info.
449 *
450 * \param[in] policy The policy
451 * \param[out] info Holds returned status information
452 */
Rocco Folino96135462015-10-02 23:54:26 +0200453static void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy,
Oleg Drokin30c0aa32016-02-26 01:50:02 -0500454 struct ptlrpc_nrs_pol_info *info)
Peng Taod7e09d02013-05-02 16:46:55 +0800455{
Li Xi5e42bc92014-04-27 13:07:06 -0400456 assert_spin_locked(&policy->pol_nrs->nrs_lock);
Peng Taod7e09d02013-05-02 16:46:55 +0800457
458 memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX);
459
460 info->pi_fallback = !!(policy->pol_flags & PTLRPC_NRS_FL_FALLBACK);
461 info->pi_state = policy->pol_state;
462 /**
463 * XXX: These are accessed without holding
464 * ptlrpc_service_part::scp_req_lock.
465 */
466 info->pi_req_queued = policy->pol_req_queued;
467 info->pi_req_started = policy->pol_req_started;
468}
469
470/**
471 * Reads and prints policy status information for all policies of a PTLRPC
472 * service.
473 */
Peng Tao73bb1da2013-05-29 21:40:55 +0800474static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
Peng Taod7e09d02013-05-02 16:46:55 +0800475{
Chris Hannad0bfef32015-06-03 10:28:26 -0400476 struct ptlrpc_service *svc = m->private;
477 struct ptlrpc_service_part *svcpt;
478 struct ptlrpc_nrs *nrs;
479 struct ptlrpc_nrs_policy *policy;
480 struct ptlrpc_nrs_pol_info *infos;
481 struct ptlrpc_nrs_pol_info tmp;
482 unsigned num_pols;
483 unsigned pol_idx = 0;
484 bool hp = false;
485 int i;
486 int rc = 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800487
488 /**
489 * Serialize NRS core lprocfs operations with policy registration/
490 * unregistration.
491 */
492 mutex_lock(&nrs_core.nrs_mutex);
493
494 /**
495 * Use the first service partition's regular NRS head in order to obtain
496 * the number of policies registered with NRS heads of this service. All
497 * service partitions will have the same number of policies.
498 */
499 nrs = nrs_svcpt2nrs(svc->srv_parts[0], false);
500
501 spin_lock(&nrs->nrs_lock);
502 num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols;
503 spin_unlock(&nrs->nrs_lock);
504
Julia Lawall9ae10592015-05-01 17:51:12 +0200505 infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
Oleg Drokin8b382082016-02-16 00:46:58 -0500506 if (!infos) {
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200507 rc = -ENOMEM;
Julia Lawall848e90c2015-05-01 21:37:49 +0200508 goto unlock;
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200509 }
Peng Taod7e09d02013-05-02 16:46:55 +0800510again:
511
512 ptlrpc_service_for_each_part(svcpt, i, svc) {
513 nrs = nrs_svcpt2nrs(svcpt, hp);
514 spin_lock(&nrs->nrs_lock);
515
516 pol_idx = 0;
517
Oleg Drokin30c0aa32016-02-26 01:50:02 -0500518 list_for_each_entry(policy, &nrs->nrs_policy_list, pol_list) {
Peng Taod7e09d02013-05-02 16:46:55 +0800519 LASSERT(pol_idx < num_pols);
520
521 nrs_policy_get_info_locked(policy, &tmp);
522 /**
523 * Copy values when handling the first service
524 * partition.
525 */
526 if (i == 0) {
527 memcpy(infos[pol_idx].pi_name, tmp.pi_name,
528 NRS_POL_NAME_MAX);
529 memcpy(&infos[pol_idx].pi_state, &tmp.pi_state,
530 sizeof(tmp.pi_state));
531 infos[pol_idx].pi_fallback = tmp.pi_fallback;
532 /**
533 * For the rest of the service partitions
534 * sanity-check the values we get.
535 */
536 } else {
537 LASSERT(strncmp(infos[pol_idx].pi_name,
538 tmp.pi_name,
539 NRS_POL_NAME_MAX) == 0);
540 /**
541 * Not asserting ptlrpc_nrs_pol_info::pi_state,
542 * because it may be different between
543 * instances of the same policy in different
544 * service partitions.
545 */
546 LASSERT(infos[pol_idx].pi_fallback ==
547 tmp.pi_fallback);
548 }
549
550 infos[pol_idx].pi_req_queued += tmp.pi_req_queued;
551 infos[pol_idx].pi_req_started += tmp.pi_req_started;
552
553 pol_idx++;
554 }
555 spin_unlock(&nrs->nrs_lock);
556 }
557
558 /**
559 * Policy status information output is in YAML format.
560 * For example:
561 *
562 * regular_requests:
563 * - name: fifo
564 * state: started
565 * fallback: yes
566 * queued: 0
567 * active: 0
568 *
569 * - name: crrn
570 * state: started
571 * fallback: no
572 * queued: 2015
573 * active: 384
574 *
575 * high_priority_requests:
576 * - name: fifo
577 * state: started
578 * fallback: yes
579 * queued: 0
580 * active: 2
581 *
582 * - name: crrn
583 * state: stopped
584 * fallback: no
585 * queued: 0
586 * active: 0
587 */
Peng Tao73bb1da2013-05-29 21:40:55 +0800588 seq_printf(m, "%s\n",
Oleg Drokin30c0aa32016-02-26 01:50:02 -0500589 !hp ? "\nregular_requests:" : "high_priority_requests:");
Peng Taod7e09d02013-05-02 16:46:55 +0800590
591 for (pol_idx = 0; pol_idx < num_pols; pol_idx++) {
Peng Tao73bb1da2013-05-29 21:40:55 +0800592 seq_printf(m, " - name: %s\n"
Peng Taod7e09d02013-05-02 16:46:55 +0800593 " state: %s\n"
594 " fallback: %s\n"
595 " queued: %-20d\n"
596 " active: %-20d\n\n",
597 infos[pol_idx].pi_name,
598 nrs_state2str(infos[pol_idx].pi_state),
599 infos[pol_idx].pi_fallback ? "yes" : "no",
600 (int)infos[pol_idx].pi_req_queued,
601 (int)infos[pol_idx].pi_req_started);
Peng Taod7e09d02013-05-02 16:46:55 +0800602 }
603
604 if (!hp && nrs_svc_has_hp(svc)) {
605 memset(infos, 0, num_pols * sizeof(*infos));
606
607 /**
608 * Redo the processing for the service's HP NRS heads' policies.
609 */
610 hp = true;
611 goto again;
612 }
613
Julia Lawall848e90c2015-05-01 21:37:49 +0200614 kfree(infos);
615unlock:
Peng Taod7e09d02013-05-02 16:46:55 +0800616 mutex_unlock(&nrs_core.nrs_mutex);
617
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800618 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800619}
620
621/**
Masanari Iidab6da17f2014-02-08 00:30:40 +0900622 * The longest valid command string is the maximum policy name size, plus the
Peng Taod7e09d02013-05-02 16:46:55 +0800623 * length of the " reg" substring
624 */
625#define LPROCFS_NRS_WR_MAX_CMD (NRS_POL_NAME_MAX + sizeof(" reg") - 1)
626
627/**
628 * Starts and stops a given policy on a PTLRPC service.
629 *
630 * Commands consist of the policy name, followed by an optional [reg|hp] token;
631 * if the optional token is omitted, the operation is performed on both the
632 * regular and high-priority (if the service has one) NRS head.
633 */
Anil Belur29dd4f92014-07-31 13:21:02 +0530634static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
Chris Hannad0bfef32015-06-03 10:28:26 -0400635 const char __user *buffer,
636 size_t count, loff_t *off)
Peng Taod7e09d02013-05-02 16:46:55 +0800637{
Peng Tao73bb1da2013-05-29 21:40:55 +0800638 struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
Chris Hannad0bfef32015-06-03 10:28:26 -0400639 enum ptlrpc_nrs_queue_type queue = PTLRPC_NRS_QUEUE_BOTH;
640 char *cmd;
641 char *cmd_copy = NULL;
642 char *token;
643 int rc = 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800644
Julia Lawall848e90c2015-05-01 21:37:49 +0200645 if (count >= LPROCFS_NRS_WR_MAX_CMD)
646 return -EINVAL;
Peng Taod7e09d02013-05-02 16:46:55 +0800647
Julia Lawall9ae10592015-05-01 17:51:12 +0200648 cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
Julia Lawall597851a2015-06-20 18:59:10 +0200649 if (!cmd)
Julia Lawall848e90c2015-05-01 21:37:49 +0200650 return -ENOMEM;
Peng Taod7e09d02013-05-02 16:46:55 +0800651 /**
652 * strsep() modifies its argument, so keep a copy
653 */
654 cmd_copy = cmd;
655
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200656 if (copy_from_user(cmd, buffer, count)) {
657 rc = -EFAULT;
658 goto out;
659 }
Peng Taod7e09d02013-05-02 16:46:55 +0800660
661 cmd[count] = '\0';
662
663 token = strsep(&cmd, " ");
664
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200665 if (strlen(token) > NRS_POL_NAME_MAX - 1) {
666 rc = -EINVAL;
667 goto out;
668 }
Peng Taod7e09d02013-05-02 16:46:55 +0800669
670 /**
671 * No [reg|hp] token has been specified
672 */
Oleg Drokin8b382082016-02-16 00:46:58 -0500673 if (!cmd)
Peng Taod7e09d02013-05-02 16:46:55 +0800674 goto default_queue;
675
676 /**
677 * The second token is either NULL, or an optional [reg|hp] string
678 */
Oleg Drokinda5ecb42016-04-01 15:18:01 -0400679 if (strcmp(cmd, "reg") == 0) {
Peng Taod7e09d02013-05-02 16:46:55 +0800680 queue = PTLRPC_NRS_QUEUE_REG;
Oleg Drokinda5ecb42016-04-01 15:18:01 -0400681 } else if (strcmp(cmd, "hp") == 0) {
Peng Taod7e09d02013-05-02 16:46:55 +0800682 queue = PTLRPC_NRS_QUEUE_HP;
Oleg Drokinda5ecb42016-04-01 15:18:01 -0400683 } else {
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200684 rc = -EINVAL;
685 goto out;
686 }
Peng Taod7e09d02013-05-02 16:46:55 +0800687
688default_queue:
689
Julia Lawalla9b3e8f2014-09-07 18:18:29 +0200690 if (queue == PTLRPC_NRS_QUEUE_HP && !nrs_svc_has_hp(svc)) {
691 rc = -ENODEV;
692 goto out;
Oleg Drokinda5ecb42016-04-01 15:18:01 -0400693 } else if (queue == PTLRPC_NRS_QUEUE_BOTH && !nrs_svc_has_hp(svc)) {
Peng Taod7e09d02013-05-02 16:46:55 +0800694 queue = PTLRPC_NRS_QUEUE_REG;
Oleg Drokinda5ecb42016-04-01 15:18:01 -0400695 }
Peng Taod7e09d02013-05-02 16:46:55 +0800696
697 /**
698 * Serialize NRS core lprocfs operations with policy registration/
699 * unregistration.
700 */
701 mutex_lock(&nrs_core.nrs_mutex);
702
703 rc = ptlrpc_nrs_policy_control(svc, queue, token, PTLRPC_NRS_CTL_START,
704 false, NULL);
705
706 mutex_unlock(&nrs_core.nrs_mutex);
707out:
Julia Lawall848e90c2015-05-01 21:37:49 +0200708 kfree(cmd_copy);
Peng Taod7e09d02013-05-02 16:46:55 +0800709
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +0800710 return rc < 0 ? rc : count;
Peng Taod7e09d02013-05-02 16:46:55 +0800711}
Mike Rapoportc9f6bb92015-10-13 16:03:42 +0300712
Peng Tao73bb1da2013-05-29 21:40:55 +0800713LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs);
Peng Taod7e09d02013-05-02 16:46:55 +0800714
715/** @} nrs */
716
717struct ptlrpc_srh_iterator {
718 int srhi_idx;
719 __u64 srhi_seq;
720 struct ptlrpc_request *srhi_req;
721};
722
Jon Bernardb3c986d2015-01-20 14:55:28 -0500723static int
Peng Taod7e09d02013-05-02 16:46:55 +0800724ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service_part *svcpt,
725 struct ptlrpc_srh_iterator *srhi,
726 __u64 seq)
727{
Chris Hannad0bfef32015-06-03 10:28:26 -0400728 struct list_head *e;
729 struct ptlrpc_request *req;
Peng Taod7e09d02013-05-02 16:46:55 +0800730
Oleg Drokin8b382082016-02-16 00:46:58 -0500731 if (srhi->srhi_req && srhi->srhi_seq > svcpt->scp_hist_seq_culled &&
Peng Taod7e09d02013-05-02 16:46:55 +0800732 srhi->srhi_seq <= seq) {
733 /* If srhi_req was set previously, hasn't been culled and
734 * we're searching for a seq on or after it (i.e. more
735 * recent), search from it onwards.
736 * Since the service history is LRU (i.e. culled reqs will
737 * be near the head), we shouldn't have to do long
Oleg Drokindadfcda2016-02-24 22:00:38 -0500738 * re-scans
739 */
Peng Taod7e09d02013-05-02 16:46:55 +0800740 LASSERTF(srhi->srhi_seq == srhi->srhi_req->rq_history_seq,
Greg Kroah-Hartmanb0f5aad2014-07-12 20:06:04 -0700741 "%s:%d: seek seq %llu, request seq %llu\n",
Peng Taod7e09d02013-05-02 16:46:55 +0800742 svcpt->scp_service->srv_name, svcpt->scp_cpt,
743 srhi->srhi_seq, srhi->srhi_req->rq_history_seq);
744 LASSERTF(!list_empty(&svcpt->scp_hist_reqs),
Joe Perches2d00bd12014-11-23 11:28:50 -0800745 "%s:%d: seek offset %llu, request seq %llu, last culled %llu\n",
Peng Taod7e09d02013-05-02 16:46:55 +0800746 svcpt->scp_service->srv_name, svcpt->scp_cpt,
747 seq, srhi->srhi_seq, svcpt->scp_hist_seq_culled);
748 e = &srhi->srhi_req->rq_history_list;
749 } else {
750 /* search from start */
751 e = svcpt->scp_hist_reqs.next;
752 }
753
754 while (e != &svcpt->scp_hist_reqs) {
755 req = list_entry(e, struct ptlrpc_request, rq_history_list);
756
757 if (req->rq_history_seq >= seq) {
758 srhi->srhi_seq = req->rq_history_seq;
759 srhi->srhi_req = req;
760 return 0;
761 }
762 e = e->next;
763 }
764
765 return -ENOENT;
766}
767
768/*
769 * ptlrpc history sequence is used as "position" of seq_file, in some case,
770 * seq_read() will increase "position" to indicate reading the next
771 * element, however, low bits of history sequence are reserved for CPT id
772 * (check the details from comments before ptlrpc_req_add_history), which
773 * means seq_read() might change CPT id of history sequence and never
774 * finish reading of requests on a CPT. To make it work, we have to shift
775 * CPT id to high bits and timestamp to low bits, so seq_read() will only
776 * increase timestamp which can correctly indicate the next position.
777 */
778
779/* convert seq_file pos to cpt */
780#define PTLRPC_REQ_POS2CPT(svc, pos) \
781 ((svc)->srv_cpt_bits == 0 ? 0 : \
782 (__u64)(pos) >> (64 - (svc)->srv_cpt_bits))
783
784/* make up seq_file pos from cpt */
785#define PTLRPC_REQ_CPT2POS(svc, cpt) \
786 ((svc)->srv_cpt_bits == 0 ? 0 : \
787 (cpt) << (64 - (svc)->srv_cpt_bits))
788
789/* convert sequence to position */
790#define PTLRPC_REQ_SEQ2POS(svc, seq) \
791 ((svc)->srv_cpt_bits == 0 ? (seq) : \
792 ((seq) >> (svc)->srv_cpt_bits) | \
793 ((seq) << (64 - (svc)->srv_cpt_bits)))
794
795/* convert position to sequence */
796#define PTLRPC_REQ_POS2SEQ(svc, pos) \
797 ((svc)->srv_cpt_bits == 0 ? (pos) : \
798 ((__u64)(pos) << (svc)->srv_cpt_bits) | \
799 ((__u64)(pos) >> (64 - (svc)->srv_cpt_bits)))
800
801static void *
802ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
803{
804 struct ptlrpc_service *svc = s->private;
805 struct ptlrpc_service_part *svcpt;
806 struct ptlrpc_srh_iterator *srhi;
807 unsigned int cpt;
808 int rc;
809 int i;
810
811 if (sizeof(loff_t) != sizeof(__u64)) { /* can't support */
Joe Perches2d00bd12014-11-23 11:28:50 -0800812 CWARN("Failed to read request history because size of loff_t %d can't match size of u64\n",
813 (int)sizeof(loff_t));
Peng Taod7e09d02013-05-02 16:46:55 +0800814 return NULL;
815 }
816
Julia Lawall9ae10592015-05-01 17:51:12 +0200817 srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
Julia Lawall597851a2015-06-20 18:59:10 +0200818 if (!srhi)
Peng Taod7e09d02013-05-02 16:46:55 +0800819 return NULL;
820
821 srhi->srhi_seq = 0;
822 srhi->srhi_req = NULL;
823
824 cpt = PTLRPC_REQ_POS2CPT(svc, *pos);
825
826 ptlrpc_service_for_each_part(svcpt, i, svc) {
827 if (i < cpt) /* skip */
828 continue;
829 if (i > cpt) /* make up the lowest position for this CPT */
830 *pos = PTLRPC_REQ_CPT2POS(svc, i);
831
832 spin_lock(&svcpt->scp_lock);
833 rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi,
834 PTLRPC_REQ_POS2SEQ(svc, *pos));
835 spin_unlock(&svcpt->scp_lock);
836 if (rc == 0) {
837 *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
838 srhi->srhi_idx = i;
839 return srhi;
840 }
841 }
842
Julia Lawall9ae10592015-05-01 17:51:12 +0200843 kfree(srhi);
Peng Taod7e09d02013-05-02 16:46:55 +0800844 return NULL;
845}
846
847static void
848ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter)
849{
850 struct ptlrpc_srh_iterator *srhi = iter;
851
Julia Lawall848e90c2015-05-01 21:37:49 +0200852 kfree(srhi);
Peng Taod7e09d02013-05-02 16:46:55 +0800853}
854
855static void *
856ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
857 void *iter, loff_t *pos)
858{
Chris Hannad0bfef32015-06-03 10:28:26 -0400859 struct ptlrpc_service *svc = s->private;
860 struct ptlrpc_srh_iterator *srhi = iter;
861 struct ptlrpc_service_part *svcpt;
862 __u64 seq;
863 int rc;
864 int i;
Peng Taod7e09d02013-05-02 16:46:55 +0800865
866 for (i = srhi->srhi_idx; i < svc->srv_ncpts; i++) {
867 svcpt = svc->srv_parts[i];
868
869 if (i > srhi->srhi_idx) { /* reset iterator for a new CPT */
870 srhi->srhi_req = NULL;
Nathaniel Clark3d2b8f52016-06-09 22:35:17 -0400871 seq = 0;
872 srhi->srhi_seq = 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800873 } else { /* the next sequence */
874 seq = srhi->srhi_seq + (1 << svc->srv_cpt_bits);
875 }
876
877 spin_lock(&svcpt->scp_lock);
878 rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, seq);
879 spin_unlock(&svcpt->scp_lock);
880 if (rc == 0) {
881 *pos = PTLRPC_REQ_SEQ2POS(svc, srhi->srhi_seq);
882 srhi->srhi_idx = i;
883 return srhi;
884 }
885 }
886
Julia Lawall9ae10592015-05-01 17:51:12 +0200887 kfree(srhi);
Peng Taod7e09d02013-05-02 16:46:55 +0800888 return NULL;
889}
890
Peng Taod7e09d02013-05-02 16:46:55 +0800891static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
892{
Chris Hannad0bfef32015-06-03 10:28:26 -0400893 struct ptlrpc_service *svc = s->private;
894 struct ptlrpc_srh_iterator *srhi = iter;
895 struct ptlrpc_service_part *svcpt;
896 struct ptlrpc_request *req;
897 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800898
899 LASSERT(srhi->srhi_idx < svc->srv_ncpts);
900
901 svcpt = svc->srv_parts[srhi->srhi_idx];
902
903 spin_lock(&svcpt->scp_lock);
904
905 rc = ptlrpc_lprocfs_svc_req_history_seek(svcpt, srhi, srhi->srhi_seq);
906
907 if (rc == 0) {
Dmitry Eremin80feb1e2015-10-21 21:52:47 -0400908 char nidstr[LNET_NIDSTR_SIZE];
909
Peng Taod7e09d02013-05-02 16:46:55 +0800910 req = srhi->srhi_req;
911
Dmitry Eremin80feb1e2015-10-21 21:52:47 -0400912 libcfs_nid2str_r(req->rq_self, nidstr, sizeof(nidstr));
Peng Taod7e09d02013-05-02 16:46:55 +0800913 /* Print common req fields.
914 * CAVEAT EMPTOR: we're racing with the service handler
915 * here. The request could contain any old crap, so you
916 * must be just as careful as the service's request
917 * parser. Currently I only print stuff here I know is OK
Oleg Drokindadfcda2016-02-24 22:00:38 -0500918 * to look at coz it was set up in request_in_callback()!!!
919 */
Arnd Bergmann219e6de2015-09-27 16:45:30 -0400920 seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld:%lds(%+lds) ",
Dmitry Eremin80feb1e2015-10-21 21:52:47 -0400921 req->rq_history_seq, nidstr,
Peng Taod7e09d02013-05-02 16:46:55 +0800922 libcfs_id2str(req->rq_peer), req->rq_xid,
923 req->rq_reqlen, ptlrpc_rqphase2str(req),
Arnd Bergmann219e6de2015-09-27 16:45:30 -0400924 (s64)req->rq_arrival_time.tv_sec,
925 (long)(req->rq_sent - req->rq_arrival_time.tv_sec),
926 (long)(req->rq_sent - req->rq_deadline));
Oleg Drokin8b382082016-02-16 00:46:58 -0500927 if (!svc->srv_ops.so_req_printer)
Amitoj Kaur Chawla8d816fb2015-10-26 22:37:26 +0530928 seq_putc(s, '\n');
Peng Taod7e09d02013-05-02 16:46:55 +0800929 else
930 svc->srv_ops.so_req_printer(s, srhi->srhi_req);
931 }
932
933 spin_unlock(&svcpt->scp_lock);
934 return rc;
935}
936
937static int
938ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file)
939{
Julia Lawallfaac7a82016-08-28 23:27:06 +0200940 static const struct seq_operations sops = {
Peng Taod7e09d02013-05-02 16:46:55 +0800941 .start = ptlrpc_lprocfs_svc_req_history_start,
942 .stop = ptlrpc_lprocfs_svc_req_history_stop,
943 .next = ptlrpc_lprocfs_svc_req_history_next,
944 .show = ptlrpc_lprocfs_svc_req_history_show,
945 };
Chris Hannad0bfef32015-06-03 10:28:26 -0400946 struct seq_file *seqf;
947 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800948
Peng Taod7e09d02013-05-02 16:46:55 +0800949 rc = seq_open(file, &sops);
Peng Tao73bb1da2013-05-29 21:40:55 +0800950 if (rc)
Peng Taod7e09d02013-05-02 16:46:55 +0800951 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +0800952
953 seqf = file->private_data;
Dmitry Eremin700815d2015-05-21 15:32:11 -0400954 seqf->private = inode->i_private;
Peng Taod7e09d02013-05-02 16:46:55 +0800955 return 0;
956}
957
958/* See also lprocfs_rd_timeouts */
Peng Tao73bb1da2013-05-29 21:40:55 +0800959static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n)
Peng Taod7e09d02013-05-02 16:46:55 +0800960{
Chris Hannad0bfef32015-06-03 10:28:26 -0400961 struct ptlrpc_service *svc = m->private;
962 struct ptlrpc_service_part *svcpt;
963 struct dhms ts;
Arnd Bergmann0ac04782015-09-27 16:45:19 -0400964 time64_t worstt;
Chris Hannad0bfef32015-06-03 10:28:26 -0400965 unsigned int cur;
966 unsigned int worst;
967 int i;
Peng Taod7e09d02013-05-02 16:46:55 +0800968
969 if (AT_OFF) {
Peng Tao73bb1da2013-05-29 21:40:55 +0800970 seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n",
Oleg Drokin30c0aa32016-02-26 01:50:02 -0500971 obd_timeout);
Peng Tao73bb1da2013-05-29 21:40:55 +0800972 return 0;
Peng Taod7e09d02013-05-02 16:46:55 +0800973 }
974
975 ptlrpc_service_for_each_part(svcpt, i, svc) {
976 cur = at_get(&svcpt->scp_at_estimate);
977 worst = svcpt->scp_at_estimate.at_worst_ever;
978 worstt = svcpt->scp_at_estimate.at_worst_time;
Arnd Bergmann0ac04782015-09-27 16:45:19 -0400979 s2dhms(&ts, ktime_get_real_seconds() - worstt);
Peng Taod7e09d02013-05-02 16:46:55 +0800980
Arnd Bergmann0ac04782015-09-27 16:45:19 -0400981 seq_printf(m, "%10s : cur %3u worst %3u (at %lld, "
Oleg Drokin30c0aa32016-02-26 01:50:02 -0500982 DHMS_FMT " ago) ", "service",
983 cur, worst, (s64)worstt, DHMS_VARS(&ts));
Peng Taod7e09d02013-05-02 16:46:55 +0800984
Peng Tao73bb1da2013-05-29 21:40:55 +0800985 lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate);
Peng Taod7e09d02013-05-02 16:46:55 +0800986 }
987
Peng Tao73bb1da2013-05-29 21:40:55 +0800988 return 0;
989}
Mike Rapoportc9f6bb92015-10-13 16:03:42 +0300990
Peng Tao73bb1da2013-05-29 21:40:55 +0800991LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
992
Oleg Drokinb40881e2015-05-21 15:32:10 -0400993static ssize_t high_priority_ratio_show(struct kobject *kobj,
994 struct attribute *attr,
995 char *buf)
Peng Tao73bb1da2013-05-29 21:40:55 +0800996{
Oleg Drokinb40881e2015-05-21 15:32:10 -0400997 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
998 srv_kobj);
999 return sprintf(buf, "%d\n", svc->srv_hpreq_ratio);
Peng Taod7e09d02013-05-02 16:46:55 +08001000}
1001
Oleg Drokinb40881e2015-05-21 15:32:10 -04001002static ssize_t high_priority_ratio_store(struct kobject *kobj,
1003 struct attribute *attr,
1004 const char *buffer,
1005 size_t count)
Peng Taod7e09d02013-05-02 16:46:55 +08001006{
Oleg Drokinb40881e2015-05-21 15:32:10 -04001007 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
1008 srv_kobj);
1009 int rc;
Dan Carpenterb8155552015-06-05 12:22:57 +03001010 int val;
Peng Taod7e09d02013-05-02 16:46:55 +08001011
Dan Carpenterb8155552015-06-05 12:22:57 +03001012 rc = kstrtoint(buffer, 10, &val);
Peng Taod7e09d02013-05-02 16:46:55 +08001013 if (rc < 0)
1014 return rc;
1015
1016 if (val < 0)
1017 return -ERANGE;
1018
1019 spin_lock(&svc->srv_lock);
1020 svc->srv_hpreq_ratio = val;
1021 spin_unlock(&svc->srv_lock);
1022
1023 return count;
1024}
Oleg Drokinb40881e2015-05-21 15:32:10 -04001025LUSTRE_RW_ATTR(high_priority_ratio);
Peng Taod7e09d02013-05-02 16:46:55 +08001026
Oleg Drokin328676f2015-05-21 15:32:08 -04001027static struct attribute *ptlrpc_svc_attrs[] = {
Oleg Drokin673a6792015-05-21 15:32:09 -04001028 &lustre_attr_threads_min.attr,
1029 &lustre_attr_threads_started.attr,
1030 &lustre_attr_threads_max.attr,
Oleg Drokinb40881e2015-05-21 15:32:10 -04001031 &lustre_attr_high_priority_ratio.attr,
Oleg Drokin328676f2015-05-21 15:32:08 -04001032 NULL,
1033};
1034
1035static void ptlrpc_sysfs_svc_release(struct kobject *kobj)
1036{
1037 struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
1038 srv_kobj);
1039
1040 complete(&svc->srv_kobj_unregister);
1041}
1042
1043static struct kobj_type ptlrpc_svc_ktype = {
1044 .default_attrs = ptlrpc_svc_attrs,
1045 .sysfs_ops = &lustre_sysfs_ops,
1046 .release = ptlrpc_sysfs_svc_release,
1047};
1048
1049void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc)
1050{
1051 /* Let's see if we had a chance at initialization first */
1052 if (svc->srv_kobj.kset) {
1053 kobject_put(&svc->srv_kobj);
1054 wait_for_completion(&svc->srv_kobj_unregister);
1055 }
1056}
1057
1058int ptlrpc_sysfs_register_service(struct kset *parent,
1059 struct ptlrpc_service *svc)
1060{
1061 int rc;
1062
1063 svc->srv_kobj.kset = parent;
1064 init_completion(&svc->srv_kobj_unregister);
1065 rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL,
1066 "%s", svc->srv_name);
1067
1068 return rc;
1069}
1070
Dmitry Eremin700815d2015-05-21 15:32:11 -04001071void ptlrpc_ldebugfs_register_service(struct dentry *entry,
1072 struct ptlrpc_service *svc)
Peng Taod7e09d02013-05-02 16:46:55 +08001073{
1074 struct lprocfs_vars lproc_vars[] = {
Peng Taod7e09d02013-05-02 16:46:55 +08001075 {.name = "req_buffer_history_len",
Peng Tao73bb1da2013-05-29 21:40:55 +08001076 .fops = &ptlrpc_lprocfs_req_history_len_fops,
Peng Taod7e09d02013-05-02 16:46:55 +08001077 .data = svc},
1078 {.name = "req_buffer_history_max",
Peng Tao73bb1da2013-05-29 21:40:55 +08001079 .fops = &ptlrpc_lprocfs_req_history_max_fops,
Peng Taod7e09d02013-05-02 16:46:55 +08001080 .data = svc},
Peng Taod7e09d02013-05-02 16:46:55 +08001081 {.name = "timeouts",
Peng Tao73bb1da2013-05-29 21:40:55 +08001082 .fops = &ptlrpc_lprocfs_timeouts_fops,
Peng Taod7e09d02013-05-02 16:46:55 +08001083 .data = svc},
1084 {.name = "nrs_policies",
Peng Tao73bb1da2013-05-29 21:40:55 +08001085 .fops = &ptlrpc_lprocfs_nrs_fops,
Peng Taod7e09d02013-05-02 16:46:55 +08001086 .data = svc},
1087 {NULL}
1088 };
Melike Yurtogludddf4c22015-02-27 22:42:09 +02001089 static const struct file_operations req_history_fops = {
Peng Taod7e09d02013-05-02 16:46:55 +08001090 .owner = THIS_MODULE,
1091 .open = ptlrpc_lprocfs_svc_req_history_open,
1092 .read = seq_read,
1093 .llseek = seq_lseek,
1094 .release = lprocfs_seq_release,
1095 };
1096
1097 int rc;
1098
Dmitry Eremin700815d2015-05-21 15:32:11 -04001099 ptlrpc_ldebugfs_register(entry, svc->srv_name,
1100 "stats", &svc->srv_debugfs_entry,
1101 &svc->srv_stats);
Peng Taod7e09d02013-05-02 16:46:55 +08001102
Oleg Drokin8b382082016-02-16 00:46:58 -05001103 if (IS_ERR_OR_NULL(svc->srv_debugfs_entry))
Peng Taod7e09d02013-05-02 16:46:55 +08001104 return;
1105
Dmitry Eremin700815d2015-05-21 15:32:11 -04001106 ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL);
Peng Taod7e09d02013-05-02 16:46:55 +08001107
Dmitry Eremin700815d2015-05-21 15:32:11 -04001108 rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history",
1109 0400, &req_history_fops, svc);
Peng Taod7e09d02013-05-02 16:46:55 +08001110 if (rc)
1111 CWARN("Error adding the req_history file\n");
1112}
1113
1114void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
1115{
Dmitry Eremin61e87ab2015-05-21 15:32:27 -04001116 ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats",
1117 &obddev->obd_svc_debugfs_entry,
1118 &obddev->obd_svc_stats);
Peng Taod7e09d02013-05-02 16:46:55 +08001119}
1120EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
1121
1122void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount)
1123{
1124 struct lprocfs_stats *svc_stats;
1125 __u32 op = lustre_msg_get_opc(req->rq_reqmsg);
1126 int opc = opcode_offset(op);
1127
1128 svc_stats = req->rq_import->imp_obd->obd_svc_stats;
Oleg Drokin8b382082016-02-16 00:46:58 -05001129 if (!svc_stats || opc <= 0)
Peng Taod7e09d02013-05-02 16:46:55 +08001130 return;
1131 LASSERT(opc < LUSTRE_MAX_OPCODES);
1132 if (!(op == LDLM_ENQUEUE || op == MDS_REINT))
1133 lprocfs_counter_add(svc_stats, opc + EXTRA_MAX_OPCODES, amount);
1134}
1135
1136void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes)
1137{
1138 struct lprocfs_stats *svc_stats;
1139 int idx;
1140
1141 if (!req->rq_import)
1142 return;
1143 svc_stats = req->rq_import->imp_obd->obd_svc_stats;
1144 if (!svc_stats)
1145 return;
1146 idx = lustre_msg_get_opc(req->rq_reqmsg);
1147 switch (idx) {
1148 case OST_READ:
1149 idx = BRW_READ_BYTES + PTLRPC_LAST_CNTR;
1150 break;
1151 case OST_WRITE:
1152 idx = BRW_WRITE_BYTES + PTLRPC_LAST_CNTR;
1153 break;
1154 default:
1155 LASSERTF(0, "unsupported opcode %u\n", idx);
1156 break;
1157 }
1158
1159 lprocfs_counter_add(svc_stats, idx, bytes);
1160}
Peng Taod7e09d02013-05-02 16:46:55 +08001161EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
1162
1163void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
1164{
Oleg Drokin8b382082016-02-16 00:46:58 -05001165 if (!IS_ERR_OR_NULL(svc->srv_debugfs_entry))
Dmitry Eremin700815d2015-05-21 15:32:11 -04001166 ldebugfs_remove(&svc->srv_debugfs_entry);
Peng Taod7e09d02013-05-02 16:46:55 +08001167
1168 if (svc->srv_stats)
1169 lprocfs_free_stats(&svc->srv_stats);
1170}
1171
1172void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
1173{
Dmitry Eremin61e87ab2015-05-21 15:32:27 -04001174 if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry))
1175 ldebugfs_remove(&obd->obd_svc_debugfs_entry);
Peng Taod7e09d02013-05-02 16:46:55 +08001176
1177 if (obd->obd_svc_stats)
1178 lprocfs_free_stats(&obd->obd_svc_stats);
1179}
1180EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
1181
Peng Taod7e09d02013-05-02 16:46:55 +08001182#undef BUFLEN
1183
Tristan Lelonge84962e2014-12-05 22:43:20 -08001184int lprocfs_wr_ping(struct file *file, const char __user *buffer,
Peng Tao73bb1da2013-05-29 21:40:55 +08001185 size_t count, loff_t *off)
Peng Taod7e09d02013-05-02 16:46:55 +08001186{
Peng Tao73bb1da2013-05-29 21:40:55 +08001187 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
Peng Taod7e09d02013-05-02 16:46:55 +08001188 struct ptlrpc_request *req;
Chris Hannad0bfef32015-06-03 10:28:26 -04001189 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +08001190
Ksenija Stanojevica15b2222015-10-26 08:05:57 -07001191 rc = lprocfs_climp_check(obd);
1192 if (rc)
1193 return rc;
1194
Peng Taod7e09d02013-05-02 16:46:55 +08001195 req = ptlrpc_prep_ping(obd->u.cli.cl_import);
Ksenija Stanojevice5b6b5d2015-10-28 17:30:43 -07001196 up_read(&obd->u.cli.cl_sem);
Oleg Drokin8b382082016-02-16 00:46:58 -05001197 if (!req)
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +08001198 return -ENOMEM;
Peng Taod7e09d02013-05-02 16:46:55 +08001199
1200 req->rq_send_state = LUSTRE_IMP_FULL;
1201
1202 rc = ptlrpc_queue_wait(req);
1203
1204 ptlrpc_req_finished(req);
1205 if (rc >= 0)
Greg Kroah-Hartman0a3bdb02013-08-03 10:35:28 +08001206 return count;
1207 return rc;
Peng Taod7e09d02013-05-02 16:46:55 +08001208}
1209EXPORT_SYMBOL(lprocfs_wr_ping);
1210
1211/* Write the connection UUID to this file to attempt to connect to that node.
1212 * The connection UUID is a node's primary NID. For example,
1213 * "echo connection=192.168.0.1@tcp0::instance > .../import".
1214 */
Tristan Lelonge84962e2014-12-05 22:43:20 -08001215int lprocfs_wr_import(struct file *file, const char __user *buffer,
Peng Tao73bb1da2013-05-29 21:40:55 +08001216 size_t count, loff_t *off)
Peng Taod7e09d02013-05-02 16:46:55 +08001217{
Peng Tao73bb1da2013-05-29 21:40:55 +08001218 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
Peng Taod7e09d02013-05-02 16:46:55 +08001219 struct obd_import *imp = obd->u.cli.cl_import;
1220 char *kbuf = NULL;
1221 char *uuid;
1222 char *ptr;
1223 int do_reconn = 1;
1224 const char prefix[] = "connection=";
1225 const int prefix_len = sizeof(prefix) - 1;
1226
Kirill A. Shutemov09cbfea2016-04-01 15:29:47 +03001227 if (count > PAGE_SIZE - 1 || count <= prefix_len)
Peng Taod7e09d02013-05-02 16:46:55 +08001228 return -EINVAL;
1229
Julia Lawall9ae10592015-05-01 17:51:12 +02001230 kbuf = kzalloc(count + 1, GFP_NOFS);
Julia Lawall597851a2015-06-20 18:59:10 +02001231 if (!kbuf)
Peng Taod7e09d02013-05-02 16:46:55 +08001232 return -ENOMEM;
1233
Julia Lawalla9b3e8f2014-09-07 18:18:29 +02001234 if (copy_from_user(kbuf, buffer, count)) {
1235 count = -EFAULT;
1236 goto out;
1237 }
Peng Taod7e09d02013-05-02 16:46:55 +08001238
1239 kbuf[count] = 0;
1240
1241 /* only support connection=uuid::instance now */
Julia Lawalla9b3e8f2014-09-07 18:18:29 +02001242 if (strncmp(prefix, kbuf, prefix_len) != 0) {
1243 count = -EINVAL;
1244 goto out;
1245 }
Peng Taod7e09d02013-05-02 16:46:55 +08001246
1247 uuid = kbuf + prefix_len;
1248 ptr = strstr(uuid, "::");
1249 if (ptr) {
1250 __u32 inst;
1251 char *endptr;
1252
1253 *ptr = 0;
1254 do_reconn = 0;
1255 ptr += strlen("::");
Shivani Bhardwaje3ce40cb72015-10-16 02:17:20 +05301256 inst = simple_strtoul(ptr, &endptr, 10);
Peng Taod7e09d02013-05-02 16:46:55 +08001257 if (*endptr) {
1258 CERROR("config: wrong instance # %s\n", ptr);
1259 } else if (inst != imp->imp_connect_data.ocd_instance) {
Joe Perches2d00bd12014-11-23 11:28:50 -08001260 CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted target(%u/%u), reconnecting...\n",
Peng Taod7e09d02013-05-02 16:46:55 +08001261 imp->imp_obd->obd_name,
1262 imp->imp_connect_data.ocd_instance, inst);
1263 do_reconn = 1;
1264 } else {
Joe Perches2d00bd12014-11-23 11:28:50 -08001265 CDEBUG(D_INFO, "IR: %s has already been connecting to new target(%u)\n",
Peng Taod7e09d02013-05-02 16:46:55 +08001266 imp->imp_obd->obd_name, inst);
1267 }
1268 }
1269
1270 if (do_reconn)
1271 ptlrpc_recover_import(imp, uuid, 1);
1272
1273out:
Julia Lawall9ae10592015-05-01 17:51:12 +02001274 kfree(kbuf);
Peng Taod7e09d02013-05-02 16:46:55 +08001275 return count;
1276}
1277EXPORT_SYMBOL(lprocfs_wr_import);
1278
Peng Tao73bb1da2013-05-29 21:40:55 +08001279int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
Peng Taod7e09d02013-05-02 16:46:55 +08001280{
Peng Tao73bb1da2013-05-29 21:40:55 +08001281 struct obd_device *obd = m->private;
Peng Taod7e09d02013-05-02 16:46:55 +08001282 struct obd_import *imp = obd->u.cli.cl_import;
Ksenija Stanojevica15b2222015-10-26 08:05:57 -07001283 int rc;
Peng Taod7e09d02013-05-02 16:46:55 +08001284
Ksenija Stanojevica15b2222015-10-26 08:05:57 -07001285 rc = lprocfs_climp_check(obd);
1286 if (rc)
1287 return rc;
1288
Joe Perches91b3a682015-03-01 19:58:57 -08001289 seq_printf(m, "%d\n", !imp->imp_no_pinger_recover);
Ksenija Stanojevice5b6b5d2015-10-28 17:30:43 -07001290 up_read(&obd->u.cli.cl_sem);
Peng Taod7e09d02013-05-02 16:46:55 +08001291
Joe Perches91b3a682015-03-01 19:58:57 -08001292 return 0;
Peng Taod7e09d02013-05-02 16:46:55 +08001293}
1294EXPORT_SYMBOL(lprocfs_rd_pinger_recov);
1295
Tristan Lelonge84962e2014-12-05 22:43:20 -08001296int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
Oleg Drokin30c0aa32016-02-26 01:50:02 -05001297 size_t count, loff_t *off)
Peng Taod7e09d02013-05-02 16:46:55 +08001298{
Peng Tao73bb1da2013-05-29 21:40:55 +08001299 struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
Peng Taod7e09d02013-05-02 16:46:55 +08001300 struct client_obd *cli = &obd->u.cli;
1301 struct obd_import *imp = cli->cl_import;
1302 int rc, val;
1303
1304 rc = lprocfs_write_helper(buffer, count, &val);
1305 if (rc < 0)
1306 return rc;
1307
1308 if (val != 0 && val != 1)
1309 return -ERANGE;
1310
Ksenija Stanojevica15b2222015-10-26 08:05:57 -07001311 rc = lprocfs_climp_check(obd);
1312 if (rc)
1313 return rc;
1314
Peng Taod7e09d02013-05-02 16:46:55 +08001315 spin_lock(&imp->imp_lock);
1316 imp->imp_no_pinger_recover = !val;
1317 spin_unlock(&imp->imp_lock);
Ksenija Stanojevice5b6b5d2015-10-28 17:30:43 -07001318 up_read(&obd->u.cli.cl_sem);
Peng Taod7e09d02013-05-02 16:46:55 +08001319
1320 return count;
Peng Taod7e09d02013-05-02 16:46:55 +08001321}
1322EXPORT_SYMBOL(lprocfs_wr_pinger_recov);