Whamcloud - gitweb
LU-9855 lustre: use with_imp_locked() more broadly.
[fs/lustre-release.git] / lustre / mdc / lproc_mdc.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) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2017, 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 #define DEBUG_SUBSYSTEM S_CLASS
33
34 #include <linux/vfs.h>
35 #include <obd_class.h>
36 #include <obd_cksum.h>
37 #include <lprocfs_status.h>
38 #include <lustre_osc.h>
39 #include <cl_object.h>
40 #include "mdc_internal.h"
41
42 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
43                            char *buf)
44 {
45         struct obd_device *obd = container_of(kobj, struct obd_device,
46                                               obd_kset.kobj);
47         struct obd_import *imp;
48         ssize_t len;
49
50         with_imp_locked(obd, imp, len)
51                 len = sprintf(buf, "%d\n", !imp->imp_deactive);
52         return len;
53 }
54
55 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
56                             const char *buffer, size_t count)
57 {
58         struct obd_device *obd = container_of(kobj, struct obd_device,
59                                               obd_kset.kobj);
60         struct obd_import *imp, *imp0;
61         bool val;
62         int rc;
63
64         rc = kstrtobool(buffer, &val);
65         if (rc)
66                 return rc;
67
68         with_imp_locked(obd, imp0, rc)
69                 imp = class_import_get(imp0);
70         if (rc)
71                 return rc;
72         /* opposite senses */
73         if (imp->imp_deactive == val)
74                 rc = ptlrpc_set_import_active(imp, val);
75         else
76                 CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
77                        val);
78         class_import_put(imp);
79         return rc ?: count;
80 }
81 LUSTRE_RW_ATTR(active);
82
83 static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
84                                        struct attribute *attr,
85                                        char *buf)
86 {
87         struct obd_device *obd = container_of(kobj, struct obd_device,
88                                               obd_kset.kobj);
89         ssize_t len;
90         u32 max;
91
92         max = obd_get_max_rpcs_in_flight(&obd->u.cli);
93         len = sprintf(buf, "%u\n", max);
94
95         return len;
96 }
97
98 static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
99                                         struct attribute *attr,
100                                         const char *buffer,
101                                         size_t count)
102 {
103         struct obd_device *obd = container_of(kobj, struct obd_device,
104                                               obd_kset.kobj);
105         unsigned int val;
106         int rc;
107
108         rc = kstrtouint(buffer, 10, &val);
109         if (rc)
110                 return rc;
111
112         rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
113         if (rc)
114                 count = rc;
115
116         return count;
117 }
118 LUSTRE_RW_ATTR(max_rpcs_in_flight);
119
120 static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
121                                            struct attribute *attr,
122                                            char *buf)
123 {
124         struct obd_device *obd = container_of(kobj, struct obd_device,
125                                               obd_kset.kobj);
126         u16 max;
127
128         max = obd_get_max_mod_rpcs_in_flight(&obd->u.cli);
129         return sprintf(buf, "%hu\n", max);
130 }
131
132 static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
133                                             struct attribute *attr,
134                                             const char *buffer,
135                                             size_t count)
136 {
137         struct obd_device *obd = container_of(kobj, struct obd_device,
138                                               obd_kset.kobj);
139         u16 val;
140         int rc;
141
142         rc = kstrtou16(buffer, 10, &val);
143         if (rc)
144                 return rc;
145
146         rc = obd_set_max_mod_rpcs_in_flight(&obd->u.cli, val);
147         if (rc)
148                 count = rc;
149
150         return count;
151 }
152 LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
153
154 static int mdc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
155 {
156         struct obd_device *obd = m->private;
157         struct client_obd *cli = &obd->u.cli;
158
159         seq_printf(m, "%lu\n", PAGES_TO_MiB(cli->cl_dirty_max_pages));
160         return 0;
161 }
162
163 static ssize_t mdc_max_dirty_mb_seq_write(struct file *file,
164                                           const char __user *buffer,
165                                           size_t count, loff_t *off)
166 {
167         struct seq_file *sfl = file->private_data;
168         struct obd_device *obd = sfl->private;
169         struct client_obd *cli = &obd->u.cli;
170         char kernbuf[22] = "";
171         u64 pages_number;
172         int rc;
173
174         if (count >= sizeof(kernbuf))
175                 return -EINVAL;
176
177         if (copy_from_user(kernbuf, buffer, count))
178                 return -EFAULT;
179         kernbuf[count] = 0;
180
181         rc = sysfs_memparse(kernbuf, count, &pages_number, "MiB");
182         if (rc < 0)
183                 return rc;
184
185         /* MB -> pages */
186         pages_number = round_up(pages_number, 1024 * 1024) >> PAGE_SHIFT;
187         if (pages_number <= 0 ||
188             pages_number >= MiB_TO_PAGES(OSC_MAX_DIRTY_MB_MAX) ||
189             pages_number > cfs_totalram_pages() / 4) /* 1/4 of RAM */
190                 return -ERANGE;
191
192         spin_lock(&cli->cl_loi_list_lock);
193         cli->cl_dirty_max_pages = pages_number;
194         osc_wake_cache_waiters(cli);
195         spin_unlock(&cli->cl_loi_list_lock);
196
197         return count;
198 }
199 LPROC_SEQ_FOPS(mdc_max_dirty_mb);
200
201 DECLARE_CKSUM_NAME;
202
203 static int mdc_checksum_type_seq_show(struct seq_file *m, void *v)
204 {
205         struct obd_device *obd = m->private;
206         int i;
207
208         if (obd == NULL)
209                 return 0;
210
211         for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
212                 if ((BIT(i) & obd->u.cli.cl_supp_cksum_types) == 0)
213                         continue;
214                 if (obd->u.cli.cl_cksum_type == BIT(i))
215                         seq_printf(m, "[%s] ", cksum_name[i]);
216                 else
217                         seq_printf(m, "%s ", cksum_name[i]);
218         }
219         seq_puts(m, "\n");
220
221         return 0;
222 }
223
224 static ssize_t mdc_checksum_type_seq_write(struct file *file,
225                                            const char __user *buffer,
226                                            size_t count, loff_t *off)
227 {
228         struct seq_file *m = file->private_data;
229         struct obd_device *obd = m->private;
230         char kernbuf[10];
231         int rc = -EINVAL;
232         int i;
233
234         if (obd == NULL)
235                 return 0;
236
237         if (count > sizeof(kernbuf) - 1)
238                 return -EINVAL;
239         if (copy_from_user(kernbuf, buffer, count))
240                 return -EFAULT;
241
242         if (count > 0 && kernbuf[count - 1] == '\n')
243                 kernbuf[count - 1] = '\0';
244         else
245                 kernbuf[count] = '\0';
246
247         for (i = 0; i < ARRAY_SIZE(cksum_name); i++) {
248                 if (strcmp(kernbuf, cksum_name[i]) == 0) {
249                         obd->u.cli.cl_preferred_cksum_type = BIT(i);
250                         if (obd->u.cli.cl_supp_cksum_types & BIT(i)) {
251                                 obd->u.cli.cl_cksum_type = BIT(i);
252                                 rc = count;
253                         } else {
254                                 rc = -ENOTSUPP;
255                         }
256                         break;
257                 }
258         }
259
260         return rc;
261 }
262 LPROC_SEQ_FOPS(mdc_checksum_type);
263
264 static ssize_t checksums_show(struct kobject *kobj,
265                               struct attribute *attr, char *buf)
266 {
267         struct obd_device *obd = container_of(kobj, struct obd_device,
268                                               obd_kset.kobj);
269
270         return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum);
271 }
272
273 static ssize_t checksums_store(struct kobject *kobj,
274                                struct attribute *attr,
275                                const char *buffer,
276                                size_t count)
277 {
278         struct obd_device *obd = container_of(kobj, struct obd_device,
279                                               obd_kset.kobj);
280         bool val;
281         int rc;
282
283         rc = kstrtobool(buffer, &val);
284         if (rc)
285                 return rc;
286
287         obd->u.cli.cl_checksum = val;
288
289         return count;
290 }
291 LUSTRE_RW_ATTR(checksums);
292
293 static ssize_t checksum_dump_show(struct kobject *kobj,
294                                   struct attribute *attr, char *buf)
295 {
296         struct obd_device *obd = container_of(kobj, struct obd_device,
297                                               obd_kset.kobj);
298
299         return scnprintf(buf, PAGE_SIZE, "%d\n", !!obd->u.cli.cl_checksum_dump);
300 }
301
302 static ssize_t checksum_dump_store(struct kobject *kobj,
303                                    struct attribute *attr,
304                                    const char *buffer,
305                                    size_t count)
306 {
307         struct obd_device *obd = container_of(kobj, struct obd_device,
308                                               obd_kset.kobj);
309         bool val;
310         int rc;
311
312         rc = kstrtobool(buffer, &val);
313         if (rc)
314                 return rc;
315
316         obd->u.cli.cl_checksum_dump = val;
317
318         return count;
319 }
320 LUSTRE_RW_ATTR(checksum_dump);
321
322 static ssize_t contention_seconds_show(struct kobject *kobj,
323                                        struct attribute *attr,
324                                        char *buf)
325 {
326         struct obd_device *obd = container_of(kobj, struct obd_device,
327                                               obd_kset.kobj);
328         struct osc_device *od = obd2osc_dev(obd);
329
330         return sprintf(buf, "%lld\n", od->od_contention_time);
331 }
332
333 static ssize_t contention_seconds_store(struct kobject *kobj,
334                                         struct attribute *attr,
335                                         const char *buffer,
336                                         size_t count)
337 {
338         struct obd_device *obd = container_of(kobj, struct obd_device,
339                                               obd_kset.kobj);
340         struct osc_device *od = obd2osc_dev(obd);
341         time64_t val;
342         int rc;
343
344         rc = kstrtoll(buffer, 0, &val);
345         if (rc)
346                 return rc;
347
348         od->od_contention_time = val;
349
350         return count;
351 }
352 LUSTRE_RW_ATTR(contention_seconds);
353
354 LUSTRE_ATTR(mds_conn_uuid, 0444, conn_uuid_show, NULL);
355 LUSTRE_RO_ATTR(conn_uuid);
356
357 LUSTRE_RW_ATTR(ping);
358
359 static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
360 {
361         struct obd_device *obd = m->private;
362         struct client_obd *cli = &obd->u.cli;
363         int shift = 20 - PAGE_SHIFT;
364
365         seq_printf(m, "used_mb: %ld\n"
366                    "busy_cnt: %ld\n"
367                    "reclaim: %llu\n",
368                    (atomic_long_read(&cli->cl_lru_in_list) +
369                     atomic_long_read(&cli->cl_lru_busy)) >> shift,
370                     atomic_long_read(&cli->cl_lru_busy),
371                    cli->cl_lru_reclaim);
372
373         return 0;
374 }
375
376 /* shrink the number of caching pages to a specific number */
377 static ssize_t
378 mdc_cached_mb_seq_write(struct file *file, const char __user *buffer,
379                         size_t count, loff_t *off)
380 {
381         struct seq_file *sfl = file->private_data;
382         struct obd_device *obd = sfl->private;
383         struct client_obd *cli = &obd->u.cli;
384         u64 pages_number;
385         const char *tmp;
386         long rc;
387         char kernbuf[128];
388
389         if (count >= sizeof(kernbuf))
390                 return -EINVAL;
391
392         if (copy_from_user(kernbuf, buffer, count))
393                 return -EFAULT;
394         kernbuf[count] = 0;
395
396         tmp = lprocfs_find_named_value(kernbuf, "used_mb:", &count);
397         rc = sysfs_memparse(tmp, count, &pages_number, "MiB");
398         if (rc < 0)
399                 return rc;
400
401         pages_number >>= PAGE_SHIFT;
402
403         rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number;
404         if (rc > 0) {
405                 struct lu_env *env;
406                 __u16 refcheck;
407
408                 env = cl_env_get(&refcheck);
409                 if (!IS_ERR(env)) {
410                         (void)osc_lru_shrink(env, cli, rc, true);
411                         cl_env_put(env, &refcheck);
412                 }
413         }
414
415         return count;
416 }
417 LPROC_SEQ_FOPS(mdc_cached_mb);
418
419 static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v)
420 {
421         struct obd_device *obd = m->private;
422         struct client_obd *cli = &obd->u.cli;
423         long pages;
424         int mb;
425
426         pages = atomic_long_read(&cli->cl_unstable_count);
427         mb    = (pages * PAGE_SIZE) >> 20;
428
429         seq_printf(m, "unstable_pages: %20ld\n"
430                    "unstable_mb:              %10d\n", pages, mb);
431         return 0;
432 }
433 LPROC_SEQ_FOPS_RO(mdc_unstable_stats);
434
435 static ssize_t mdc_rpc_stats_seq_write(struct file *file,
436                                        const char __user *buf,
437                                        size_t len, loff_t *off)
438 {
439         struct seq_file *seq = file->private_data;
440         struct obd_device *obd = seq->private;
441         struct client_obd *cli = &obd->u.cli;
442
443         lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
444
445         lprocfs_oh_clear(&cli->cl_read_rpc_hist);
446         lprocfs_oh_clear(&cli->cl_write_rpc_hist);
447         lprocfs_oh_clear(&cli->cl_read_page_hist);
448         lprocfs_oh_clear(&cli->cl_write_page_hist);
449         lprocfs_oh_clear(&cli->cl_read_offset_hist);
450         lprocfs_oh_clear(&cli->cl_write_offset_hist);
451
452         return len;
453 }
454
455 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
456 {
457         struct obd_device *obd = seq->private;
458         struct client_obd *cli = &obd->u.cli;
459         unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
460         int i;
461
462         obd_mod_rpc_stats_seq_show(cli, seq);
463
464         spin_lock(&cli->cl_loi_list_lock);
465
466         seq_printf(seq, "\nread RPCs in flight:  %d\n",
467                    cli->cl_r_in_flight);
468         seq_printf(seq, "write RPCs in flight: %d\n",
469                    cli->cl_w_in_flight);
470         seq_printf(seq, "pending write pages:  %d\n",
471                    atomic_read(&cli->cl_pending_w_pages));
472         seq_printf(seq, "pending read pages:   %d\n",
473                    atomic_read(&cli->cl_pending_r_pages));
474
475         seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
476         seq_printf(seq, "pages per rpc         rpcs   %% cum %% |");
477         seq_printf(seq, "       rpcs   %% cum %%\n");
478
479         read_tot = lprocfs_oh_sum(&cli->cl_read_page_hist);
480         write_tot = lprocfs_oh_sum(&cli->cl_write_page_hist);
481
482         read_cum = 0;
483         write_cum = 0;
484         for (i = 0; i < OBD_HIST_MAX; i++) {
485                 unsigned long r = cli->cl_read_page_hist.oh_buckets[i];
486                 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
487
488                 read_cum += r;
489                 write_cum += w;
490                 seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
491                            1 << i, r, pct(r, read_tot),
492                            pct(read_cum, read_tot), w,
493                            pct(w, write_tot),
494                            pct(write_cum, write_tot));
495                 if (read_cum == read_tot && write_cum == write_tot)
496                         break;
497         }
498
499         seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
500         seq_printf(seq, "rpcs in flight        rpcs   %% cum %% |");
501         seq_printf(seq, "       rpcs   %% cum %%\n");
502
503         read_tot = lprocfs_oh_sum(&cli->cl_read_rpc_hist);
504         write_tot = lprocfs_oh_sum(&cli->cl_write_rpc_hist);
505
506         read_cum = 0;
507         write_cum = 0;
508         for (i = 1; i < OBD_HIST_MAX; i++) {
509                 unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
510                 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
511
512                 read_cum += r;
513                 write_cum += w;
514                 seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
515                            i, r, pct(r, read_tot), pct(read_cum, read_tot), w,
516                            pct(w, write_tot), pct(write_cum, write_tot));
517                 if (read_cum == read_tot && write_cum == write_tot)
518                         break;
519         }
520
521         seq_printf(seq, "\n\t\t\tread\t\t\twrite\n");
522         seq_printf(seq, "offset                rpcs   %% cum %% |");
523         seq_printf(seq, "       rpcs   %% cum %%\n");
524
525         read_tot = lprocfs_oh_sum(&cli->cl_read_offset_hist);
526         write_tot = lprocfs_oh_sum(&cli->cl_write_offset_hist);
527
528         read_cum = 0;
529         write_cum = 0;
530         for (i = 0; i < OBD_HIST_MAX; i++) {
531                 unsigned long r = cli->cl_read_offset_hist.oh_buckets[i];
532                 unsigned long w = cli->cl_write_offset_hist.oh_buckets[i];
533
534                 read_cum += r;
535                 write_cum += w;
536                 seq_printf(seq, "%d:\t\t%10lu %3u %3u   | %10lu %3u %3u\n",
537                            (i == 0) ? 0 : 1 << (i - 1),
538                            r, pct(r, read_tot), pct(read_cum, read_tot),
539                            w, pct(w, write_tot), pct(write_cum, write_tot));
540                 if (read_cum == read_tot && write_cum == write_tot)
541                         break;
542         }
543         spin_unlock(&cli->cl_loi_list_lock);
544
545         return 0;
546 }
547 LPROC_SEQ_FOPS(mdc_rpc_stats);
548
549 static int mdc_stats_seq_show(struct seq_file *seq, void *v)
550 {
551         struct timespec64 now;
552         struct obd_device *obd = seq->private;
553         struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
554
555         ktime_get_real_ts64(&now);
556
557         seq_printf(seq, "snapshot_time:         %lld.%09lu (secs.nsecs)\n",
558                    (s64)now.tv_sec, now.tv_nsec);
559         seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
560                    stats->os_lockless_writes);
561         seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
562                    stats->os_lockless_reads);
563         seq_printf(seq, "lockless_truncate\t\t%llu\n",
564                    stats->os_lockless_truncates);
565         return 0;
566 }
567
568 static ssize_t mdc_stats_seq_write(struct file *file,
569                                    const char __user *buf,
570                                    size_t len, loff_t *off)
571 {
572         struct seq_file *seq = file->private_data;
573         struct obd_device *obd = seq->private;
574         struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
575
576         memset(stats, 0, sizeof(*stats));
577         return len;
578 }
579 LPROC_SEQ_FOPS(mdc_stats);
580
581 static int mdc_dom_min_repsize_seq_show(struct seq_file *m, void *v)
582 {
583         struct obd_device *obd = m->private;
584
585         seq_printf(m, "%u\n", obd->u.cli.cl_dom_min_inline_repsize);
586
587         return 0;
588 }
589
590 static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
591                                              const char __user *buffer,
592                                              size_t count, loff_t *off)
593 {
594         struct seq_file *m = file->private_data;
595         struct obd_device *obd = m->private;
596         unsigned int val;
597         int rc;
598
599         rc = kstrtouint_from_user(buffer, count, 0, &val);
600         if (rc)
601                 return rc;
602
603         if (val > MDC_DOM_MAX_INLINE_REPSIZE)
604                 return -ERANGE;
605
606         obd->u.cli.cl_dom_min_inline_repsize = val;
607         return count;
608 }
609 LPROC_SEQ_FOPS(mdc_dom_min_repsize);
610
611 LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
612 LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
613 LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
614 LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
615 LPROC_SEQ_FOPS_RW_TYPE(mdc, obd_max_pages_per_rpc);
616 LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
617 LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
618
619 struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
620         { .name =       "connect_flags",
621           .fops =       &mdc_connect_flags_fops },
622         { .name =       "mds_server_uuid",
623           .fops =       &mdc_server_uuid_fops   },
624         { .name =       "max_pages_per_rpc",
625           .fops =       &mdc_obd_max_pages_per_rpc_fops },
626         { .name =       "max_dirty_mb",
627           .fops =       &mdc_max_dirty_mb_fops          },
628         { .name =       "mdc_cached_mb",
629           .fops =       &mdc_cached_mb_fops             },
630         { .name =       "checksum_type",
631           .fops =       &mdc_checksum_type_fops         },
632         { .name =       "timeouts",
633           .fops =       &mdc_timeouts_fops              },
634         { .name =       "import",
635           .fops =       &mdc_import_fops                },
636         { .name =       "state",
637           .fops =       &mdc_state_fops                 },
638         { .name =       "pinger_recov",
639           .fops =       &mdc_pinger_recov_fops          },
640         { .name =       "rpc_stats",
641           .fops =       &mdc_rpc_stats_fops             },
642         { .name =       "unstable_stats",
643           .fops =       &mdc_unstable_stats_fops        },
644         { .name =       "mdc_stats",
645           .fops =       &mdc_stats_fops                 },
646         { .name =       "mdc_dom_min_repsize",
647           .fops =       &mdc_dom_min_repsize_fops       },
648         { NULL }
649 };
650
651 static struct attribute *mdc_attrs[] = {
652         &lustre_attr_active.attr,
653         &lustre_attr_checksums.attr,
654         &lustre_attr_checksum_dump.attr,
655         &lustre_attr_max_rpcs_in_flight.attr,
656         &lustre_attr_max_mod_rpcs_in_flight.attr,
657         &lustre_attr_contention_seconds.attr,
658         &lustre_attr_mds_conn_uuid.attr,
659         &lustre_attr_conn_uuid.attr,
660         &lustre_attr_ping.attr,
661         NULL,
662 };
663
664 int mdc_tunables_init(struct obd_device *obd)
665 {
666         int rc;
667
668         obd->obd_ktype.default_attrs = mdc_attrs;
669         obd->obd_vars = lprocfs_mdc_obd_vars;
670
671         rc = lprocfs_obd_setup(obd, false);
672         if (rc)
673                 goto out_failed;
674 #ifdef CONFIG_PROC_FS
675         rc = lprocfs_alloc_md_stats(obd, 0);
676         if (rc) {
677                 lprocfs_obd_cleanup(obd);
678                 goto out_failed;
679         }
680 #endif
681         rc = sptlrpc_lprocfs_cliobd_attach(obd);
682         if (rc) {
683 #ifdef CONFIG_PROC_FS
684                 lprocfs_free_md_stats(obd);
685 #endif
686                 lprocfs_obd_cleanup(obd);
687                 goto out_failed;
688         }
689         ptlrpc_lprocfs_register_obd(obd);
690
691 out_failed:
692         return rc;
693 }