Whamcloud - gitweb
LU-7243 misc: update Intel copyright messages 2015
[fs/lustre-release.git] / lustre / osp / lproc_osp.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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 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  * lustre/osp/lproc_osp.c
33  *
34  * Lustre OST Proxy Device (OSP), procfs functions
35  *
36  * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
37  */
38
39 #define DEBUG_SUBSYSTEM S_CLASS
40
41 #include "osp_internal.h"
42
43 #ifdef CONFIG_PROC_FS
44 /**
45  * Show OSP active status
46  *
47  * \param[in] m         seq_file handle
48  * \param[in] data      unused for single entry
49  * \retval              0 on success
50  * \retval              negative number on error
51  */
52 static int osp_active_seq_show(struct seq_file *m, void *data)
53 {
54         struct obd_device       *dev = m->private;
55         int                      rc;
56
57         LPROCFS_CLIMP_CHECK(dev);
58         rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
59         LPROCFS_CLIMP_EXIT(dev);
60         return rc;
61 }
62
63 /**
64  * Activate/Deactivate OSP
65  *
66  * \param[in] file      proc file
67  * \param[in] buffer    string, which is "1" or "0" to activate/deactivate OSP
68  * \param[in] count     \a buffer length
69  * \param[in] off       unused for single entry
70  * \retval              \a count on success
71  * \retval              negative number on error
72  */
73 static ssize_t
74 osp_active_seq_write(struct file *file, const char *buffer,
75                         size_t count, loff_t *off)
76 {
77         struct seq_file   *m = file->private_data;
78         struct obd_device *dev = m->private;
79         int                val, rc;
80
81         rc = lprocfs_write_helper(buffer, count, &val);
82         if (rc)
83                 return rc;
84         if (val < 0 || val > 1)
85                 return -ERANGE;
86
87         LPROCFS_CLIMP_CHECK(dev);
88         /* opposite senses */
89         if (dev->u.cli.cl_import->imp_deactive == val)
90                 rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
91         else
92                 CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n",
93                        val);
94
95         LPROCFS_CLIMP_EXIT(dev);
96         return count;
97 }
98 LPROC_SEQ_FOPS(osp_active);
99
100 /**
101  * Show number of RPCs in flight
102  *
103  * \param[in] m         seq_file handle
104  * \param[in] data      unused for single entry
105  * \retval              0 on success
106  * \retval              negative number on error
107  */
108 static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
109 {
110         struct obd_device       *dev = m->private;
111         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
112
113         if (osp == NULL)
114                 return -EINVAL;
115
116         return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight);
117 }
118 LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
119
120 /**
121  * Show number of RPCs in processing (including uncommitted by OST)
122  *
123  * \param[in] m         seq_file handle
124  * \param[in] data      unused for single entry
125  * \retval              0 on success
126  * \retval              negative number on error
127  */
128 static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
129 {
130         struct obd_device       *dev = m->private;
131         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
132
133         if (osp == NULL)
134                 return -EINVAL;
135
136         return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress);
137 }
138 LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
139
140 /**
141  * Show number of changes to sync
142  *
143  * \param[in] m         seq_file handle
144  * \param[in] data      unused for single entry
145  * \retval              0 on success
146  * \retval              negative number on error
147  */
148 static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
149 {
150         struct obd_device       *dev = m->private;
151         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
152
153         if (osp == NULL)
154                 return -EINVAL;
155
156         return seq_printf(m, "%lu\n", osp->opd_syn_changes);
157 }
158
159 /**
160  * Sync changes
161  *
162  * \param[in] file      proc file
163  * \param[in] buffer    unused because any input will do
164  * \param[in] count     \a buffer length
165  * \param[in] off       unused for single entry
166  * \retval              \a count on success
167  * \retval              negative number on error
168  */
169 static ssize_t osp_syn_changes_seq_write(struct file *file, const char *buffer,
170                                          size_t count, loff_t *off)
171 {
172         struct seq_file         *m      = file->private_data;
173         struct obd_device       *dev    = m->private;
174         struct osp_device       *osp    = lu2osp_dev(dev->obd_lu_dev);
175         struct lu_env            env;
176         int                      rc;
177
178         rc = lu_env_init(&env, LCT_LOCAL);
179         if (rc != 0)
180                 return rc;
181
182         rc = dt_sync(&env, &osp->opd_dt_dev);
183         lu_env_fini(&env);
184
185         return rc == 0 ? count : rc;
186 }
187 LPROC_SEQ_FOPS(osp_syn_changes);
188
189 /**
190  * Show maximum number of RPCs in flight allowed
191  *
192  * \param[in] m         seq_file handle
193  * \param[in] data      unused for single entry
194  * \retval              0 on success
195  * \retval              negative number on error
196  */
197 static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
198 {
199         struct obd_device       *dev = m->private;
200         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
201
202         if (osp == NULL)
203                 return -EINVAL;
204
205         return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
206 }
207
208 /**
209  * Change maximum number of RPCs in flight allowed
210  *
211  * \param[in] file      proc file
212  * \param[in] buffer    string which represents maximum number
213  * \param[in] count     \a buffer length
214  * \param[in] off       unused for single entry
215  * \retval              \a count on success
216  * \retval              negative number on error
217  */
218 static ssize_t
219 osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
220                                 size_t count, loff_t *off)
221 {
222         struct seq_file         *m = file->private_data;
223         struct obd_device       *dev = m->private;
224         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
225         int                      val, rc;
226
227         if (osp == NULL)
228                 return -EINVAL;
229
230         rc = lprocfs_write_helper(buffer, count, &val);
231         if (rc)
232                 return rc;
233
234         if (val < 1)
235                 return -ERANGE;
236
237         osp->opd_syn_max_rpc_in_flight = val;
238         return count;
239 }
240 LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
241
242 /**
243  * Show maximum number of RPCs in processing allowed
244  *
245  * \param[in] m         seq_file handle
246  * \param[in] data      unused
247  * \retval              0 on success
248  * \retval              negative number on error
249  */
250 static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
251 {
252         struct obd_device       *dev = m->private;
253         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
254
255         if (osp == NULL)
256                 return -EINVAL;
257
258         return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
259 }
260
261 /**
262  * Change maximum number of RPCs in processing allowed
263  *
264  * \param[in] file      proc file
265  * \param[in] buffer    string which represents maximum number
266  * \param[in] count     \a buffer length
267  * \param[in] off       unused for single entry
268  * \retval              \a count on success
269  * \retval              negative number on error
270  */
271 static ssize_t
272 osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer,
273                                 size_t count, loff_t *off)
274 {
275         struct seq_file         *m = file->private_data;
276         struct obd_device       *dev = m->private;
277         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
278         int                      val, rc;
279
280         if (osp == NULL)
281                 return -EINVAL;
282
283         rc = lprocfs_write_helper(buffer, count, &val);
284         if (rc)
285                 return rc;
286
287         if (val < 1)
288                 return -ERANGE;
289
290         osp->opd_syn_max_rpc_in_progress = val;
291
292         return count;
293 }
294 LPROC_SEQ_FOPS(osp_max_rpcs_in_prog);
295
296 /**
297  * Show number of objects to precreate next time
298  *
299  * \param[in] m         seq_file handle
300  * \param[in] data      unused for single entry
301  * \retval              0 on success
302  * \retval              negative number on error
303  */
304 static int osp_create_count_seq_show(struct seq_file *m, void *data)
305 {
306         struct obd_device *obd = m->private;
307         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
308
309         if (osp == NULL || osp->opd_pre == NULL)
310                 return 0;
311
312         return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
313 }
314
315 /**
316  * Change number of objects to precreate next time
317  *
318  * \param[in] file      proc file
319  * \param[in] buffer    string which represents number of objects to precreate
320  * \param[in] count     \a buffer length
321  * \param[in] off       unused for single entry
322  * \retval              \a count on success
323  * \retval              negative number on error
324  */
325 static ssize_t
326 osp_create_count_seq_write(struct file *file, const char *buffer,
327                                 size_t count, loff_t *off)
328 {
329         struct seq_file         *m = file->private_data;
330         struct obd_device       *obd = m->private;
331         struct osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
332         int                      val, rc, i;
333
334         if (osp == NULL || osp->opd_pre == NULL)
335                 return 0;
336
337         rc = lprocfs_write_helper(buffer, count, &val);
338         if (rc)
339                 return rc;
340
341         /* The MDT ALWAYS needs to limit the precreate count to
342          * OST_MAX_PRECREATE, and the constant cannot be changed
343          * because it is a value shared between the OSP and OST
344          * that is the maximum possible number of objects that will
345          * ever be handled by MDT->OST recovery processing.
346          *
347          * If the OST ever gets a request to delete more orphans,
348          * this implies that something has gone badly on the MDT
349          * and the OST will refuse to delete so much data from the
350          * filesystem as a safety measure. */
351         if (val < OST_MIN_PRECREATE || val > OST_MAX_PRECREATE)
352                 return -ERANGE;
353         if (val > osp->opd_pre_max_grow_count)
354                 return -ERANGE;
355
356         for (i = 1; (i << 1) <= val; i <<= 1)
357                 ;
358         osp->opd_pre_grow_count = i;
359
360         return count;
361 }
362 LPROC_SEQ_FOPS(osp_create_count);
363
364 /**
365  * Show maximum number of objects to precreate
366  *
367  * \param[in] m         seq_file handle
368  * \param[in] data      unused for single entry
369  * \retval              0 on success
370  * \retval              negative number on error
371  */
372 static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
373 {
374         struct obd_device *obd = m->private;
375         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
376
377         if (osp == NULL || osp->opd_pre == NULL)
378                 return 0;
379
380         return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
381 }
382
383 /**
384  * Change maximum number of objects to precreate
385  *
386  * \param[in] file      proc file
387  * \param[in] buffer    string which represents maximum number
388  * \param[in] count     \a buffer length
389  * \param[in] off       unused for single entry
390  * \retval              \a count on success
391  * \retval              negative number on error
392  */
393 static ssize_t
394 osp_max_create_count_seq_write(struct file *file, const char *buffer,
395                                 size_t count, loff_t *off)
396 {
397         struct seq_file         *m = file->private_data;
398         struct obd_device       *obd = m->private;
399         struct osp_device       *osp = lu2osp_dev(obd->obd_lu_dev);
400         int                      val, rc;
401
402         if (osp == NULL || osp->opd_pre == NULL)
403                 return 0;
404
405         rc = lprocfs_write_helper(buffer, count, &val);
406         if (rc)
407                 return rc;
408
409         if (val < 0)
410                 return -ERANGE;
411         if (val > OST_MAX_PRECREATE)
412                 return -ERANGE;
413
414         if (osp->opd_pre_grow_count > val)
415                 osp->opd_pre_grow_count = val;
416
417         osp->opd_pre_max_grow_count = val;
418
419         return count;
420 }
421 LPROC_SEQ_FOPS(osp_max_create_count);
422
423 /**
424  * Show last id to assign in creation
425  *
426  * \param[in] m         seq_file handle
427  * \param[in] data      unused for single entry
428  * \retval              0 on success
429  * \retval              negative number on error
430  */
431 static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
432 {
433         struct obd_device *obd = m->private;
434         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
435
436         if (osp == NULL || osp->opd_pre == NULL)
437                 return 0;
438
439         return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
440 }
441 LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
442
443 /**
444  * Show last created id OST reported
445  *
446  * \param[in] m         seq_file handle
447  * \param[in] data      unused for single entry
448  * \retval              0 on success
449  * \retval              negative number on error
450  */
451 static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
452 {
453         struct obd_device *obd = m->private;
454         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
455
456         if (osp == NULL || osp->opd_pre == NULL)
457                 return 0;
458
459         return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
460 }
461 LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
462
463 /**
464  * Show next FID sequence to precreate
465  *
466  * \param[in] m         seq_file handle
467  * \param[in] data      unused for single entry
468  * \retval              0 on success
469  * \retval              negative number on error
470  */
471 static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
472 {
473         struct obd_device *obd = m->private;
474         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
475
476         if (osp == NULL || osp->opd_pre == NULL)
477                 return 0;
478
479         return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
480 }
481 LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
482
483 /**
484  * Show last created FID sequence OST reported
485  *
486  * \param[in] m         seq_file handle
487  * \param[in] data      unused for single entry
488  * \retval              0 on success
489  * \retval              negative number on error
490  */
491 static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
492 {
493         struct obd_device *obd = m->private;
494         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
495
496         if (osp == NULL || osp->opd_pre == NULL)
497                 return 0;
498
499         return seq_printf(m, LPX64"\n",
500                         fid_seq(&osp->opd_pre_last_created_fid));
501 }
502 LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
503
504 /**
505  * Show the number of ids reserved by declare
506  *
507  * \param[in] m         seq_file handle
508  * \param[in] data      unused for single entry
509  * \retval              0 on success
510  * \retval              negative number on error
511  */
512 static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
513 {
514         struct obd_device *obd = m->private;
515         struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
516
517         if (osp == NULL || osp->opd_pre == NULL)
518                 return 0;
519
520         return seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
521 }
522 LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
523
524 /**
525  * Show interval (in seconds) to update statfs data
526  *
527  * \param[in] m         seq_file handle
528  * \param[in] data      unused for single entry
529  * \retval              0 on success
530  * \retval              negative number on error
531  */
532 static int osp_maxage_seq_show(struct seq_file *m, void *data)
533 {
534         struct obd_device       *dev = m->private;
535         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
536
537         if (osp == NULL)
538                 return -EINVAL;
539
540         return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
541 }
542
543 /**
544  * Change interval to update statfs data
545  *
546  * \param[in] file      proc file
547  * \param[in] buffer    string which represents statfs interval (in seconds)
548  * \param[in] count     \a buffer length
549  * \param[in] off       unused for single entry
550  * \retval              \a count on success
551  * \retval              negative number on error
552  */
553 static ssize_t
554 osp_maxage_seq_write(struct file *file, const char *buffer,
555                         size_t count, loff_t *off)
556 {
557         struct seq_file         *m = file->private_data;
558         struct obd_device       *dev = m->private;
559         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
560         int                      val, rc;
561
562         if (osp == NULL)
563                 return -EINVAL;
564
565         rc = lprocfs_write_helper(buffer, count, &val);
566         if (rc)
567                 return rc;
568
569         if (val < 1)
570                 return -ERANGE;
571
572         osp->opd_statfs_maxage = val;
573
574         return count;
575 }
576 LPROC_SEQ_FOPS(osp_maxage);
577
578 /**
579  * Show current precreation status: output 0 means success, otherwise negative
580  * number is printed
581  *
582  * \param[in] m         seq_file handle
583  * \param[in] data      unused for single entry
584  * \retval              0 on success
585  * \retval              negative number on error
586  */
587 static int osp_pre_status_seq_show(struct seq_file *m, void *data)
588 {
589         struct obd_device       *dev = m->private;
590         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
591
592         if (osp == NULL || osp->opd_pre == NULL)
593                 return -EINVAL;
594
595         return seq_printf(m, "%d\n", osp->opd_pre_status);
596 }
597 LPROC_SEQ_FOPS_RO(osp_pre_status);
598
599 /**
600  * Show the number of RPCs in processing (including uncommitted by OST) plus
601  * changes to sync, i.e. this is the total number of changes OST needs to apply
602  * and commit.
603  *
604  * This counter is used to determine if OST has space returned. A zero value
605  * indicates that OST storage space consumed by destroyed objects has been freed
606  * on disk, the associated llog records have been cleared, and no synchronous
607  * RPC are being processed.
608  *
609  * \param[in] m         seq_file handle
610  * \param[in] data      unused for single entry
611  * \retval              0 on success
612  * \retval              negative number on error
613  */
614 static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
615 {
616         struct obd_device *dev = m->private;
617         struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
618
619         if (osp == NULL)
620                 return -EINVAL;
621
622         return seq_printf(m, "%lu\n",
623                           osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
624 }
625 LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
626
627 /**
628  * Show changes synced from previous mount
629  *
630  * \param[in] m         seq_file handle
631  * \param[in] data      unused for single entry
632  * \retval              0 on success
633  * \retval              negative number on error
634  */
635 static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
636 {
637         struct obd_device       *dev = m->private;
638         struct osp_device       *osp = lu2osp_dev(dev->obd_lu_dev);
639
640         if (osp == NULL)
641                 return -EINVAL;
642
643         return seq_printf(m, "%d\n", osp->opd_syn_prev_done);
644 }
645 LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
646
647 /**
648  * Show maximum number of RPCs in flight
649  *
650  * \param[in] m         seq_file handle
651  * \param[in] data      unused for single entry
652  * \retval              0 on success
653  * \retval              negative number on error
654  */
655 static int
656 osp_lfsck_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
657 {
658         struct obd_device *dev = m->private;
659         __u32 max;
660
661         max = obd_get_max_rpcs_in_flight(&dev->u.cli);
662         return seq_printf(m, "%u\n", max);
663 }
664
665 /**
666  * Change maximum number of RPCs in flight
667  *
668  * \param[in] file      proc file
669  * \param[in] buffer    string which represents maximum number of RPCs in flight
670  * \param[in] count     \a buffer length
671  * \param[in] off       unused for single entry
672  * \retval              \a count on success
673  * \retval              negative number on error
674  */
675 static ssize_t
676 osp_lfsck_max_rpcs_in_flight_seq_write(struct file *file,
677                                        const char __user *buffer,
678                                        size_t count, loff_t *off)
679 {
680         struct seq_file   *m = file->private_data;
681         struct obd_device *dev = m->private;
682         int val;
683         int rc;
684
685         rc = lprocfs_write_helper(buffer, count, &val);
686         if (rc == 0)
687                 rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
688
689         if (rc != 0)
690                 count = rc;
691
692         return count;
693 }
694 LPROC_SEQ_FOPS(osp_lfsck_max_rpcs_in_flight);
695
696 LPROC_SEQ_FOPS_WO_TYPE(osp, ping);
697 LPROC_SEQ_FOPS_RO_TYPE(osp, uuid);
698 LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags);
699 LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
700 LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
701
702 /**
703  * Show maximum pages per bulk RPC
704  *
705  * \param[in] m         seq_file handle
706  * \param[in] data      unused for single entry
707  * \retval              0 on success
708  * \retval              negative number on error
709  */
710 static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
711 {
712         return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
713 }
714 LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc);
715 LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
716
717 LPROC_SEQ_FOPS_RW_TYPE(osp, import);
718 LPROC_SEQ_FOPS_RO_TYPE(osp, state);
719
720 static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
721         { .name =       "uuid",
722           .fops =       &osp_uuid_fops                  },
723         { .name =       "ping",
724           .fops =       &osp_ping_fops,
725           .proc_mode =  0222                            },
726         { .name =       "connect_flags",
727           .fops =       &osp_connect_flags_fops         },
728         { .name =       "ost_server_uuid",
729           .fops =       &osp_server_uuid_fops           },
730         { .name =       "ost_conn_uuid",
731           .fops =       &osp_conn_uuid_fops             },
732         { .name =       "active",
733           .fops =       &osp_active_fops                },
734         { .name =       "max_rpcs_in_flight",
735           .fops =       &osp_max_rpcs_in_flight_fops    },
736         { .name =       "max_rpcs_in_progress",
737           .fops =       &osp_max_rpcs_in_prog_fops      },
738         { .name =       "create_count",
739           .fops =       &osp_create_count_fops          },
740         { .name =       "max_create_count",
741           .fops =       &osp_max_create_count_fops      },
742         { .name =       "prealloc_next_id",
743           .fops =       &osp_prealloc_next_id_fops      },
744         { .name =       "prealloc_next_seq",
745           .fops =       &osp_prealloc_next_seq_fops     },
746         { .name =       "prealloc_last_id",
747           .fops =       &osp_prealloc_last_id_fops      },
748         { .name =       "prealloc_last_seq",
749           .fops =       &osp_prealloc_last_seq_fops     },
750         { .name =       "prealloc_reserved",
751           .fops =       &osp_prealloc_reserved_fops     },
752         { .name =       "timeouts",
753           .fops =       &osp_timeouts_fops              },
754         { .name =       "import",
755           .fops =       &osp_import_fops                },
756         { .name =       "state",
757           .fops =       &osp_state_fops                 },
758         { .name =       "maxage",
759           .fops =       &osp_maxage_fops                },
760         { .name =       "prealloc_status",
761           .fops =       &osp_pre_status_fops            },
762         { .name =       "sync_changes",
763           .fops =       &osp_syn_changes_fops           },
764         { .name =       "sync_in_flight",
765           .fops =       &osp_syn_in_flight_fops         },
766         { .name =       "sync_in_progress",
767           .fops =       &osp_syn_in_prog_fops           },
768         { .name =       "old_sync_processed",
769           .fops =       &osp_old_sync_processed_fops    },
770
771         /* for compatibility reasons */
772         { .name =       "destroys_in_flight",
773           .fops =       &osp_destroys_in_flight_fops            },
774         { .name =       "lfsck_max_rpcs_in_flight",
775           .fops =       &osp_lfsck_max_rpcs_in_flight_fops      },
776         { NULL }
777 };
778
779 static struct lprocfs_vars lprocfs_osp_md_vars[] = {
780         { .name =       "uuid",
781           .fops =       &osp_uuid_fops                  },
782         { .name =       "ping",
783           .fops =       &osp_ping_fops,
784           .proc_mode =  0222                            },
785         { .name =       "connect_flags",
786           .fops =       &osp_connect_flags_fops         },
787         { .name =       "mdt_server_uuid",
788           .fops =       &osp_server_uuid_fops           },
789         { .name =       "mdt_conn_uuid",
790           .fops =       &osp_conn_uuid_fops             },
791         { .name =       "active",
792           .fops =       &osp_active_fops                },
793         { .name =       "max_rpcs_in_flight",
794           .fops =       &osp_max_rpcs_in_flight_fops    },
795         { .name =       "max_rpcs_in_progress",
796           .fops =       &osp_max_rpcs_in_prog_fops      },
797         { .name =       "timeouts",
798           .fops =       &osp_timeouts_fops              },
799         { .name =       "import",
800           .fops =       &osp_import_fops                },
801         { .name =       "state",
802           .fops =       &osp_state_fops                 },
803         { .name =       "maxage",
804           .fops =       &osp_maxage_fops                },
805         { .name =       "prealloc_status",
806           .fops =       &osp_pre_status_fops            },
807
808         /* for compatibility reasons */
809         { .name =       "destroys_in_flight",
810           .fops =       &osp_destroys_in_flight_fops            },
811         { .name =       "lfsck_max_rpcs_in_flight",
812           .fops =       &osp_lfsck_max_rpcs_in_flight_fops      },
813         { NULL }
814 };
815
816 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize);
817 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytestotal);
818 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesfree);
819 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail);
820 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal);
821 LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree);
822
823 static struct lprocfs_vars lprocfs_osp_osd_vars[] = {
824         { .name =       "blocksize",
825           .fops =       &osp_dt_blksize_fops            },
826         { .name =       "kbytestotal",
827           .fops =       &osp_dt_kbytestotal_fops        },
828         { .name =       "kbytesfree",
829           .fops =       &osp_dt_kbytesfree_fops         },
830         { .name =       "kbytesavail",
831           .fops =       &osp_dt_kbytesavail_fops        },
832         { .name =       "filestotal",
833           .fops =       &osp_dt_filestotal_fops         },
834         { .name =       "filesfree",
835           .fops =       &osp_dt_filesfree_fops          },
836         { NULL }
837 };
838
839 /**
840  * Initialize OSP lprocfs
841  *
842  * param[in] osp        OSP device
843  */
844 void osp_lprocfs_init(struct osp_device *osp)
845 {
846         struct obd_device       *obd = osp->opd_obd;
847         struct proc_dir_entry   *osc_proc_dir = NULL;
848         struct obd_type         *type;
849         int                      rc;
850
851         if (osp->opd_connect_mdt)
852                 obd->obd_vars = lprocfs_osp_md_vars;
853         else
854                 obd->obd_vars = lprocfs_osp_obd_vars;
855         if (lprocfs_obd_setup(obd) != 0)
856                 return;
857
858         rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_osd_vars,
859                               &osp->opd_dt_dev);
860         if (rc) {
861                 CERROR("%s: can't register in lprocfs, rc %d\n",
862                        obd->obd_name, rc);
863                 return;
864         }
865
866         sptlrpc_lprocfs_cliobd_attach(obd);
867         ptlrpc_lprocfs_register_obd(obd);
868
869         if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc"))
870                 return;
871
872         /* If the real OSC is present which is the case for setups
873          * with both server and clients on the same node then use
874          * the OSC's proc root */
875         type = class_search_type(LUSTRE_OSC_NAME);
876         if (type != NULL && type->typ_procroot != NULL)
877                 osc_proc_dir = type->typ_procroot;
878         else
879                 osc_proc_dir = obd->obd_type->typ_procsym;
880
881         if (osc_proc_dir == NULL)
882                 return;
883
884         /* for compatibility we link old procfs's OSC entries to osp ones */
885         osp->opd_symlink = lprocfs_add_symlink(obd->obd_name, osc_proc_dir,
886                                                "../osp/%s", obd->obd_name);
887         if (osp->opd_symlink == NULL)
888                 CERROR("cannot create OSC symlink for /proc/fs/lustre/osp/%s\n",
889                        obd->obd_name);
890 }
891
892 #endif /* CONFIG_PROC_FS */
893