aboutsummaryrefslogtreecommitdiff
blob: 7734600caf8e6e861bda1d1f0c59d83cac2e0cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
From cfafe91ff9caf648f144c1a162112b7d1485aae4 Mon Sep 17 00:00:00 2001
From: James Simmons <uja.ornl@gmail.com>
Date: Sun, 9 Feb 2014 17:10:18 -0500
Subject: [PATCH 05/12] LU-3319 procfs: move osp proc handling to seq_files

With 3.10 linux kernel and above proc handling now only
uses struct seq_files. This patch migrates the osp
layer proc entries over to using seq_files.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Id8f77d72fd35755f1b7b1c17fcf27e0731bd5ac1
---
 lustre/osp/lproc_osp.c    | 373 ++++++++++++++++++++++++----------------------
 lustre/osp/lwp_dev.c      |  18 +--
 lustre/osp/osp_dev.c      |  48 +++---
 lustre/osp/osp_internal.h |   2 -
 4 files changed, 222 insertions(+), 219 deletions(-)

diff --git a/lustre/osp/lproc_osp.c b/lustre/osp/lproc_osp.c
index 75ebeb1..1ec40fc 100644
--- a/lustre/osp/lproc_osp.c
+++ b/lustre/osp/lproc_osp.c
@@ -45,24 +45,23 @@
 #include "osp_internal.h"
 
 #ifdef LPROCFS
-static int osp_rd_active(char *page, char **start, off_t off,
-			 int count, int *eof, void *data)
+static int osp_active_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	int			 rc;
 
 	LPROCFS_CLIMP_CHECK(dev);
-	rc = snprintf(page, count, "%d\n",
-		      !dev->u.cli.cl_import->imp_deactive);
+	rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
 	LPROCFS_CLIMP_EXIT(dev);
 	return rc;
 }
 
-static int osp_wr_active(struct file *file, const char *buffer,
-			 unsigned long count, void *data)
+static ssize_t
+osp_active_seq_write(struct file *file, const char *buffer,
+			size_t count, loff_t *off)
 {
-	struct obd_device	*dev = data;
-	int			 val, rc;
+	struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+	int		   val, rc;
 
 	rc = lprocfs_write_helper(buffer, count, &val);
 	if (rc)
@@ -81,67 +80,60 @@ static int osp_wr_active(struct file *file, const char *buffer,
 	LPROCFS_CLIMP_EXIT(dev);
 	return count;
 }
+LPROC_SEQ_FOPS(osp_active);
 
-static int osp_rd_syn_in_flight(char *page, char **start, off_t off,
-				int count, int *eof, void *data)
+static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_flight);
-	return rc;
+	return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight);
 }
+LPROC_SEQ_FOPS_RO(osp_syn_in_flight);
 
-static int osp_rd_syn_in_prog(char *page, char **start, off_t off, int count,
-			      int *eof, void *data)
+static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_progress);
-	return rc;
+	return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress);
 }
+LPROC_SEQ_FOPS_RO(osp_syn_in_prog);
 
-static int osp_rd_syn_changes(char *page, char **start, off_t off,
-			      int count, int *eof, void *data)
+static int osp_syn_changes_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%lu\n", osp->opd_syn_changes);
-	return rc;
+	return seq_printf(m, "%lu\n", osp->opd_syn_changes);
 }
+LPROC_SEQ_FOPS_RO(osp_syn_changes);
 
-static int osp_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
-				     int count, int *eof, void *data)
+static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_flight);
-	return rc;
+	return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight);
 }
 
-static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
-				     unsigned long count, void *data)
+static ssize_t
+osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer,
+				size_t count, loff_t *off)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = ((struct seq_file *)file->private_data)->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
 	int			 val, rc;
 
@@ -158,25 +150,24 @@ static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
 	osp->opd_syn_max_rpc_in_flight = val;
 	return count;
 }
+LPROC_SEQ_FOPS(osp_max_rpcs_in_flight);
 
-static int osp_rd_max_rpcs_in_prog(char *page, char **start, off_t off,
-				   int count, int *eof, void *data)
+static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_progress);
-	return rc;
+	return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress);
 }
 
-static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer,
-				   unsigned long count, void *data)
+static ssize_t
+osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer,
+				size_t count, loff_t *off)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = ((struct seq_file *)file->private_data)->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
 	int			 val, rc;
 
@@ -194,23 +185,24 @@ static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer,
 
 	return count;
 }
+LPROC_SEQ_FOPS(osp_max_rpcs_in_prog);
 
-static int osp_rd_create_count(char *page, char **start, off_t off, int count,
-			       int *eof, void *data)
+static int osp_create_count_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, "%d\n", osp->opd_pre_grow_count);
+	return seq_printf(m, "%d\n", osp->opd_pre_grow_count);
 }
 
-static int osp_wr_create_count(struct file *file, const char *buffer,
-			       unsigned long count, void *data)
+static ssize_t
+osp_create_count_seq_write(struct file *file, const char *buffer,
+				size_t count, loff_t *off)
 {
-	struct obd_device	*obd = data;
+	struct obd_device	*obd = ((struct seq_file *)file->private_data)->private;
 	struct osp_device	*osp = lu2osp_dev(obd->obd_lu_dev);
 	int			 val, rc, i;
 
@@ -242,23 +234,24 @@ static int osp_wr_create_count(struct file *file, const char *buffer,
 
 	return count;
 }
+LPROC_SEQ_FOPS(osp_create_count);
 
-static int osp_rd_max_create_count(char *page, char **start, off_t off,
-				   int count, int *eof, void *data)
+static int osp_max_create_count_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, "%d\n", osp->opd_pre_max_grow_count);
+	return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count);
 }
 
-static int osp_wr_max_create_count(struct file *file, const char *buffer,
-				   unsigned long count, void *data)
+static ssize_t
+osp_max_create_count_seq_write(struct file *file, const char *buffer,
+				size_t count, loff_t *off)
 {
-	struct obd_device	*obd = data;
+	struct obd_device	*obd = ((struct seq_file *)file->private_data)->private;
 	struct osp_device	*osp = lu2osp_dev(obd->obd_lu_dev);
 	int			 val, rc;
 
@@ -281,89 +274,85 @@ static int osp_wr_max_create_count(struct file *file, const char *buffer,
 
 	return count;
 }
+LPROC_SEQ_FOPS(osp_max_create_count);
 
-static int osp_rd_prealloc_next_id(char *page, char **start, off_t off,
-				   int count, int *eof, void *data)
+static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, "%u\n",
-			fid_oid(&osp->opd_pre_used_fid) + 1);
+	return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
 }
+LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
 
-static int osp_rd_prealloc_last_id(char *page, char **start, off_t off,
-				   int count, int *eof, void *data)
+static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, "%u\n",
-			fid_oid(&osp->opd_pre_last_created_fid));
+	return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
 }
+LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
 
-static int osp_rd_prealloc_next_seq(char *page, char **start, off_t off,
-				    int count, int *eof, void *data)
+static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, LPX64"\n",
-			fid_seq(&osp->opd_pre_used_fid));
+	return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid));
 }
+LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
 
-static int osp_rd_prealloc_last_seq(char *page, char **start, off_t off,
-				    int count, int *eof, void *data)
+static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, LPX64"\n",
+	return seq_printf(m, LPX64"\n",
 			fid_seq(&osp->opd_pre_last_created_fid));
 }
+LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
 
-static int osp_rd_prealloc_reserved(char *page, char **start, off_t off,
-				    int count, int *eof, void *data)
+static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *obd = data;
+	struct obd_device *obd = m->private;
 	struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return 0;
 
-	return snprintf(page, count, LPU64"\n", osp->opd_pre_reserved);
+	return seq_printf(m, LPU64"\n", osp->opd_pre_reserved);
 }
+LPROC_SEQ_FOPS_RO(osp_prealloc_reserved);
 
-static int osp_rd_maxage(char *page, char **start, off_t off,
-			 int count, int *eof, void *data)
+static int osp_maxage_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%u\n", osp->opd_statfs_maxage);
-	return rc;
+	return seq_printf(m, "%u\n", osp->opd_statfs_maxage);
 }
 
-static int osp_wr_maxage(struct file *file, const char *buffer,
-			 unsigned long count, void *data)
+static ssize_t
+osp_maxage_seq_write(struct file *file, const char *buffer,
+			size_t count, loff_t *off)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = ((struct seq_file *)file->private_data)->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
 	int			 val, rc;
 
@@ -381,25 +370,23 @@ static int osp_wr_maxage(struct file *file, const char *buffer,
 
 	return count;
 }
+LPROC_SEQ_FOPS(osp_maxage);
 
-static int osp_rd_pre_status(char *page, char **start, off_t off,
-			     int count, int *eof, void *data)
+static int osp_pre_status_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL || osp->opd_pre == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%d\n", osp->opd_pre_status);
-	return rc;
+	return seq_printf(m, "%d\n", osp->opd_pre_status);
 }
+LPROC_SEQ_FOPS_RO(osp_pre_status);
 
-static int osp_rd_destroys_in_flight(char *page, char **start, off_t off,
-				     int count, int *eof, void *data)
+static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device *dev = data;
+	struct obd_device *dev = m->private;
 	struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev);
 
 	if (osp == NULL)
@@ -411,87 +398,126 @@ static int osp_rd_destroys_in_flight(char *page, char **start, off_t off,
 	 * - sync changes are zero - no llog records
 	 * - sync in progress are zero - no RPCs in flight
 	 */
-	return snprintf(page, count, "%lu\n",
+	return seq_printf(m, "%lu\n",
 			osp->opd_syn_rpc_in_progress + osp->opd_syn_changes);
 }
+LPROC_SEQ_FOPS_RO(osp_destroys_in_flight);
 
-static int osp_rd_old_sync_processed(char *page, char **start, off_t off,
-				     int count, int *eof, void *data)
+static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data)
 {
-	struct obd_device	*dev = data;
+	struct obd_device	*dev = m->private;
 	struct osp_device	*osp = lu2osp_dev(dev->obd_lu_dev);
-	int			 rc;
 
 	if (osp == NULL)
 		return -EINVAL;
 
-	rc = snprintf(page, count, "%d\n", osp->opd_syn_prev_done);
-	return rc;
+	return seq_printf(m, "%d\n", osp->opd_syn_prev_done);
 }
+LPROC_SEQ_FOPS_RO(osp_old_sync_processed);
 
-static struct lprocfs_vars lprocfs_osp_obd_vars[] = {
-	{ "uuid",		lprocfs_rd_uuid, 0, 0 },
-	{ "ping",		0, lprocfs_wr_ping, 0, 0, 0222 },
-	{ "connect_flags",	lprocfs_rd_connect_flags, 0, 0 },
-	{ "ost_server_uuid",	lprocfs_rd_server_uuid, 0, 0 },
-	{ "ost_conn_uuid",	lprocfs_rd_conn_uuid, 0, 0 },
-	{ "active",		osp_rd_active, osp_wr_active, 0 },
-	{ "max_rpcs_in_flight",	osp_rd_max_rpcs_in_flight,
-				osp_wr_max_rpcs_in_flight, 0 },
-	{ "max_rpcs_in_progress", osp_rd_max_rpcs_in_prog,
-				  osp_wr_max_rpcs_in_prog, 0 },
-	{ "create_count",	osp_rd_create_count,
-				osp_wr_create_count, 0 },
-	{ "max_create_count",	osp_rd_max_create_count,
-				osp_wr_max_create_count, 0 },
-	{ "prealloc_next_id",	osp_rd_prealloc_next_id, 0, 0 },
-	{ "prealloc_next_seq",  osp_rd_prealloc_next_seq, 0, 0 },
-	{ "prealloc_last_id",   osp_rd_prealloc_last_id,  0, 0 },
-	{ "prealloc_last_seq",  osp_rd_prealloc_last_seq, 0, 0 },
-	{ "prealloc_reserved",	osp_rd_prealloc_reserved, 0, 0 },
-	{ "timeouts",		lprocfs_rd_timeouts, 0, 0 },
-	{ "import",		lprocfs_rd_import, lprocfs_wr_import, 0 },
-	{ "state",		lprocfs_rd_state, 0, 0 },
-	{ "maxage",		osp_rd_maxage, osp_wr_maxage, 0 },
-	{ "prealloc_status",	osp_rd_pre_status, 0, 0 },
-	{ "sync_changes",	osp_rd_syn_changes, 0, 0 },
-	{ "sync_in_flight",	osp_rd_syn_in_flight, 0, 0 },
-	{ "sync_in_progress",	osp_rd_syn_in_prog, 0, 0 },
-	{ "old_sync_processed",	osp_rd_old_sync_processed, 0, 0 },
+LPROC_SEQ_FOPS_WO_TYPE(osp, ping);
+LPROC_SEQ_FOPS_RO_TYPE(osp, uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags);
+LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid);
+LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid);
 
-	/* for compatibility reasons */
-	{ "destroys_in_flight",	osp_rd_destroys_in_flight, 0, 0 },
-	{ 0 }
-};
+static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+{
+	return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private);
+}
+LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc);
+LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts);
+
+LPROC_SEQ_FOPS_RW_TYPE(osp, import);
+LPROC_SEQ_FOPS_RO_TYPE(osp, state);
+
+static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = {
+	{ .name	=	"uuid",
+	  .fops	=	&osp_uuid_fops			},
+	{ .name	=	"ping",
+	  .fops	=	&osp_ping_fops,
+	  .proc_mode =	0222				},
+	{ .name	=	"connect_flags",
+	  .fops	=	&osp_connect_flags_fops		},
+	{ .name	=	"ost_server_uuid",
+	  .fops	=	&osp_server_uuid_fops		},
+	{ .name	=	"ost_conn_uuid",
+	  .fops	=	&osp_conn_uuid_fops		},
+	{ .name	=	"active",
+	  .fops	=	&osp_active_fops		},
+	{ .name	=	"max_rpcs_in_flight",
+	  .fops	=	&osp_max_rpcs_in_flight_fops	},
+	{ .name	=	"max_rpcs_in_progress",
+	  .fops	=	&osp_max_rpcs_in_prog_fops	},
+	{ .name	=	"create_count",
+	  .fops	=	&osp_create_count_fops		},
+	{ .name	=	"max_create_count",
+	  .fops	=	&osp_max_create_count_fops	},
+	{ .name	=	"prealloc_next_id",
+	  .fops	=	&osp_prealloc_next_id_fops	},
+	{ .name	=	"prealloc_next_seq",
+	  .fops	=	&osp_prealloc_next_seq_fops	},
+	{ .name	=	"prealloc_last_id",
+	  .fops	=	&osp_prealloc_last_id_fops	},
+	{ .name	=	"prealloc_last_seq",
+	  .fops	=	&osp_prealloc_last_seq_fops	},
+	{ .name	=	"prealloc_reserved",
+	  .fops	=	&osp_prealloc_reserved_fops	},
+	{ .name	=	"timeouts",
+	  .fops	=	&osp_timeouts_fops		},
+	{ .name	=	"import",
+	  .fops	=	&osp_import_fops		},
+	{ .name	=	"state",
+	  .fops	=	&osp_state_fops			},
+	{ .name	=	"maxage",
+	  .fops	=	&osp_maxage_fops		},
+	{ .name	=	"prealloc_status",
+	  .fops	=	&osp_pre_status_fops		},
+	{ .name	=	"sync_changes",
+	  .fops	=	&osp_syn_changes_fops		},
+	{ .name	=	"sync_in_flight",
+	  .fops	=	&osp_syn_in_flight_fops		},
+	{ .name	=	"sync_in_progress",
+	  .fops	=	&osp_syn_in_prog_fops		},
+	{ .name	=	"old_sync_processed",
+	  .fops	=	&osp_old_sync_processed_fops	},
 
-static struct lprocfs_vars lprocfs_osp_osd_vars[] = {
-	{ "blocksize",		lprocfs_dt_rd_blksize, 0, 0 },
-	{ "kbytestotal",	lprocfs_dt_rd_kbytestotal, 0, 0 },
-	{ "kbytesfree",		lprocfs_dt_rd_kbytesfree, 0, 0 },
-	{ "kbytesavail",	lprocfs_dt_rd_kbytesavail, 0, 0 },
-	{ "filestotal",		lprocfs_dt_rd_filestotal, 0, 0 },
-	{ "filesfree",		lprocfs_dt_rd_filesfree, 0, 0 },
+	/* for compatibility reasons */
+	{ .name	=	"destroys_in_flight",
+	  .fops	=	&osp_destroys_in_flight_fops	},
 	{ 0 }
 };
 
-static struct lprocfs_vars lprocfs_osp_module_vars[] = {
-	{ "num_refs",		lprocfs_rd_numrefs, 0, 0 },
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize);
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytestotal);
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesfree);
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail);
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal);
+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree);
+
+static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = {
+	{ .name	=	"blocksize",
+	  .fops	=	&osp_dt_blksize_fops		},
+	{ .name	=	"kbytestotal",
+	  .fops	=	&osp_dt_kbytestotal_fops	},
+	{ .name	=	"kbytesfree",
+	  .fops	=	&osp_dt_kbytesfree_fops		},
+	{ .name	=	"kbytesavail",
+	  .fops	=	&osp_dt_kbytesavail_fops	},
+	{ .name	=	"filestotal",
+	  .fops	=	&osp_dt_filestotal_fops		},
+	{ .name	=	"filesfree",
+	  .fops	=	&osp_dt_filesfree_fops		},
 	{ 0 }
 };
 
-void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars)
-{
-	lvars->module_vars = lprocfs_osp_module_vars;
-	lvars->obd_vars = lprocfs_osp_obd_vars;
-}
-
 void osp_lprocfs_init(struct osp_device *osp)
 {
 	struct obd_device	*obd = osp->opd_obd;
-	struct proc_dir_entry	*osc_proc_dir;
+	struct proc_dir_entry	*symlink = NULL;
 	int			 rc;
 
-	obd->obd_proc_entry = lprocfs_register(obd->obd_name,
+	obd->obd_proc_entry = lprocfs_seq_register(obd->obd_name,
 					       obd->obd_type->typ_procroot,
 					       lprocfs_osp_osd_vars,
 					       &osp->opd_dt_dev);
@@ -502,34 +528,29 @@ void osp_lprocfs_init(struct osp_device *osp)
 		return;
 	}
 
-	rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd);
+	rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd);
 	if (rc) {
 		CERROR("%s: can't register in lprocfs: %ld\n",
 		       obd->obd_name, PTR_ERR(obd->obd_proc_entry));
 		return;
 	}
+	obd->obd_vars = lprocfs_osp_obd_vars;
 
 	ptlrpc_lprocfs_register_obd(obd);
 
+	if (osp->opd_connect_mdt || obd->obd_type->typ_procsym == NULL ||
+	    !strstr(obd->obd_name, "osc"))
+		return;
+
 	/* for compatibility we link old procfs's OSC entries to osp ones */
-	if (!osp->opd_connect_mdt) {
-		osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc");
-		if (osc_proc_dir) {
-			cfs_proc_dir_entry_t	*symlink = NULL;
-			char			*name;
-
-			OBD_ALLOC(name, strlen(obd->obd_name) + 1);
-			if (name == NULL)
-				return;
-
-			strcpy(name, obd->obd_name);
-			if (strstr(name, "osc"))
-				symlink = lprocfs_add_symlink(name,
-						osc_proc_dir, "../osp/%s",
-						obd->obd_name);
-			OBD_FREE(name, strlen(obd->obd_name) + 1);
-			osp->opd_symlink = symlink;
-		}
+	symlink = lprocfs_add_symlink(obd->obd_name, obd->obd_type->typ_procsym,
+				      "../osp/%s", obd->obd_name);
+	if (symlink == NULL) {
+		CERROR("could not register OSC symlink for "
+			"/proc/fs/lustre/osp/%s.", obd->obd_name);
+		lprocfs_remove(&obd->obd_type->typ_procsym);
+	} else {
+		osp->opd_symlink = symlink;
 	}
 }
 
diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c
index 9560504..d6ae965 100644
--- a/lustre/osp/lwp_dev.c
+++ b/lustre/osp/lwp_dev.c
@@ -186,25 +186,13 @@ const struct lu_device_operations lwp_lu_ops = {
 	.ldo_process_config	= lwp_process_config,
 };
 
-static struct lprocfs_vars lprocfs_lwp_module_vars[] = {
-	{ "num_refs",		lprocfs_rd_numrefs, 0, 0 },
+static struct lprocfs_seq_vars lprocfs_lwp_obd_vars[] = {
 	{ 0 }
 };
 
-static struct lprocfs_vars lprocfs_lwp_obd_vars[] = {
-	{ 0 }
-};
-
-void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars)
-{
-	lvars->module_vars = lprocfs_lwp_module_vars;
-	lvars->obd_vars = lprocfs_lwp_obd_vars;
-}
-
 int lwp_init0(const struct lu_env *env, struct lwp_device *lwp,
 	      struct lu_device_type *ldt, struct lustre_cfg *cfg)
 {
-	struct lprocfs_static_vars lvars = { 0 };
 	int			   rc;
 	ENTRY;
 
@@ -233,8 +221,8 @@ int lwp_init0(const struct lu_env *env, struct lwp_device *lwp,
 		RETURN(rc);
 	}
 
-	lprocfs_lwp_init_vars(&lvars);
-	if (lprocfs_obd_setup(lwp->lpd_obd, lvars.obd_vars) == 0)
+	lwp->lpd_obd->obd_vars = lprocfs_lwp_obd_vars;
+	if (lprocfs_seq_obd_setup(lwp->lpd_obd) == 0)
 		ptlrpc_lprocfs_register_obd(lwp->lpd_obd);
 
 	RETURN(0);
diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c
index 5828d88..7d45fa1 100644
--- a/lustre/osp/osp_dev.c
+++ b/lustre/osp/osp_dev.c
@@ -371,7 +371,7 @@ static int osp_process_config(const struct lu_env *env,
 			      struct lu_device *dev, struct lustre_cfg *lcfg)
 {
 	struct osp_device		*d = lu2osp_dev(dev);
-	struct lprocfs_static_vars	 lvars = { 0 };
+	struct obd_device		*obd = d->opd_obd;
 	int				 rc;
 
 	ENTRY;
@@ -385,11 +385,9 @@ static int osp_process_config(const struct lu_env *env,
 		rc = osp_shutdown(env, d);
 		break;
 	case LCFG_PARAM:
-		lprocfs_osp_init_vars(&lvars);
-
-		LASSERT(d->opd_obd);
-		rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars,
-					      lcfg, d->opd_obd);
+		LASSERT(obd);
+		rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars,
+						  lcfg, obd);
 		if (rc > 0)
 			rc = 0;
 		if (rc == -ENOSYS) {
@@ -842,6 +840,9 @@ static struct lu_device *osp_device_fini(const struct lu_env *env,
 			OBD_FREE_PTR(cli->cl_rpc_lock);
 			cli->cl_rpc_lock = NULL;
 		}
+	} else {
+		if (m->opd_obd->obd_type->typ_procsym != NULL)
+			lprocfs_remove(&m->opd_obd->obd_type->typ_procsym);
 	}
 
 	rc = client_obd_cleanup(m->opd_obd);
@@ -1220,33 +1221,26 @@ struct llog_operations osp_mds_ost_orig_logops;
 
 static int __init osp_mod_init(void)
 {
-	struct lprocfs_static_vars	 lvars;
-	cfs_proc_dir_entry_t		*osc_proc_dir;
-	int				 rc;
+	struct obd_type *type;
+	int rc;
 
 	rc = lu_kmem_init(osp_caches);
 	if (rc)
 		return rc;
 
-	lprocfs_osp_init_vars(&lvars);
-
 	rc = class_register_type(&osp_obd_device_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-				lvars.module_vars,
+				NULL,
 #endif
 				LUSTRE_OSP_NAME, &osp_device_type);
-
-	/* create "osc" entry in procfs for compatibility purposes */
 	if (rc != 0) {
 		lu_kmem_fini(osp_caches);
 		return rc;
 	}
 
-	lprocfs_lwp_init_vars(&lvars);
-
 	rc = class_register_type(&lwp_obd_device_ops, NULL, NULL,
 #ifndef HAVE_ONLY_PROCFS_SEQ
-				lvars.module_vars,
+				NULL,
 #endif
 				LUSTRE_LWP_NAME, &lwp_device_type);
 	if (rc != 0) {
@@ -1260,21 +1254,23 @@ static int __init osp_mod_init(void)
 	osp_mds_ost_orig_logops.lop_add = llog_cat_add_rec;
 	osp_mds_ost_orig_logops.lop_declare_add = llog_cat_declare_add_rec;
 
-	osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc");
-	if (osc_proc_dir == NULL) {
-		osc_proc_dir = lprocfs_register("osc", proc_lustre_root, NULL,
-						NULL);
-		if (IS_ERR(osc_proc_dir))
-			CERROR("osp: can't create compat entry \"osc\": %d\n",
-			       (int) PTR_ERR(osc_proc_dir));
+	type = class_search_type(LUSTRE_OSC_NAME);
+	if (type)
+		return rc;
+
+	type = class_search_type(LUSTRE_OSP_NAME);
+	type->typ_procsym = lprocfs_seq_register("osc", proc_lustre_root,
+						 NULL, NULL);
+	if (IS_ERR(type->typ_procsym)) {
+		CERROR("osp: can't create compat entry \"osc\": %d\n",
+		       (int) PTR_ERR(type->typ_procsym));
+		type->typ_procsym = NULL;
 	}
 	return rc;
 }
 
 static void __exit osp_mod_exit(void)
 {
-	lprocfs_try_remove_proc_entry("osc", proc_lustre_root);
-
 	class_unregister_type(LUSTRE_LWP_NAME);
 	class_unregister_type(LUSTRE_OSP_NAME);
 	lu_kmem_fini(osp_caches);
diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h
index 0871d8d..0cc608b 100644
--- a/lustre/osp/osp_internal.h
+++ b/lustre/osp/osp_internal.h
@@ -433,7 +433,6 @@ int osp_write_last_oid_seq_files(struct lu_env *env, struct osp_device *osp,
 int osp_init_pre_fid(struct osp_device *osp);
 
 /* lproc_osp.c */
-void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars);
 void osp_lprocfs_init(struct osp_device *osp);
 
 /* osp_sync.c */
@@ -447,7 +446,6 @@ int osp_sync_fini(struct osp_device *d);
 void __osp_sync_check_for_work(struct osp_device *d);
 
 /* lwp_dev.c */
-void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars);
 extern struct obd_ops lwp_obd_device_ops;
 extern struct lu_device_type lwp_device_type;
 
-- 
1.8.5.3