struct lprocfs_static_vars {
struct lprocfs_vars *obd_vars;
+ struct attribute_group *sysfs_vars;
};
/* if we find more consumers this could be generalized */
extern void lprocfs_remove_proc_entry(const char *name,
struct proc_dir_entry *parent);
-extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
+extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs);
extern int lprocfs_obd_cleanup(struct obd_device *obd);
extern int ldebugfs_seq_create(struct dentry *parent,
int typ_refcnt;
struct lu_device_type *typ_lu;
spinlock_t obd_type_lock;
+ struct kobject *typ_kobj;
};
struct brw_page {
struct lu_ref obd_reference;
int obd_conn_inprogress;
+
+ struct kobject obd_kobj; /* sysfs object */
+ struct completion obd_kobj_unregister;
};
#define OBD_LLOG_FL_SENDNOW 0x0001
static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct lmv_obd *lmv = &obd->u.lmv;
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
struct lmv_desc *desc;
int rc;
lprocfs_lmv_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
#if defined (CONFIG_PROC_FS)
{
rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
goto out;
lprocfs_lov_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
#if defined (CONFIG_PROC_FS)
{
int rc1;
if (rc)
goto err_close_lock;
lprocfs_mdc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
int rc;
ptlrpcd_addref();
}
lprocfs_mgc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
if (atomic_inc_return(&mgc_count) == 1) {
goto failed;
}
+ type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
+ if (!type->typ_kobj) {
+ rc = -ENOMEM;
+ goto failed;
+ }
+
if (ldt != NULL) {
type->typ_lu = ldt;
rc = lu_device_type_init(ldt);
return 0;
failed:
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
kfree(type->typ_name);
kfree(type->typ_md_ops);
kfree(type->typ_dt_ops);
return -EBUSY;
}
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
+
if (type->typ_procroot) {
lprocfs_remove(&type->typ_procroot);
}
}
EXPORT_SYMBOL(lprocfs_rd_connect_flags);
-int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list)
+static struct attribute *obd_def_attrs[] = {
+ NULL,
+};
+
+static void obd_sysfs_release(struct kobject *kobj)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+
+ complete(&obd->obd_kobj_unregister);
+}
+
+static struct kobj_type obd_ktype = {
+ .default_attrs = obd_def_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = obd_sysfs_release,
+};
+
+int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs)
{
int rc = 0;
LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
LASSERT(obd->obd_type->typ_procroot != NULL);
+ init_completion(&obd->obd_kobj_unregister);
+ rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype,
+ obd->obd_type->typ_kobj,
+ "%s", obd->obd_name);
+ if (rc)
+ return rc;
+
+ if (attrs) {
+ rc = sysfs_create_group(&obd->obd_kobj, attrs);
+ if (rc) {
+ kobject_put(&obd->obd_kobj);
+ return rc;
+ }
+ }
+
obd->obd_proc_entry = lprocfs_register(obd->obd_name,
obd->obd_type->typ_procroot,
list, obd);
if (IS_ERR(obd->obd_proc_entry)) {
+ kobject_put(&obd->obd_kobj);
rc = PTR_ERR(obd->obd_proc_entry);
CERROR("error %d setting up lprocfs for %s\n",
rc, obd->obd_name);
obd->obd_proc_entry = NULL;
}
+
return rc;
}
EXPORT_SYMBOL(lprocfs_obd_setup);
lprocfs_remove(&obd->obd_proc_entry);
obd->obd_proc_entry = NULL;
}
+ kobject_put(&obd->obd_kobj);
+ wait_for_completion(&obd->obd_kobj_unregister);
return 0;
}
EXPORT_SYMBOL(lprocfs_obd_cleanup);
cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
lprocfs_osc_init_vars(&lvars);
- if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
+ if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) {
lproc_osc_attach_seqstat(obd);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);