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