All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 23/38] lustre: obd: create class_setup_tunables() function
Date: Thu, 16 Aug 2018 23:10:26 -0400	[thread overview]
Message-ID: <1534475441-15543-24-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1534475441-15543-1-git-send-email-jsimmons@infradead.org>

Creat class_setup_tunables() so sysfs kobject creation is handled
for both obd_devices and llite.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
WC-bug-id: https://jira.whamcloud.com/browse/LU-8066
Reviewed-on: https://review.whamcloud.com/28108
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 drivers/staging/lustre/lustre/include/obd.h        |  3 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |  2 ++
 drivers/staging/lustre/lustre/llite/lproc_llite.c  | 30 +++-------------
 drivers/staging/lustre/lustre/obdclass/genops.c    | 40 +++++++++++++++-------
 .../lustre/lustre/obdclass/lprocfs_status.c        |  2 +-
 5 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 36f6c10..385a88d 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -111,8 +111,7 @@ struct obd_type {
 	int  typ_refcnt;
 	struct lu_device_type *typ_lu;
 	spinlock_t obd_type_lock;
-	struct kobject		typ_kobj;
-	struct completion	typ_kobj_unregister;
+	struct kobject		*typ_kobj;
 };
 
 struct brw_page {
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index fd9d99b..e994c968 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -33,6 +33,7 @@
 #ifndef __CLASS_OBD_H
 #define __CLASS_OBD_H
 
+#include <linux/kobject.h>
 #include <obd_support.h>
 #include <lustre_import.h>
 #include <lustre_net.h>
@@ -59,6 +60,7 @@
 
 /* genops.c */
 struct obd_export *class_conn2export(struct lustre_handle *conn);
+struct kobject *class_setup_tunables(const char *name);
 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 			const char *name, struct lu_device_type *ldt);
 int class_unregister_type(const char *name);
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index ab2f102..30873fc 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -43,40 +43,20 @@
 static struct kobject *llite_kobj;
 static struct dentry *llite_root;
 
-static void class_sysfs_release(struct kobject *kobj)
-{
-	kfree(kobj);
-}
-
-static struct kobj_type class_ktype = {
-	.sysfs_ops	= &lustre_sysfs_ops,
-	.release	= class_sysfs_release,
-};
-
 int llite_tunables_register(void)
 {
-	const char *name = "llite";
-	struct kobject *kobj;
 	int rc = 0;
 
-	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
-	if (!kobj)
-		return -ENOMEM;
-
-	kobj->kset = lustre_kset;
-	kobject_init(kobj, &class_ktype);
-	rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name);
-	if (rc) {
-		kobject_put(kobj);
-		return -ENOMEM;
-	}
-	llite_kobj = kobj;
+	llite_kobj = class_setup_tunables("llite");
+	if (IS_ERR(llite_kobj))
+		return PTR_ERR(llite_kobj);
 
 	llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
 	if (IS_ERR_OR_NULL(llite_root)) {
 		rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
 		llite_root = NULL;
-		kobject_put(kobj);
+		kobject_put(llite_kobj);
+		llite_kobj = NULL;
 	}
 
 	return rc;
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index bf182e5..29ed498 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -135,10 +135,7 @@ void class_put_type(struct obd_type *type)
 
 static void class_sysfs_release(struct kobject *kobj)
 {
-	struct obd_type *type = container_of(kobj, struct obd_type,
-					     typ_kobj);
-
-	complete(&type->typ_kobj_unregister);
+	kfree(kobj);
 }
 
 static struct kobj_type class_ktype = {
@@ -146,6 +143,26 @@ static void class_sysfs_release(struct kobject *kobj)
 	.release	= class_sysfs_release,
 };
 
+struct kobject *class_setup_tunables(const char *name)
+{
+	struct kobject *kobj;
+	int rc;
+
+	kobj = kzalloc(sizeof(*kobj), GFP_KERNEL);
+	if (!kobj)
+		return ERR_PTR(-ENOMEM);
+
+	kobj->kset = lustre_kset;
+	kobject_init(kobj, &class_ktype);
+	rc = kobject_add(kobj, &lustre_kset->kobj, "%s", name);
+	if (rc) {
+		kobject_put(kobj);
+		return ERR_PTR(rc);
+	}
+	return kobj;
+}
+EXPORT_SYMBOL(class_setup_tunables);
+
 #define CLASS_MAX_NAME 1024
 
 int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
@@ -187,19 +204,17 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
 						     debugfs_lustre_root);
 
-	type->typ_kobj.kset = lustre_kset;
-	init_completion(&type->typ_kobj_unregister);
-	rc = kobject_init_and_add(&type->typ_kobj, &class_ktype,
-				  &lustre_kset->kobj, "%s", type->typ_name);
-	if (rc)
+	type->typ_kobj = class_setup_tunables(type->typ_name);
+	if (IS_ERR(type->typ_kobj)) {
+		rc = PTR_ERR(type->typ_kobj);
 		goto failed;
-
+	}
 
 	if (ldt) {
 		type->typ_lu = ldt;
 		rc = lu_device_type_init(ldt);
 		if (rc != 0) {
-			kobject_put(&type->typ_kobj);
+			kobject_put(type->typ_kobj);
 			goto failed;
 		}
 	}
@@ -237,8 +252,7 @@ int class_unregister_type(const char *name)
 		return -EBUSY;
 	}
 
-	kobject_put(&type->typ_kobj);
-	wait_for_completion(&type->typ_kobj_unregister);
+	kobject_put(type->typ_kobj);
 
 	debugfs_remove_recursive(type->typ_debugfs_entry);
 
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index b3ba554..f889fb8 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1027,7 +1027,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only)
 	obd->obd_ktype.sysfs_ops = &lustre_sysfs_ops;
 	obd->obd_ktype.release = obd_sysfs_release;
 
-	obd->obd_kset.kobj.parent = &obd->obd_type->typ_kobj;
+	obd->obd_kset.kobj.parent = obd->obd_type->typ_kobj;
 	obd->obd_kset.kobj.ktype = &obd->obd_ktype;
 	init_completion(&obd->obd_kobj_unregister);
 	rc = kset_register(&obd->obd_kset);
-- 
1.8.3.1

  parent reply	other threads:[~2018-08-17  3:10 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17  3:10 [lustre-devel] [PATCH 00/38] lustre: fixes for sysfs handling James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 01/38] lustre: llite: rename ldebugfs_[un]register_mountpoint James Simmons
2018-08-17  4:24   ` NeilBrown
2018-08-17 22:03     ` James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 02/38] lustre: llite: change ll_statfs_internal to use struct ll_sb_info James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 03/38] lustre: llite: move llite_root and llite_kset to lproc_llite.c James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 04/38] lustre: llite: remove ll_sb James Simmons
2018-08-17  4:27   ` NeilBrown
2018-08-18  0:35     ` James Simmons
2018-08-18  5:12       ` Andreas Dilger
2018-08-17  3:10 ` [lustre-devel] [PATCH 05/38] lustre: llite: change top kobject for llite into a kset James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 06/38] lustre: llite: rename llite_sb_release James Simmons
2018-08-17  5:56   ` NeilBrown
2018-08-17  3:10 ` [lustre-devel] [PATCH 07/38] lustre: llite: register mountpoint before process llog James Simmons
2018-08-17  6:21   ` NeilBrown
2018-08-17  3:10 ` [lustre-devel] [PATCH 08/38] lustre: llite: move lmd_profile handling James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 09/38] lustre: llite: add proper error handling for ll_debugfs_register_super() James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 10/38] lustre: llite: use C99 for struct lprocfs_llite_obd_vars James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 11/38] lustre: llite: create ll_stats_pid_write() James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 12/38] lustre: llite: improve sysfs file text in lproc_llite.c James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 13/38] lustre: llite: don't handle success case for blocksize sysfs code James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 14/38] lustre: llite: don't handle success case for kbyte* " James Simmons
2018-08-17  6:32   ` NeilBrown
2018-08-17  3:10 ` [lustre-devel] [PATCH 15/38] lustre: llite: don't handle success case for file* " James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 16/38] lustre: llite: user kstrtobool for some sysfs handling James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 17/38] lustre: llite: add newline to llite.*.offset_stats James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 18/38] lustre: obd: embedded struct lprocfs_vars in obd device James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 19/38] lustre: obdclass: swap obd device attrs and default_attrs James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 20/38] lustre: obdclass: embedded attributes in struct obd_device James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 21/38] lustre: obdclass: add light weight obd_def_uuid_attrs James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 22/38] lustre: obd: migrate to ksets James Simmons
2018-08-17  3:10 ` James Simmons [this message]
2018-08-17  3:10 ` [lustre-devel] [PATCH 24/38] lustre: obd: create conn_uuid sysfs file James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 25/38] lustre: obd: enhance print_lustre_cfg() James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 26/38] lustre: obd: merge both top lustre sysfs attributes James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 27/38] lustre: obd: resolve config log sysfs issues James Simmons
2018-08-17  6:52   ` NeilBrown
2018-08-17  3:10 ` [lustre-devel] [PATCH 28/38] lustre: obd: move ioctl handling to class_obd.c James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 29/38] lustre: llite: replace ll_process_config with class_modify_config James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 30/38] lustre: mgc: update sysfs handling James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 31/38] lustre: osc: fixup kstrto* for " James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 32/38] lustre: osc: restore cl_loi_list_lock James Simmons
2018-08-17  7:30   ` NeilBrown
2018-08-18  0:59     ` James Simmons
2018-08-18  5:08       ` Andreas Dilger
2018-08-18  5:10         ` Andreas Dilger
2018-08-17  3:10 ` [lustre-devel] [PATCH 33/38] lustre: osc: make unstable_stats a debugfs file James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 34/38] lustre: osc: enhance end to end bulk cksum error report James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 35/38] lustre: osc: update sysfs handling James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 36/38] lustre: lmv: " James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 37/38] lustre: lov: " James Simmons
2018-08-17  3:10 ` [lustre-devel] [PATCH 38/38] lustre: mdc: " James Simmons
2018-08-20  4:28 ` [lustre-devel] [PATCH 00/38] lustre: fixes for " NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1534475441-15543-24-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.