+ struct obd_type *type;
+ int rc;
+
+ ENTRY;
+
+ /* at the moment there is no linkage between lu_type
+ * and obd_type, so we lookup obd_type this way
+ */
+ type = class_search_type(LUSTRE_OSD_LDISKFS_NAME);
+
+ LASSERT(name);
+ LASSERT(type);
+
+ LCONSOLE_INFO("osd-ldiskfs create tunables for %s\n", name);
+
+ /* put reference taken by class_search_type */
+ kobject_put(&type->typ_kobj);
+
+ osd->od_dt_dev.dd_ktype.default_attrs = ldiskfs_attrs;
+ rc = dt_tunables_init(&osd->od_dt_dev, type, name,
+ lprocfs_osd_obd_vars);
+ if (rc) {
+ CERROR("%s: cannot setup sysfs / debugfs entry: %d\n",
+ name, rc);
+ GOTO(out, rc);
+ }
+
+ if (osd->od_proc_entry)
+ RETURN(0);
+
+ /* Find the type procroot and add the proc entry for this device */
+ osd->od_proc_entry = lprocfs_register(name, type->typ_procroot,
+ NULL, &osd->od_dt_dev);
+ if (IS_ERR(osd->od_proc_entry)) {
+ rc = PTR_ERR(osd->od_proc_entry);
+ CERROR("Error %d setting up lprocfs for %s\n",
+ rc, name);
+ osd->od_proc_entry = NULL;
+ GOTO(out, rc);
+ }
+
+ rc = osd_stats_init(osd);
+
+ EXIT;
+out:
+ if (rc)
+ osd_procfs_fini(osd);
+ return rc;
+}
+
+int osd_procfs_fini(struct osd_device *osd)
+{
+ if (osd->od_stats)
+ lprocfs_free_stats(&osd->od_stats);
+
+ if (osd->od_proc_entry)
+ lprocfs_remove(&osd->od_proc_entry);
+
+ return dt_tunables_fini(&osd->od_dt_dev);