Whamcloud - gitweb
0b863226d32bee4c17d015e5cf4cc01a4953ecff
[fs/lustre-release.git] / lustre / mdd / mdd_lproc.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, 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  * lustre/mdd/mdd_lproc.c
33  *
34  * Lustre Metadata Server (mdd) routines
35  *
36  * Author: Wang Di <wangdi@clusterfs.com>
37  */
38
39 #define DEBUG_SUBSYSTEM S_MDS
40
41 #include <obd.h>
42 #include <obd_class.h>
43 #include <obd_support.h>
44 #include <lprocfs_status.h>
45 #include <libcfs/libcfs_string.h>
46 #include "mdd_internal.h"
47
48 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
49                          char *buf)
50 {
51         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
52                                               mdd_kobj);
53         struct obd_device *obd = mdd2obd_dev(mdd);
54
55         return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
56 }
57 LUSTRE_RO_ATTR(uuid);
58
59 static ssize_t atime_diff_show(struct kobject *kobj, struct attribute *attr,
60                                char *buf)
61 {
62         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
63                                               mdd_kobj);
64
65         return sprintf(buf, "%lld\n", mdd->mdd_atime_diff);
66 }
67
68 static ssize_t atime_diff_store(struct kobject *kobj,
69                                 struct attribute *attr,
70                                 const char *buffer, size_t count)
71 {
72         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
73                                               mdd_kobj);
74         time64_t diff = 0;
75         int rc;
76
77         rc = kstrtoll(buffer, 10, &diff);
78         if (rc)
79                 return rc;
80
81         mdd->mdd_atime_diff = diff;
82         return count;
83 }
84 LUSTRE_RW_ATTR(atime_diff);
85
86 /**** changelogs ****/
87 static int mdd_changelog_mask_seq_show(struct seq_file *m, void *data)
88 {
89         struct mdd_device *mdd = m->private;
90         int i = 0;
91
92         while (i < CL_LAST) {
93                 if (mdd->mdd_cl.mc_mask & (1 << i))
94                         seq_printf(m, "%s ", changelog_type2str(i));
95                 i++;
96         }
97         seq_putc(m, '\n');
98         return 0;
99 }
100
101 static ssize_t
102 mdd_changelog_mask_seq_write(struct file *file, const char __user *buffer,
103                              size_t count, loff_t *off)
104 {
105         struct seq_file *m = file->private_data;
106         struct mdd_device *mdd = m->private;
107         char *kernbuf;
108         int rc;
109         ENTRY;
110
111         if (count >= PAGE_SIZE)
112                 RETURN(-EINVAL);
113         OBD_ALLOC(kernbuf, PAGE_SIZE);
114         if (kernbuf == NULL)
115                 RETURN(-ENOMEM);
116         if (copy_from_user(kernbuf, buffer, count))
117                 GOTO(out, rc = -EFAULT);
118         kernbuf[count] = 0;
119
120         rc = cfs_str2mask(kernbuf, changelog_type2str, &mdd->mdd_cl.mc_mask,
121                           CHANGELOG_MINMASK, CHANGELOG_ALLMASK);
122         if (rc == 0)
123                 rc = count;
124 out:
125         OBD_FREE(kernbuf, PAGE_SIZE);
126         return rc;
127 }
128 LDEBUGFS_SEQ_FOPS(mdd_changelog_mask);
129
130 static int lprocfs_changelog_users_cb(const struct lu_env *env,
131                                       struct llog_handle *llh,
132                                       struct llog_rec_hdr *hdr, void *data)
133 {
134         struct llog_changelog_user_rec *rec;
135         struct seq_file *m = data;
136
137         LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN);
138
139         rec = (struct llog_changelog_user_rec *)hdr;
140
141         seq_printf(m, CHANGELOG_USER_PREFIX"%-3d %llu (%u)\n",
142                    rec->cur_id, rec->cur_endrec, (__u32)get_seconds() -
143                                                  rec->cur_time);
144         return 0;
145 }
146
147 static int mdd_changelog_users_seq_show(struct seq_file *m, void *data)
148 {
149         struct lu_env            env;
150         struct mdd_device       *mdd = m->private;
151         struct llog_ctxt        *ctxt;
152         __u64                    cur;
153         int                      rc;
154
155         ctxt = llog_get_context(mdd2obd_dev(mdd),
156                                 LLOG_CHANGELOG_USER_ORIG_CTXT);
157         if (ctxt == NULL)
158                 return -ENXIO;
159         LASSERT(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT);
160
161         rc = lu_env_init(&env, LCT_LOCAL);
162         if (rc) {
163                 llog_ctxt_put(ctxt);
164                 return rc;
165         }
166
167         spin_lock(&mdd->mdd_cl.mc_lock);
168         cur = mdd->mdd_cl.mc_index;
169         spin_unlock(&mdd->mdd_cl.mc_lock);
170
171         seq_printf(m, "current index: %llu\n", cur);
172         seq_printf(m, "%-5s %s %s\n", "ID", "index", "(idle seconds)");
173
174         llog_cat_process(&env, ctxt->loc_handle, lprocfs_changelog_users_cb,
175                          m, 0, 0);
176
177         lu_env_fini(&env);
178         llog_ctxt_put(ctxt);
179         return 0;
180 }
181 LDEBUGFS_SEQ_FOPS_RO(mdd_changelog_users);
182
183 static int mdd_changelog_size_ctxt(const struct lu_env *env,
184                                    struct mdd_device *mdd,
185                                    int index, __u64 *val)
186 {
187         struct llog_ctxt        *ctxt;
188
189         ctxt = llog_get_context(mdd2obd_dev(mdd),
190                                 index);
191         if (ctxt == NULL)
192                 return -ENXIO;
193
194         if (!(ctxt->loc_handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) {
195                 CERROR("%s: ChangeLog has wrong flags: rc = %d\n",
196                        ctxt->loc_obd->obd_name, -EINVAL);
197                 llog_ctxt_put(ctxt);
198                 return -EINVAL;
199         }
200
201         *val += llog_cat_size(env, ctxt->loc_handle);
202
203         llog_ctxt_put(ctxt);
204
205         return 0;
206 }
207
208 static ssize_t changelog_size_show(struct kobject *kobj,
209                                    struct attribute *attr,
210                                    char *buf)
211 {
212         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
213                                               mdd_kobj);
214         struct lu_env env;
215         u64 tmp = 0;
216         int rc;
217
218         rc = lu_env_init(&env, LCT_LOCAL);
219         if (rc)
220                 return rc;
221
222         rc = mdd_changelog_size_ctxt(&env, mdd, LLOG_CHANGELOG_ORIG_CTXT, &tmp);
223         if (rc) {
224                 lu_env_fini(&env);
225                 return rc;
226         }
227
228         rc = mdd_changelog_size_ctxt(&env, mdd, LLOG_CHANGELOG_USER_ORIG_CTXT,
229                                      &tmp);
230
231         rc = sprintf(buf, "%llu\n", tmp);
232         lu_env_fini(&env);
233         return rc;
234 }
235 LUSTRE_RO_ATTR(changelog_size);
236
237 static ssize_t changelog_gc_show(struct kobject *kobj,
238                                  struct attribute *attr,
239                                  char *buf)
240 {
241         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
242                                               mdd_kobj);
243
244         return sprintf(buf, "%u\n", mdd->mdd_changelog_gc);
245 }
246
247 static ssize_t changelog_gc_store(struct kobject *kobj,
248                                   struct attribute *attr,
249                                   const char *buffer, size_t count)
250 {
251         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
252                                               mdd_kobj);
253         bool val;
254         int rc;
255
256         rc = kstrtobool(buffer, &val);
257         if (rc)
258                 return rc;
259
260         mdd->mdd_changelog_gc = val;
261
262         return count;
263 }
264 LUSTRE_RW_ATTR(changelog_gc);
265
266 static ssize_t changelog_max_idle_time_show(struct kobject *kobj,
267                                             struct attribute *attr,
268                                             char *buf)
269 {
270         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
271                                               mdd_kobj);
272
273         return sprintf(buf, "%lld\n", mdd->mdd_changelog_max_idle_time);
274 }
275
276 static ssize_t changelog_max_idle_time_store(struct kobject *kobj,
277                                              struct attribute *attr,
278                                              const char *buffer, size_t count)
279 {
280         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
281                                               mdd_kobj);
282         time64_t val;
283         int rc;
284
285         rc = kstrtoll(buffer, 10, &val);
286         if (rc)
287                 return rc;
288
289         /* as it sounds reasonable, do not allow a user to be idle since
290          * more than about 68 years, this will allow to use 32bits
291          * timestamps for comparison
292          */
293         if (val < 1 || val > INT_MAX)
294                 return -ERANGE;
295
296         mdd->mdd_changelog_max_idle_time = val;
297
298         return count;
299 }
300 LUSTRE_RW_ATTR(changelog_max_idle_time);
301
302 static ssize_t changelog_max_idle_indexes_show(struct kobject *kobj,
303                                                struct attribute *attr,
304                                                char *buf)
305 {
306         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
307                                               mdd_kobj);
308
309         return sprintf(buf, "%lu\n", mdd->mdd_changelog_max_idle_indexes);
310 }
311
312 static ssize_t changelog_max_idle_indexes_store(struct kobject *kobj,
313                                                 struct attribute *attr,
314                                                 const char *buffer,
315                                                 size_t count)
316 {
317         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
318                                               mdd_kobj);
319         unsigned long val;
320         int rc;
321
322         LASSERT(mdd != NULL);
323         rc = kstrtoul(buffer, 0, &val);
324         if (rc)
325                 return rc;
326
327         /* XXX may need to limit/check with reasonable elapsed/idle indexes */
328         /* XXX may better allow to specify a % of full ChangeLogs */
329
330         mdd->mdd_changelog_max_idle_indexes = val;
331
332         return count;
333 }
334 LUSTRE_RW_ATTR(changelog_max_idle_indexes);
335
336 static ssize_t changelog_min_gc_interval_show(struct kobject *kobj,
337                                               struct attribute *attr,
338                                               char *buf)
339 {
340         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
341                                               mdd_kobj);
342
343         return sprintf(buf, "%lld\n", mdd->mdd_changelog_min_gc_interval);
344 }
345
346 static ssize_t changelog_min_gc_interval_store(struct kobject *kobj,
347                                                struct attribute *attr,
348                                                const char *buffer,
349                                                size_t count)
350 {
351         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
352                                               mdd_kobj);
353         time64_t val;
354         int rc;
355
356         rc = kstrtoll(buffer, 10, &val);
357         if (rc)
358                 return rc;
359
360         /* XXX may need to limit with reasonable elapsed/interval times */
361         if (val < 1)
362                 return -ERANGE;
363
364         mdd->mdd_changelog_min_gc_interval = val;
365
366         return count;
367 }
368 LUSTRE_RW_ATTR(changelog_min_gc_interval);
369
370 static ssize_t changelog_min_free_cat_entries_show(struct kobject *kobj,
371                                                    struct attribute *attr,
372                                                    char *buf)
373 {
374         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
375                                               mdd_kobj);
376
377         return sprintf(buf, "%u\n", mdd->mdd_changelog_min_free_cat_entries);
378 }
379
380 static ssize_t changelog_min_free_cat_entries_store(struct kobject *kobj,
381                                                     struct attribute *attr,
382                                                     const char *buffer,
383                                                     size_t count)
384 {
385         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
386                                               mdd_kobj);
387         unsigned int val;
388         int rc;
389
390         rc = kstrtouint(buffer, 10, &val);
391         if (rc)
392                 return rc;
393
394         /* XXX may need to limit with more reasonable number of free entries */
395         if (val < 1)
396                 return -ERANGE;
397
398         mdd->mdd_changelog_min_free_cat_entries = val;
399
400         return count;
401 }
402 LUSTRE_RW_ATTR(changelog_min_free_cat_entries);
403
404 static ssize_t changelog_deniednext_show(struct kobject *kobj,
405                                          struct attribute *attr,
406                                          char *buf)
407 {
408         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
409                                               mdd_kobj);
410
411         return sprintf(buf, "%u\n", mdd->mdd_cl.mc_deniednext);
412 }
413
414 static ssize_t changelog_deniednext_store(struct kobject *kobj,
415                                           struct attribute *attr,
416                                           const char *buffer,
417                                           size_t count)
418 {
419         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
420                                               mdd_kobj);
421         unsigned int time = 0;
422         int rc;
423
424         rc = kstrtouint(buffer, 0, &time);
425         if (rc)
426                 return rc;
427
428         mdd->mdd_cl.mc_deniednext = time;
429         return count;
430 }
431 LUSTRE_RW_ATTR(changelog_deniednext);
432
433 static ssize_t sync_permission_show(struct kobject *kobj,
434                                     struct attribute *attr, char *buf)
435 {
436         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
437                                               mdd_kobj);
438
439         return sprintf(buf, "%d\n", mdd->mdd_sync_permission);
440 }
441
442 static ssize_t sync_permission_store(struct kobject *kobj,
443                                      struct attribute *attr,
444                                      const char *buffer, size_t count)
445 {
446         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
447                                               mdd_kobj);
448         bool val;
449         int rc;
450
451         rc = kstrtobool(buffer, &val);
452         if (rc)
453                 return rc;
454
455         mdd->mdd_sync_permission = val;
456
457         return count;
458 }
459 LUSTRE_RW_ATTR(sync_permission);
460
461 static ssize_t lfsck_speed_limit_show(struct kobject *kobj,
462                                       struct attribute *attr, char *buf)
463 {
464         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
465                                               mdd_kobj);
466
467         return lfsck_get_speed(buf, mdd->mdd_bottom);
468 }
469
470 static ssize_t lfsck_speed_limit_store(struct kobject *kobj,
471                                        struct attribute *attr,
472                                        const char *buffer, size_t count)
473 {
474         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
475                                               mdd_kobj);
476         unsigned int val;
477         int rc;
478
479         rc = kstrtouint(buffer, 10, &val);
480         if (rc != 0)
481                 return rc;
482
483         rc = lfsck_set_speed(mdd->mdd_bottom, val);
484         return rc != 0 ? rc : count;
485 }
486 LUSTRE_RW_ATTR(lfsck_speed_limit);
487
488 static ssize_t lfsck_async_windows_show(struct kobject *kobj,
489                                         struct attribute *attr, char *buf)
490 {
491         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
492                                               mdd_kobj);
493
494         return lfsck_get_windows(buf, mdd->mdd_bottom);
495 }
496
497 static ssize_t lfsck_async_windows_store(struct kobject *kobj,
498                                          struct attribute *attr,
499                                          const char *buffer, size_t count)
500 {
501         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
502                                               mdd_kobj);
503         unsigned int val;
504         int rc;
505
506         rc = kstrtouint(buffer, 10, &val);
507         if (rc)
508                 return rc;
509
510         rc = lfsck_set_windows(mdd->mdd_bottom, val);
511
512         return rc != 0 ? rc : count;
513 }
514 LUSTRE_RW_ATTR(lfsck_async_windows);
515
516 static int mdd_lfsck_namespace_seq_show(struct seq_file *m, void *data)
517 {
518         struct mdd_device *mdd = m->private;
519
520         LASSERT(mdd != NULL);
521
522         return lfsck_dump(m, mdd->mdd_bottom, LFSCK_TYPE_NAMESPACE);
523 }
524 LDEBUGFS_SEQ_FOPS_RO(mdd_lfsck_namespace);
525
526 static int mdd_lfsck_layout_seq_show(struct seq_file *m, void *data)
527 {
528         struct mdd_device *mdd = m->private;
529
530         LASSERT(mdd != NULL);
531
532         return lfsck_dump(m, mdd->mdd_bottom, LFSCK_TYPE_LAYOUT);
533 }
534 LDEBUGFS_SEQ_FOPS_RO(mdd_lfsck_layout);
535
536 /**
537  * Show default number of stripes for O_APPEND files.
538  *
539  * \param[in] m         seq file
540  * \param[in] v         unused for single entry
541  *
542  * \retval 0            on success,
543  * \retval negative     error code if failed
544  */
545 static ssize_t append_stripe_count_show(struct kobject *kobj,
546                                         struct attribute *attr, char *buf)
547 {
548         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
549                                               mdd_kobj);
550
551         return snprintf(buf, PAGE_SIZE, "%d\n", mdd->mdd_append_stripe_count);
552 }
553
554 /**
555  * Set default number of stripes for O_APPEND files.
556  *
557  * \param[in] file      proc file
558  * \param[in] buffer    string containing the default number of stripes
559  *                      for new files
560  * \param[in] count     @buffer length
561  * \param[in] off       unused for single entry
562  *
563  * \retval @count       on success
564  * \retval negative     error code otherwise
565  */
566 static ssize_t append_stripe_count_store(struct kobject *kobj,
567                                          struct attribute *attr,
568                                          const char *buffer, size_t count)
569 {
570         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
571                                               mdd_kobj);
572         int stripe_count;
573         int rc;
574
575         rc = kstrtoint(buffer, 0, &stripe_count);
576         if (rc)
577                 return rc;
578
579         if (stripe_count < -1)
580                 return -ERANGE;
581
582         mdd->mdd_append_stripe_count = stripe_count;
583
584         return count;
585 }
586 LUSTRE_RW_ATTR(append_stripe_count);
587
588 /**
589  * Show default OST pool for O_APPEND files.
590  *
591  * \param[in] kobject   proc object
592  * \param[in] attribute proc attribute
593  * \param[in] buf       output buffer
594  *
595  * \retval 0            on success,
596  * \retval negative     error code if failed
597  */
598 static ssize_t append_pool_show(struct kobject *kobj,
599                                 struct attribute *attr, char *buf)
600 {
601         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
602                                               mdd_kobj);
603
604         return snprintf(buf, LOV_MAXPOOLNAME + 1, "%s\n", mdd->mdd_append_pool);
605 }
606
607 /**
608  * Set default OST pool for O_APPEND files.
609  *
610  * \param[in] kobject   proc object
611  * \param[in] attribute proc attribute
612  * \param[in] buffer    user inputted pool name
613  * \param[in] count     @buffer length
614  *
615  * \retval @count       on success
616  * \retval negative     error code otherwise
617  */
618 static ssize_t append_pool_store(struct kobject *kobj, struct attribute *attr,
619                                  const char *buffer, size_t count)
620 {
621         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
622                                               mdd_kobj);
623
624         if (!count || count > LOV_MAXPOOLNAME + 1)
625                 return -EINVAL;
626
627         /* clear previous value */
628         memset(mdd->mdd_append_pool, 0, LOV_MAXPOOLNAME + 1);
629
630         /* entering "none" clears the pool, otherwise copy the new pool */
631         if (strncmp("none", buffer, 4)) {
632                 memcpy(mdd->mdd_append_pool, buffer, count);
633
634                 /* Trim the trailing '\n' if any */
635                 if (mdd->mdd_append_pool[count - 1] == '\n') {
636                         /* Don't echo just a newline */
637                         if (count == 1)
638                                 return -EINVAL;
639                         mdd->mdd_append_pool[count - 1] = 0;
640                 }
641         }
642
643         return count;
644 }
645 LUSTRE_RW_ATTR(append_pool);
646
647 static struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
648         { .name =       "changelog_mask",
649           .fops =       &mdd_changelog_mask_fops        },
650         { .name =       "changelog_users",
651           .fops =       &mdd_changelog_users_fops       },
652         { .name =       "lfsck_namespace",
653           .fops =       &mdd_lfsck_namespace_fops       },
654         { .name =       "lfsck_layout",
655           .fops =       &mdd_lfsck_layout_fops          },
656         { NULL }
657 };
658
659 static struct attribute *mdd_attrs[] = {
660         &lustre_attr_uuid.attr,
661         &lustre_attr_atime_diff.attr,
662         &lustre_attr_changelog_size.attr,
663         &lustre_attr_changelog_gc.attr,
664         &lustre_attr_changelog_max_idle_time.attr,
665         &lustre_attr_changelog_max_idle_indexes.attr,
666         &lustre_attr_changelog_min_gc_interval.attr,
667         &lustre_attr_changelog_min_free_cat_entries.attr,
668         &lustre_attr_changelog_deniednext.attr,
669         &lustre_attr_lfsck_async_windows.attr,
670         &lustre_attr_lfsck_speed_limit.attr,
671         &lustre_attr_sync_permission.attr,
672         &lustre_attr_append_stripe_count.attr,
673         &lustre_attr_append_pool.attr,
674         NULL,
675 };
676
677 static void mdd_sysfs_release(struct kobject *kobj)
678 {
679         struct mdd_device *mdd = container_of(kobj, struct mdd_device,
680                                               mdd_kobj);
681         struct obd_device *obd = mdd2obd_dev(mdd);
682
683         debugfs_remove_recursive(obd->obd_debugfs_entry);
684         obd->obd_debugfs_entry = NULL;
685
686         complete(&mdd->mdd_kobj_unregister);
687 }
688
689 int mdd_procfs_init(struct mdd_device *mdd, const char *name)
690 {
691         struct obd_device *obd = mdd2obd_dev(mdd);
692         struct obd_type *type;
693         int rc;
694
695         ENTRY;
696         /* at the moment there is no linkage between lu_type
697          * and obd_type, so we lookup obd_type this way
698          */
699         type = class_search_type(LUSTRE_MDD_NAME);
700
701         LASSERT(name != NULL);
702         LASSERT(type != NULL);
703         LASSERT(obd  != NULL);
704
705         /* put reference taken by class_search_type */
706         kobject_put(&type->typ_kobj);
707
708         mdd->mdd_ktype.default_attrs = mdd_attrs;
709         mdd->mdd_ktype.release = mdd_sysfs_release;
710         mdd->mdd_ktype.sysfs_ops = &lustre_sysfs_ops;
711
712         init_completion(&mdd->mdd_kobj_unregister);
713         rc = kobject_init_and_add(&mdd->mdd_kobj, &mdd->mdd_ktype,
714                                   &type->typ_kobj, "%s", name);
715         if (rc)
716                 return rc;
717
718         /* Find the type procroot and add the proc entry for this device */
719         obd->obd_vars = lprocfs_mdd_obd_vars;
720         obd->obd_debugfs_entry = debugfs_create_dir(name,
721                                                      type->typ_debugfs_entry);
722         ldebugfs_add_vars(obd->obd_debugfs_entry, obd->obd_vars, mdd);
723
724         RETURN(rc);
725 }
726
727 void mdd_procfs_fini(struct mdd_device *mdd)
728 {
729         kobject_put(&mdd->mdd_kobj);
730         wait_for_completion(&mdd->mdd_kobj_unregister);
731 }