Whamcloud - gitweb
b=13537
[fs/lustre-release.git] / lustre / ptlrpc / lproc_ptlrpc.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2002 Cluster File Systems, Inc.
5  *
6  *   This file is part of the Lustre file system, http://www.lustre.org
7  *   Lustre is a trademark of Cluster File Systems, Inc.
8  *
9  *   You may have signed or agreed to another license before downloading
10  *   this software.  If so, you are bound by the terms and conditions
11  *   of that agreement, and the following does not apply to you.  See the
12  *   LICENSE file included with this distribution for more information.
13  *
14  *   If you did not agree to a different license, then this copy of Lustre
15  *   is open source software; you can redistribute it and/or modify it
16  *   under the terms of version 2 of the GNU General Public License as
17  *   published by the Free Software Foundation.
18  *
19  *   In either case, Lustre is distributed in the hope that it will be
20  *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
21  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   license text for more details.
23  *
24  */
25 #define DEBUG_SUBSYSTEM S_CLASS
26
27 #ifndef __KERNEL__
28 # include <liblustre.h>
29 #endif
30
31 #include <obd_support.h>
32 #include <obd.h>
33 #include <lprocfs_status.h>
34 #include <lustre/lustre_idl.h>
35 #include <lustre_net.h>
36 #include <obd_class.h>
37 #include "ptlrpc_internal.h"
38
39
40 struct ll_rpc_opcode {
41      __u32       opcode;
42      const char *opname;
43 } ll_rpc_opcode_table[LUSTRE_MAX_OPCODES] = {
44         { OST_REPLY,        "ost_reply" },
45         { OST_GETATTR,      "ost_getattr" },
46         { OST_SETATTR,      "ost_setattr" },
47         { OST_READ,         "ost_read" },
48         { OST_WRITE,        "ost_write" },
49         { OST_CREATE ,      "ost_create" },
50         { OST_DESTROY,      "ost_destroy" },
51         { OST_GET_INFO,     "ost_get_info" },
52         { OST_CONNECT,      "ost_connect" },
53         { OST_DISCONNECT,   "ost_disconnect" },
54         { OST_PUNCH,        "ost_punch" },
55         { OST_OPEN,         "ost_open" },
56         { OST_CLOSE,        "ost_close" },
57         { OST_STATFS,       "ost_statfs" },
58         { 14,                NULL },    /* formerly OST_SAN_READ */
59         { 15,                NULL },    /* formerly OST_SAN_WRITE */
60         { OST_SYNC,         "ost_sync" },
61         { OST_SET_INFO,     "ost_set_info" },
62         { OST_QUOTACHECK,   "ost_quotacheck" },
63         { OST_QUOTACTL,     "ost_quotactl" },
64         { MDS_GETATTR,      "mds_getattr" },
65         { MDS_GETATTR_NAME, "mds_getattr_lock" },
66         { MDS_CLOSE,        "mds_close" },
67         { MDS_REINT,        "mds_reint" },
68         { MDS_READPAGE,     "mds_readpage" },
69         { MDS_CONNECT,      "mds_connect" },
70         { MDS_DISCONNECT,   "mds_disconnect" },
71         { MDS_GETSTATUS,    "mds_getstatus" },
72         { MDS_STATFS,       "mds_statfs" },
73         { MDS_PIN,          "mds_pin" },
74         { MDS_UNPIN,        "mds_unpin" },
75         { MDS_SYNC,         "mds_sync" },
76         { MDS_DONE_WRITING, "mds_done_writing" },
77         { MDS_SET_INFO,     "mds_set_info" },
78         { MDS_QUOTACHECK,   "mds_quotacheck" },
79         { MDS_QUOTACTL,     "mds_quotactl" },
80         { MDS_GETXATTR,     "mds_getxattr" },
81         { MDS_SETXATTR,     "mds_setxattr" },
82         { LDLM_ENQUEUE,     "ldlm_enqueue" },
83         { LDLM_CONVERT,     "ldlm_convert" },
84         { LDLM_CANCEL,      "ldlm_cancel" },
85         { LDLM_BL_CALLBACK, "ldlm_bl_callback" },
86         { LDLM_CP_CALLBACK, "ldlm_cp_callback" },
87         { LDLM_GL_CALLBACK, "ldlm_gl_callback" },
88         { MGS_CONNECT,      "mgs_connect" },
89         { MGS_DISCONNECT,   "mgs_disconnect" },
90         { MGS_EXCEPTION,    "mgs_exception" },
91         { MGS_TARGET_REG,   "mgs_target_reg" },
92         { MGS_TARGET_DEL,   "mgs_target_del" },
93         { MGS_SET_INFO,     "mgs_set_info" },
94         { OBD_PING,         "obd_ping" },
95         { OBD_LOG_CANCEL,   "llog_origin_handle_cancel" },
96         { OBD_QC_CALLBACK,  "obd_quota_callback" },
97         { LLOG_ORIGIN_HANDLE_CREATE,     "llog_origin_handle_create" },
98         { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block"},
99         { LLOG_ORIGIN_HANDLE_READ_HEADER,"llog_origin_handle_read_header" },
100         { LLOG_ORIGIN_HANDLE_WRITE_REC,  "llog_origin_handle_write_rec" },
101         { LLOG_ORIGIN_HANDLE_CLOSE,      "llog_origin_handle_close" },
102         { LLOG_ORIGIN_CONNECT,           "llog_origin_connect" },
103         { LLOG_CATINFO,                  "llog_catinfo" },
104         { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" },
105         { LLOG_ORIGIN_HANDLE_DESTROY,    "llog_origin_handle_destroy" },
106 };
107
108 const char* ll_opcode2str(__u32 opcode)
109 {
110         /* When one of the assertions below fail, chances are that:
111          *     1) A new opcode was added in lustre_idl.h, but was
112          *        is missing from the table above.
113          * or  2) The opcode space was renumbered or rearranged,
114          *        and the opcode_offset() function in
115          *        ptlrpc_internal.h needs to be modified.
116          */
117         __u32 offset = opcode_offset(opcode);
118         LASSERT(offset < LUSTRE_MAX_OPCODES);
119         LASSERT(ll_rpc_opcode_table[offset].opcode == opcode);
120         return ll_rpc_opcode_table[offset].opname;
121 }
122
123 #ifdef LPROCFS
124 void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
125                              char *name, struct proc_dir_entry **procroot_ret,
126                              struct lprocfs_stats **stats_ret)
127 {
128         struct proc_dir_entry *svc_procroot;
129         struct lprocfs_stats *svc_stats;
130         int i, rc;
131         unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
132                                           LPROCFS_CNTR_STDDEV;
133
134         LASSERT(*procroot_ret == NULL);
135         LASSERT(*stats_ret == NULL);
136
137         svc_stats = lprocfs_alloc_stats(PTLRPC_LAST_CNTR + LUSTRE_MAX_OPCODES, 0);
138         if (svc_stats == NULL)
139                 return;
140
141         if (dir) {
142                 svc_procroot = lprocfs_register(dir, root, NULL, NULL);
143                 if (IS_ERR(svc_procroot)) {
144                         lprocfs_free_stats(&svc_stats);
145                         return;
146                 }
147         } else {
148                 svc_procroot = root;
149         }
150
151         lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR,
152                              svc_counter_config, "req_waittime", "usec");
153         lprocfs_counter_init(svc_stats, PTLRPC_REQQDEPTH_CNTR,
154                              svc_counter_config, "req_qdepth", "reqs");
155         lprocfs_counter_init(svc_stats, PTLRPC_REQACTIVE_CNTR,
156                              svc_counter_config, "req_active", "reqs");
157         lprocfs_counter_init(svc_stats, PTLRPC_TIMEOUT,
158                              svc_counter_config, "adaptive_timeout", "sec");
159         lprocfs_counter_init(svc_stats, PTLRPC_REQBUF_AVAIL_CNTR,
160                              svc_counter_config, "reqbuf_avail", "bufs");
161         for (i = 0; i < LUSTRE_MAX_OPCODES; i++) {
162                 __u32 opcode = ll_rpc_opcode_table[i].opcode;
163                 lprocfs_counter_init(svc_stats, PTLRPC_LAST_CNTR + i,
164                                      svc_counter_config, ll_opcode2str(opcode),
165                                      "usec");
166         }
167
168         rc = lprocfs_register_stats(svc_procroot, name, svc_stats);
169         if (rc < 0) {
170                 if (dir)
171                         lprocfs_remove(&svc_procroot);
172                 lprocfs_free_stats(&svc_stats);
173         } else {
174                 if (dir)
175                         *procroot_ret = svc_procroot;
176                 *stats_ret = svc_stats;
177         }
178 }
179
180 static int
181 ptlrpc_lprocfs_read_req_history_len(char *page, char **start, off_t off,
182                                     int count, int *eof, void *data)
183 {
184         struct ptlrpc_service *svc = data;
185
186         *eof = 1;
187         return snprintf(page, count, "%d\n", svc->srv_n_history_rqbds);
188 }
189
190 static int
191 ptlrpc_lprocfs_read_req_history_max(char *page, char **start, off_t off,
192                                     int count, int *eof, void *data)
193 {
194         struct ptlrpc_service *svc = data;
195
196         *eof = 1;
197         return snprintf(page, count, "%d\n", svc->srv_max_history_rqbds);
198 }
199
200 static int
201 ptlrpc_lprocfs_write_req_history_max(struct file *file, const char *buffer,
202                                      unsigned long count, void *data)
203 {
204         struct ptlrpc_service *svc = data;
205         int                    bufpages;
206         int                    val;
207         int                    rc = lprocfs_write_helper(buffer, count, &val);
208
209         if (rc < 0)
210                 return rc;
211
212         if (val < 0)
213                 return -ERANGE;
214
215         /* This sanity check is more of an insanity check; we can still
216          * hose a kernel by allowing the request history to grow too
217          * far. */
218         bufpages = (svc->srv_buf_size + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
219         if (val > num_physpages/(2*bufpages))
220                 return -ERANGE;
221
222         spin_lock(&svc->srv_lock);
223         svc->srv_max_history_rqbds = val;
224         spin_unlock(&svc->srv_lock);
225
226         return count;
227 }
228
229 struct ptlrpc_srh_iterator {
230         __u64                  srhi_seq;
231         struct ptlrpc_request *srhi_req;
232 };
233
234 int
235 ptlrpc_lprocfs_svc_req_history_seek(struct ptlrpc_service *svc,
236                                     struct ptlrpc_srh_iterator *srhi,
237                                     __u64 seq)
238 {
239         struct list_head      *e;
240         struct ptlrpc_request *req;
241
242         if (srhi->srhi_req != NULL &&
243             srhi->srhi_seq > svc->srv_request_max_cull_seq &&
244             srhi->srhi_seq <= seq) {
245                 /* If srhi_req was set previously, hasn't been culled and
246                  * we're searching for a seq on or after it (i.e. more
247                  * recent), search from it onwards.
248                  * Since the service history is LRU (i.e. culled reqs will
249                  * be near the head), we shouldn't have to do long
250                  * re-scans */
251                 LASSERT (srhi->srhi_seq == srhi->srhi_req->rq_history_seq);
252                 LASSERT (!list_empty(&svc->srv_request_history));
253                 e = &srhi->srhi_req->rq_history_list;
254         } else {
255                 /* search from start */
256                 e = svc->srv_request_history.next;
257         }
258
259         while (e != &svc->srv_request_history) {
260                 req = list_entry(e, struct ptlrpc_request, rq_history_list);
261
262                 if (req->rq_history_seq >= seq) {
263                         srhi->srhi_seq = req->rq_history_seq;
264                         srhi->srhi_req = req;
265                         return 0;
266                 }
267                 e = e->next;
268         }
269
270         return -ENOENT;
271 }
272
273 static void *
274 ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
275 {
276         struct ptlrpc_service       *svc = s->private;
277         struct ptlrpc_srh_iterator  *srhi;
278         int                          rc;
279
280         OBD_ALLOC(srhi, sizeof(*srhi));
281         if (srhi == NULL)
282                 return NULL;
283
284         srhi->srhi_seq = 0;
285         srhi->srhi_req = NULL;
286
287         spin_lock(&svc->srv_lock);
288         rc = ptlrpc_lprocfs_svc_req_history_seek(svc, srhi, *pos);
289         spin_unlock(&svc->srv_lock);
290
291         if (rc == 0) {
292                 *pos = srhi->srhi_seq;
293                 return srhi;
294         }
295
296         OBD_FREE(srhi, sizeof(*srhi));
297         return NULL;
298 }
299
300 static void
301 ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter)
302 {
303         struct ptlrpc_srh_iterator *srhi = iter;
304
305         if (srhi != NULL)
306                 OBD_FREE(srhi, sizeof(*srhi));
307 }
308
309 static void *
310 ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
311                                     void *iter, loff_t *pos)
312 {
313         struct ptlrpc_service       *svc = s->private;
314         struct ptlrpc_srh_iterator  *srhi = iter;
315         int                          rc;
316
317         spin_lock(&svc->srv_lock);
318         rc = ptlrpc_lprocfs_svc_req_history_seek(svc, srhi, *pos + 1);
319         spin_unlock(&svc->srv_lock);
320
321         if (rc != 0) {
322                 OBD_FREE(srhi, sizeof(*srhi));
323                 return NULL;
324         }
325
326         *pos = srhi->srhi_seq;
327         return srhi;
328 }
329
330 /* common ost/mdt srv_request_history_print_fn */
331 void target_print_req(void *seq_file, struct ptlrpc_request *req)
332 {
333         /* Called holding srv_lock with irqs disabled.
334          * Print specific req contents and a newline.
335          * CAVEAT EMPTOR: check request message length before printing!!!
336          * You might have received any old crap so you must be just as
337          * careful here as the service's request parser!!! */
338         struct seq_file *sf = seq_file;
339
340         switch (req->rq_phase) {
341         case RQ_PHASE_NEW:
342                 /* still awaiting a service thread's attention, or rejected
343                  * because the generic request message didn't unpack */
344                 seq_printf(sf, "<not swabbed>\n");
345                 break;
346         case RQ_PHASE_INTERPRET:
347                 /* being handled, so basic msg swabbed, and opc is valid
348                  * but racing with mds_handle() */
349         case RQ_PHASE_COMPLETE:
350                 /* been handled by mds_handle() reply state possibly still
351                  * volatile */
352                 seq_printf(sf, "opc %d\n", lustre_msg_get_opc(req->rq_reqmsg));
353                 break;
354         default:
355                 DEBUG_REQ(D_ERROR, req, "bad phase %d", req->rq_phase);
356         }
357 }
358 EXPORT_SYMBOL(target_print_req);
359
360 static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter)
361 {
362         struct ptlrpc_service      *svc = s->private;
363         struct ptlrpc_srh_iterator *srhi = iter;
364         struct ptlrpc_request      *req;
365         int                         rc;
366
367         spin_lock(&svc->srv_lock);
368
369         rc = ptlrpc_lprocfs_svc_req_history_seek(svc, srhi, srhi->srhi_seq);
370
371         if (rc == 0) {
372                 req = srhi->srhi_req;
373
374                 /* Print common req fields.
375                  * CAVEAT EMPTOR: we're racing with the service handler
376                  * here.  The request could contain any old crap, so you
377                  * must be just as careful as the service's request
378                  * parser. Currently I only print stuff here I know is OK
379                  * to look at coz it was set up in request_in_callback()!!! */
380                 seq_printf(s, LPD64":%s:%s:x"LPD64":%d:%s:%ld:%lds(%+lds) ",
381                            req->rq_history_seq, libcfs_nid2str(req->rq_self), 
382                            libcfs_id2str(req->rq_peer), req->rq_xid, 
383                            req->rq_reqlen, ptlrpc_rqphase2str(req),
384                            req->rq_arrival_time.tv_sec,
385                            req->rq_sent - req->rq_arrival_time.tv_sec,
386                            req->rq_sent - req->rq_deadline);
387                 if (svc->srv_request_history_print_fn == NULL)
388                         seq_printf(s, "\n");
389                 else
390                         svc->srv_request_history_print_fn(s, srhi->srhi_req);
391         }
392
393         spin_unlock(&svc->srv_lock);
394
395         return rc;
396 }
397
398 static int
399 ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file)
400 {
401         static struct seq_operations sops = {
402                 .start = ptlrpc_lprocfs_svc_req_history_start,
403                 .stop  = ptlrpc_lprocfs_svc_req_history_stop,
404                 .next  = ptlrpc_lprocfs_svc_req_history_next,
405                 .show  = ptlrpc_lprocfs_svc_req_history_show,
406         };
407         struct proc_dir_entry *dp = PDE(inode);
408         struct seq_file       *seqf;
409         int                    rc;
410
411         LPROCFS_ENTRY_AND_CHECK(dp);
412         rc = seq_open(file, &sops);
413         if (rc) {
414                 LPROCFS_EXIT();
415                 return rc;
416         }
417
418         seqf = file->private_data;
419         seqf->private = dp->data;
420         return 0;
421 }
422
423 /* See also lprocfs_rd_timeouts */
424 static int ptlrpc_lprocfs_rd_timeouts(char *page, char **start, off_t off,
425                                       int count, int *eof, void *data)
426 {
427         struct ptlrpc_service *svc = data;
428         unsigned int cur, worst;
429         time_t worstt;
430         struct dhms ts;
431         int rc = 0;
432
433         *eof = 1;
434         cur = at_get(&svc->srv_at_estimate);
435         worst = svc->srv_at_estimate.at_worst_ever;
436         worstt = svc->srv_at_estimate.at_worst_time;
437         s2dhms(&ts, cfs_time_current_sec() - worstt);
438         if (AT_OFF)
439                 rc += snprintf(page + rc, count - rc,
440                               "adaptive timeouts off, using obd_timeout %u\n",
441                               obd_timeout);
442         rc += snprintf(page + rc, count - rc, 
443                        "%10s : cur %3u  worst %3u (at %ld, "DHMS_FMT" ago) ",
444                        "service", cur, worst, worstt, 
445                        DHMS_VARS(&ts));
446         rc = lprocfs_at_hist_helper(page, count, rc,
447                                     &svc->srv_at_estimate);
448         return rc;
449 }               
450
451 void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
452                                      struct ptlrpc_service *svc)
453 {
454         struct lprocfs_vars lproc_vars[] = {
455                 {.name       = "req_buffer_history_len",
456                  .write_fptr = NULL,
457                  .read_fptr  = ptlrpc_lprocfs_read_req_history_len,
458                  .data       = svc},
459                 {.name       = "req_buffer_history_max",
460                  .write_fptr = ptlrpc_lprocfs_write_req_history_max,
461                  .read_fptr  = ptlrpc_lprocfs_read_req_history_max,
462                  .data       = svc},
463                 {.name       = "timeouts",
464                  .read_fptr  = ptlrpc_lprocfs_rd_timeouts,
465                  .data       = svc},
466                 {NULL}
467         };
468         static struct file_operations req_history_fops = {
469                 .owner       = THIS_MODULE,
470                 .open        = ptlrpc_lprocfs_svc_req_history_open,
471                 .read        = seq_read,
472                 .llseek      = seq_lseek,
473                 .release     = lprocfs_seq_release,
474         };
475         struct proc_dir_entry *req_history;
476
477         ptlrpc_lprocfs_register(entry, svc->srv_name,
478                                 "stats", &svc->srv_procroot,
479                                 &svc->srv_stats);
480
481         if (svc->srv_procroot == NULL)
482                 return;
483
484         lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL);
485
486         req_history = create_proc_entry("req_history", 0400,
487                                         svc->srv_procroot);
488         if (req_history != NULL) {
489                 req_history->data = svc;
490                 req_history->proc_fops = &req_history_fops;
491         }
492 }
493
494 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
495 {
496         ptlrpc_lprocfs_register(obddev->obd_proc_entry, NULL, "stats",
497                                 &obddev->obd_svc_procroot,
498                                 &obddev->obd_svc_stats);
499 }
500 EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
501
502 void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req)
503 {
504         struct lprocfs_stats *svc_stats;
505         int opc = opcode_offset(lustre_msg_get_opc(req->rq_reqmsg));
506
507         svc_stats = req->rq_import->imp_obd->obd_svc_stats;
508         if (svc_stats == NULL || opc <= 0)
509                 return;
510         LASSERT(opc < LUSTRE_MAX_OPCODES);
511         /* These two use the ptlrpc_lprocfs_brw below */
512         if (!(opc == OST_WRITE || opc == OST_READ))
513                 lprocfs_counter_add(svc_stats, opc + PTLRPC_LAST_CNTR, 0);
514 }
515
516 void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int opc, int bytes)
517 {
518         struct lprocfs_stats *svc_stats;
519         svc_stats = req->rq_import->imp_obd->obd_svc_stats;
520         if (!svc_stats) 
521                 return;
522         lprocfs_counter_add(svc_stats, opc + PTLRPC_LAST_CNTR, bytes);
523 }
524 EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
525
526 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
527 {
528         if (svc->srv_procroot != NULL) 
529                 lprocfs_remove(&svc->srv_procroot);
530         if (svc->srv_stats) 
531                 lprocfs_free_stats(&svc->srv_stats);
532 }
533
534 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
535 {
536         if (obd->obd_svc_procroot)
537                 lprocfs_remove(&obd->obd_svc_procroot);
538         if (obd->obd_svc_stats)
539                 lprocfs_free_stats(&obd->obd_svc_stats);
540 }
541 EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd);
542
543
544 int lprocfs_wr_evict_client(struct file *file, const char *buffer,
545                             unsigned long count, void *data)
546 {
547         struct obd_device *obd = data;
548         char tmpbuf[sizeof(struct obd_uuid)];
549
550         /* Kludge code(deadlock situation): the lprocfs lock has been held 
551          * since the client is evicted by writting client's
552          * uuid/nid to procfs "evict_client" entry. However, 
553          * obd_export_evict_by_uuid() will call lprocfs_remove() to destroy
554          * the proc entries under the being destroyed export{}, so I have
555          * to drop the lock at first here. 
556          * - jay, jxiong@clusterfs.com */
557         class_incref(obd);
558         LPROCFS_EXIT();
559
560         sscanf(buffer, "%40s", tmpbuf);
561         if (strncmp(tmpbuf, "nid:", 4) == 0)
562                 obd_export_evict_by_nid(obd, tmpbuf + 4);
563         else if (strncmp(tmpbuf, "uuid:", 5) == 0)
564                 obd_export_evict_by_uuid(obd, tmpbuf + 5);
565         else
566                 obd_export_evict_by_uuid(obd, tmpbuf);
567
568         LPROCFS_ENTRY();
569         class_decref(obd);
570
571         return count;
572 }
573 EXPORT_SYMBOL(lprocfs_wr_evict_client);
574
575 int lprocfs_wr_ping(struct file *file, const char *buffer,
576                     unsigned long count, void *data)
577 {
578         struct obd_device *obd = data;
579         struct ptlrpc_request *req;
580         int rc;
581         ENTRY;
582
583         LPROCFS_CLIMP_CHECK(obd);
584         req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_OBD_VERSION,
585                               OBD_PING, 1, NULL, NULL);
586         LPROCFS_CLIMP_EXIT(obd);
587         if (req == NULL)
588                 RETURN(-ENOMEM);
589
590         ptlrpc_req_set_repsize(req, 1, NULL);
591         req->rq_send_state = LUSTRE_IMP_FULL;
592         req->rq_no_resend = 1;
593
594         rc = ptlrpc_queue_wait(req);
595
596         ptlrpc_req_finished(req);
597         if (rc >= 0)
598                 RETURN(count);
599         RETURN(rc);
600 }
601 EXPORT_SYMBOL(lprocfs_wr_ping);
602
603 #endif /* LPROCFS */