Skip to contentSkip to conversation

staging: vc04_services: no need to check debugfs return values

PATCH New Greg Kroah-Hartman 2 participants 12 messages May 29, 2018 – Jun 1, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Greg Kroah-Hartman

author maintainer
#1 lore raw

PATCH 4/13 staging: vc04_services: no need to check debugfs return values

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Clean up the vchiq_arm code by not caring about the value of debugfs calls. This ends up removing a number of lines of code that are not needed.

Cc Eric Anholt <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Kees Cook <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Keerthi Reddy <[email protected]>
Cc linux-rpi-kernel at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 .../interface/vchiq_arm/vchiq_arm.c           | 13 +---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 72 +++----------------
 .../interface/vchiq_arm/vchiq_debugfs.h       |  4 +-
 3 files changed, 15 insertions(+), 74 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -11
index aaa264f3b598..bc05c69383b8 100644
@@ -2018,7 +2018,6 @@ vchiq_open(struct inode *inode, struct file *file)
 	vchiq_log_info(vchiq_arm_log_level, "vchiq_open");
 	switch (dev) {
 	case VCHIQ_MINOR: {
-		int ret;
 		VCHIQ_STATE_T *state = vchiq_get_state();
 		VCHIQ_INSTANCE_T instance;
 
@@ -2035,11 +2034,7 @@ vchiq_open(struct inode *inode, struct file *file)
 		instance->state = state;
 		instance->pid = current->tgid;
 
-		ret = vchiq_debugfs_add_instance(instance);
-		if (ret != 0) {
-			kfree(instance);
-			return ret;
-		}
+		vchiq_debugfs_add_instance(instance);
 
 		sema_init(&instance->insert_event, 0);
 		sema_init(&instance->remove_event, 0);
@@ -3630,9 +3625,7 @@ static int vchiq_probe(struct platform_device *pdev)
 		goto failed_device_create;
 
 	/* create debugfs entries */
-	err = vchiq_debugfs_init();
-	if (err != 0)
-		goto failed_debugfs_init;
+	vchiq_debugfs_init();
 
 	vchiq_log_info(vchiq_arm_log_level,
 		"vchiq: initialised - version %d (min %d), device %d.%d",
@@ -3645,8 +3638,6 @@ static int vchiq_probe(struct platform_device *pdev)
 
 	return 0;
 
-failed_debugfs_init:
-	device_destroy(vchiq_class, vchiq_devid);
 failed_device_create:
 	class_destroy(vchiq_class);
 failed_class_create:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +11 -61

132 lines not on this page · raw message

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h +2 -2
index 1d95e3d70621..3af6397ada19 100644
@@ -40,11 +40,11 @@ typedef struct vchiq_debugfs_node_struct {
     struct dentry *dentry;
 } VCHIQ_DEBUGFS_NODE_T;
 
-int vchiq_debugfs_init(void);
+void vchiq_debugfs_init(void);
 
 void vchiq_debugfs_deinit(void);
 
-int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
+void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
 
 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance);
 
Signature · 1 line
2.17.0
#2 lore raw

PATCH 4/13 staging: vc04_services: no need to check debugfs return values

Quoted 32 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Clean up the vchiq_arm code by not caring about the value of debugfs calls. This ends up removing a number of lines of code that are not needed.

Cc Eric Anholt <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Kees Cook <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Keerthi Reddy <[email protected]>
Cc linux-rpi-kernel at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 .../interface/vchiq_arm/vchiq_arm.c           | 13 +---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 72 +++----------------
 .../interface/vchiq_arm/vchiq_debugfs.h       |  4 +-
 3 files changed, 15 insertions(+), 74 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +0 -0
index 766b4fe5f32c..103fec955e2c 100644
@@ -314,31 +284,13 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 	debugfs_remove_recursive(node->dentry);
 }

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) · line 324

Quoted 10 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +1 -6
 
-int vchiq_debugfs_init(void)
+void vchiq_debugfs_init(void)
 {
-	BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
-
 	debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
-	if (debugfs_info.vchiq_cfg_dir == NULL)
-		goto fail;
-

I think now that we allow successful probe with this value NULL, module remove could vchiq_debugfs_deinit() -> vchiq_debugfs_top() -> BUG_ON(). I think the right solution would be to just drop that BUG_ON(). With that change (and probably just garbage-collecting that function), this will be enthusiastically:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180530/2fb101af/attachment-0001.sig>

author maintainer
#3 lore raw

PATCH 4/13 staging: vc04_services: no need to check debugfs return values

Quoted 51 lines · Eric Anholt
Quoted 32 lines · Greg Kroah-Hartman

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Clean up the vchiq_arm code by not caring about the value of debugfs calls. This ends up removing a number of lines of code that are not needed.

Cc Eric Anholt <[email protected]>
Cc Stefan Wahren <[email protected]>
Cc Kees Cook <[email protected]>
Cc Dan Carpenter <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Keerthi Reddy <[email protected]>
Cc linux-rpi-kernel at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 .../interface/vchiq_arm/vchiq_arm.c           | 13 +---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 72 +++----------------
 .../interface/vchiq_arm/vchiq_debugfs.h       |  4 +-
 3 files changed, 15 insertions(+), 74 deletions(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +0 -0
index 766b4fe5f32c..103fec955e2c 100644
@@ -314,31 +284,13 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 	debugfs_remove_recursive(node->dentry);
 }

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) · line 324

Quoted 10 lines
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +1 -6
 
-int vchiq_debugfs_init(void)
+void vchiq_debugfs_init(void)
 {
-	BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
-
 	debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
-	if (debugfs_info.vchiq_cfg_dir == NULL)
-		goto fail;
-

I think now that we allow successful probe with this value NULL, module remove could vchiq_debugfs_deinit() -> vchiq_debugfs_top() -> BUG_ON(). I think the right solution would be to just drop that BUG_ON(). With that change (and probably just garbage-collecting that function), this will be enthusiastically:

Quoted 1 line

Much better idea, I just did that and will send out the patch series now. The end result is nicer:

 3 files changed, 42 insertions(+), 140 deletions(-)

thanks for the suggestion.

greg k-h

author maintainer
#4 lore raw

PATCH 5/13 staging: lustre: no need to check debugfs return values

In reply to a message not in the archive

When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.

Clean up the lustre core code by not caring about the value of debugfs calls. This ends up removing a number of lines of code that are not needed.

Note, more work is needed to remove the unneeded debugfs wrapper functions in the future.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc NeilBrown <[email protected]>
Cc Ben Evans <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc "John L. Hammond" <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc Mathias Rav <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/obdclass/linux/linux-module.c      | 19 ++-----------------
 .../lustre/lustre/obdclass/lprocfs_status.c   | 11 -----------
 2 files changed, 2 insertions(+), 28 deletions(-)
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +2 -17
index d3196439985b..9c800580053b 100644
@@ -481,7 +481,6 @@ static const struct attribute_group lustre_attr_group = {
 int class_procfs_init(void)
 {
 	int rc = -ENOMEM;
-	struct dentry *file;
 
 	lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
 	if (!lustre_kobj)
@@ -495,23 +494,9 @@ int class_procfs_init(void)
 	}
 
 	debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
-	if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
-		rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
-					 : -ENOMEM;
-		debugfs_lustre_root = NULL;
-		sysfs_remove_group(lustre_kobj, &lustre_attr_group);
-		kobject_put(lustre_kobj);
-		goto out;
-	}
 
-	file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
-				   &obd_device_list_fops);
-	if (IS_ERR_OR_NULL(file)) {
-		rc = file ? PTR_ERR(file) : -ENOMEM;
-		sysfs_remove_group(lustre_kobj, &lustre_attr_group);
-		kobject_put(lustre_kobj);
-		goto out;
-	}
+	debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
+			    &obd_device_list_fops);
 out:
 	return rc;
 }
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0 -11
index eb6396add78d..c3f57b025f10 100644
@@ -315,10 +315,6 @@ struct dentry *ldebugfs_add_simple(struct dentry *root,
 	if (fops->write)
 		mode |= 0200;
 	entry = debugfs_create_file(name, mode, root, data, fops);
-	if (IS_ERR_OR_NULL(entry)) {
-		CERROR("LprocFS: No memory to create <debugfs> entry %s\n", name);
-		return entry ?: ERR_PTR(-ENOMEM);
-	}
 	return entry;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_add_simple);
@@ -348,8 +344,6 @@ int ldebugfs_add_vars(struct dentry *parent,
 					    list->data ?: data,
 					    list->fops ?: &lprocfs_generic_fops
 					   );
-		if (IS_ERR_OR_NULL(entry))
-			return entry ? PTR_ERR(entry) : -ENOMEM;
 		list++;
 	}
 	return 0;
@@ -1358,9 +1352,6 @@ int ldebugfs_register_stats(struct dentry *parent, const char *name,
 
 	entry = debugfs_create_file(name, 0644, parent, stats,
 				    &lprocfs_stats_seq_fops);
-	if (IS_ERR_OR_NULL(entry))
-		return entry ? PTR_ERR(entry) : -ENOMEM;
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_register_stats);
@@ -1588,8 +1579,6 @@ int ldebugfs_seq_create(struct dentry *parent, const char *name,
 	LASSERT((!seq_fops->write) == ((mode & 0222) == 0));
 
 	entry = debugfs_create_file(name, mode, parent, data, seq_fops);
-	if (IS_ERR_OR_NULL(entry))
-		return entry ? PTR_ERR(entry) : -ENOMEM;
 
 	return 0;
 }
Signature · 1 line
2.17.0
author maintainer
#5 lore raw

PATCH 6/13 staging: lustre: remove ldebugfs_add_simple() wrapper

In reply to a message not in the archive

It was only being called in one place, and is an unneeded wrapper function around debugfs_create_file() so just call the real debugfs function instead. This ends up cleaning up some unneeded error handling logic that was never needed as well.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Ben Evans <[email protected]>
Cc NeilBrown <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc Mathias Rav <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/lustre/include/lprocfs_status.h    |  5 -----
 drivers/staging/lustre/lustre/lov/lov_pool.c  | 21 +++++--------------
 .../lustre/lustre/obdclass/lprocfs_status.c   | 19 -----------------
 3 files changed, 5 insertions(+), 40 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +0 -5
index 1322ecffda13..9eac7dac8c7b 100644
@@ -447,11 +447,6 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
 			  const char *units);
 struct obd_export;
 int lprocfs_exp_cleanup(struct obd_export *exp);
-struct dentry *ldebugfs_add_simple(struct dentry *root,
-				   char *name,
-				   void *data,
-				   const struct file_operations *fops);
-
 int ldebugfs_register_stats(struct dentry *parent,
 			    const char *name,
 			    struct lprocfs_stats *stats);
drivers/staging/lustre/lustre/lov/lov_pool.c +5 -16
index 6d2dec9266b6..9ce7038c9b0e 100644
@@ -80,7 +80,6 @@ void lov_pool_putref(struct pool_desc *pool)
 	CDEBUG(D_INFO, "pool %p\n", pool);
 	if (atomic_dec_and_test(&pool->pool_refcount)) {
 		LASSERT(list_empty(&pool->pool_list));
-		LASSERT(!pool->pool_debugfs_entry);
 		lov_ost_pool_free(&pool->pool_obds);
 		kfree_rcu(pool, rcu);
 	}
@@ -377,18 +376,11 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 
 	/* get ref for debugfs file */
 	lov_pool_getref(new_pool);
-	new_pool->pool_debugfs_entry = ldebugfs_add_simple(
+
+	new_pool->pool_debugfs_entry = debugfs_create_file(poolname, 0444,
 						lov->lov_pool_debugfs_entry,
-						poolname, new_pool,
+						new_pool,
 						&pool_proc_operations);
-	if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) {
-		CWARN("Cannot add debugfs pool entry " LOV_POOLNAMEF "\n",
-		      poolname);
-		new_pool->pool_debugfs_entry = NULL;
-		lov_pool_putref(new_pool);
-	}
-	CDEBUG(D_INFO, "pool %p - proc %p\n",
-	       new_pool, new_pool->pool_debugfs_entry);
 
 	spin_lock(&obd->obd_dev_lock);
 	list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
@@ -443,11 +435,8 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
 	if (!pool)
 		return -ENOENT;
 
-	if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) {
-		CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry);
-		ldebugfs_remove(&pool->pool_debugfs_entry);
-		lov_pool_putref(pool);
-	}
+	ldebugfs_remove(&pool->pool_debugfs_entry);
+	lov_pool_putref(pool);
 
 	spin_lock(&obd->obd_dev_lock);
 	list_del_init(&pool->pool_list);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0 -19
index c3f57b025f10..68e85f46a146 100644
@@ -300,25 +300,6 @@ EXPORT_SYMBOL(lprocfs_seq_release);
 
 /* lprocfs API calls */
 
-struct dentry *ldebugfs_add_simple(struct dentry *root,
-				   char *name, void *data,
-				   const struct file_operations *fops)
-{
-	struct dentry *entry;
-	umode_t mode = 0;
-
-	if (!root || !name || !fops)
-		return ERR_PTR(-EINVAL);
-
-	if (fops->read)
-		mode = 0444;
-	if (fops->write)
-		mode |= 0200;
-	entry = debugfs_create_file(name, mode, root, data, fops);
-	return entry;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_add_simple);
-
 static const struct file_operations lprocfs_generic_fops = { };
 
 int ldebugfs_add_vars(struct dentry *parent,
Signature · 1 line
2.17.0
author maintainer
#6 lore raw

PATCH 7/13 staging: lustre: remove ldebugfs_register_stats() wrapper function

In reply to a message not in the archive

It was just calling debugfs_create_file() so unwind things and just call the real function instead. This ends up saving a number of lines as there was never any error handling happening anyway, so that all can be removed as well.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc Ben Evans <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc NeilBrown <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Patrick Farrell <[email protected]>
Cc Aliaksei Karaliou <[email protected]>
Cc Aastha Gupta <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc Mathias Rav <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Bob Glosman <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/lustre/include/lprocfs_status.h      |  4 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c  |  4 ++--
 .../staging/lustre/lustre/llite/lproc_llite.c   | 13 +++++--------
 .../lustre/lustre/obdclass/lprocfs_status.c     | 16 ++--------------
 .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 17 ++++++-----------
 5 files changed, 16 insertions(+), 38 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +1 -3
index 9eac7dac8c7b..7aafe873cb39 100644
@@ -447,9 +447,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
 			  const char *units);
 struct obd_export;
 int lprocfs_exp_cleanup(struct obd_export *exp);
-int ldebugfs_register_stats(struct dentry *parent,
-			    const char *name,
-			    struct lprocfs_stats *stats);
+extern const struct file_operations lprocfs_stats_seq_fops;
 
 /* lprocfs_status.c */
 int ldebugfs_add_vars(struct dentry *parent,
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +2 -2
index 53b8f33e54b5..b83e93256cd1 100644
@@ -627,8 +627,8 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 	lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
 			     LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
 			     "recalc_timing", "sec");
-	rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats",
-				     pl->pl_stats);
+	debugfs_create_file("stats", 0644, pl->pl_debugfs_entry, pl->pl_stats,
+			    &lprocfs_stats_seq_fops);
 
 out_free_name:
 	kfree(var_name);
drivers/staging/lustre/lustre/llite/lproc_llite.c +5 -8
index 164fe4d6b6b8..2297a14f00ca 100644
@@ -1209,10 +1209,9 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 				     (type & LPROCFS_CNTR_AVGMINMAX),
 				     llite_opcode_table[id].opname, ptr);
 	}
-	err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats",
-				      sbi->ll_stats);
-	if (err)
-		goto out;
+
+	debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry, sbi->ll_stats,
+			    &lprocfs_stats_seq_fops);
 
 	sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
 					       LPROCFS_STATS_FLAG_NONE);
@@ -1225,10 +1224,8 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 		lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
 				     ra_stat_string[id], "pages");
 
-	err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats",
-				      sbi->ll_ra_stats);
-	if (err)
-		goto out;
+	debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry,
+			    sbi->ll_ra_stats, &lprocfs_stats_seq_fops);
 
 	err = ldebugfs_add_vars(sbi->ll_debugfs_entry,
 				lprocfs_llite_obd_vars, sb);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2 -14
index 68e85f46a146..089a3d74f3ea 100644
@@ -1315,7 +1315,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static const struct file_operations lprocfs_stats_seq_fops = {
+const struct file_operations lprocfs_stats_seq_fops = {
 	.owner   = THIS_MODULE,
 	.open    = lprocfs_stats_seq_open,
 	.read    = seq_read,
@@ -1323,19 +1323,7 @@ static const struct file_operations lprocfs_stats_seq_fops = {
 	.llseek  = seq_lseek,
 	.release = lprocfs_seq_release,
 };
-
-int ldebugfs_register_stats(struct dentry *parent, const char *name,
-			    struct lprocfs_stats *stats)
-{
-	struct dentry *entry;
-
-	LASSERT(!IS_ERR_OR_NULL(parent));
-
-	entry = debugfs_create_file(name, 0644, parent, stats,
-				    &lprocfs_stats_seq_fops);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_register_stats);
+EXPORT_SYMBOL_GPL(lprocfs_stats_seq_fops);
 
 void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
 			  unsigned int conf, const char *name,
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +6 -11
index 36eea50a77e7..6022246c4459 100644
@@ -185,7 +185,7 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
 {
 	struct dentry *svc_debugfs_entry;
 	struct lprocfs_stats *svc_stats;
-	int i, rc;
+	int i;
 	unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
 					  LPROCFS_CNTR_STDDEV;
 
@@ -241,16 +241,11 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
 				     ll_opcode2str(opcode), "usec");
 	}
 
-	rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats);
-	if (rc < 0) {
-		if (dir)
-			ldebugfs_remove(&svc_debugfs_entry);
-		lprocfs_free_stats(&svc_stats);
-	} else {
-		if (dir)
-			*debugfs_root_ret = svc_debugfs_entry;
-		*stats_ret = svc_stats;
-	}
+	debugfs_create_file("stats", 0644, svc_debugfs_entry, svc_stats,
+			    &lprocfs_stats_seq_fops);
+	if (dir)
+		*debugfs_root_ret = svc_debugfs_entry;
+	*stats_ret = svc_stats;
 }
 
 static int
Signature · 1 line
2.17.0
author maintainer
#7 lore raw

PATCH 8/13 staging: lustre: remove ldebugfs_seq_create() wrapper function

In reply to a message not in the archive

It was just calling debugfs_create_file() so unwind things and just call the real function instead. This ends up saving a number of lines as there was never any error handling happening anyway, so that all can be removed as well.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc NeilBrown <[email protected]>
Cc Ben Evans <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc "John L. Hammond" <[email protected]>
Cc Vitaly Fertman <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc Mathias Rav <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Bob Glosman <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/lustre/include/lprocfs_status.h    |  5 ----
 .../staging/lustre/lustre/llite/lproc_llite.c | 30 ++++++-------------
 drivers/staging/lustre/lustre/lmv/lmv_obd.c   |  7 ++---
 drivers/staging/lustre/lustre/lov/lov_obd.c   |  6 ++--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 19 ++----------
 drivers/staging/lustre/lustre/osc/lproc_osc.c |  9 +++---
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c       |  8 ++---
 7 files changed, 21 insertions(+), 63 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +0 -5
index 7aafe873cb39..54abcc2eaeb6 100644
@@ -465,11 +465,6 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
 		      const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
 
-int ldebugfs_seq_create(struct dentry *parent,
-			const char *name,
-			umode_t mode,
-			const struct file_operations *seq_fops,
-			void *data);
 int ldebugfs_obd_seq_create(struct obd_device *dev,
 			    const char *name,
 			    umode_t mode,
drivers/staging/lustre/lustre/llite/lproc_llite.c +9 -21
index 2297a14f00ca..1f122f8a54dc 100644
@@ -1139,7 +1139,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 	struct obd_device *obd;
 	struct dentry *dir;
 	char name[MAX_STRING_SIZE + 1], *ptr;
-	int err, id, len, rc;
+	int err, id, len;
 
 	name[MAX_STRING_SIZE] = '\0';
 
@@ -1165,26 +1165,14 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 	}
 	sbi->ll_debugfs_entry = dir;
 
-	rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444,
-				 &vvp_dump_pgcache_file_ops, sbi);
-	if (rc)
-		CWARN("Error adding the dump_page_cache file\n");
-
-	rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644,
-				 &ll_rw_extents_stats_fops, sbi);
-	if (rc)
-		CWARN("Error adding the extent_stats file\n");
-
-	rc = ldebugfs_seq_create(sbi->ll_debugfs_entry,
-				 "extents_stats_per_process",
-				 0644, &ll_rw_extents_stats_pp_fops, sbi);
-	if (rc)
-		CWARN("Error adding the extents_stats_per_process file\n");
-
-	rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644,
-				 &ll_rw_offset_stats_fops, sbi);
-	if (rc)
-		CWARN("Error adding the offset_stats file\n");
+	debugfs_create_file("dump_page_cache", 0444, dir, sbi,
+			    &vvp_dump_pgcache_file_ops);
+	debugfs_create_file("extents_stats", 0644, dir, sbi,
+			    &ll_rw_extents_stats_fops);
+	debugfs_create_file("extents_stats_per_process", 0644,
+			    dir, sbi, &ll_rw_extents_stats_pp_fops);
+	debugfs_create_file("offset_stats", 0644, dir, sbi,
+			    &ll_rw_offset_stats_fops);
 
 	/* File operations stats */
 	sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -5
index 60cdba99e4a4..85b6e8392759 100644
@@ -1264,11 +1264,8 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	lprocfs_lmv_init_vars(&lvars);
 
 	lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
-	rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
-				 0444, &lmv_proc_target_fops, obd);
-	if (rc)
-		CWARN("%s: error adding LMV target_obd file: rc = %d\n",
-		      obd->obd_name, rc);
+	debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd,
+			    &lmv_proc_target_fops);
 	rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
 			     LUSTRE_CLI_FLD_HASH_DHT);
 	if (rc) {
drivers/staging/lustre/lustre/lov/lov_obd.c +2 -4
index 7123972d4d5b..a2a5f59dfc7a 100644
@@ -806,10 +806,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	lprocfs_lov_init_vars(&lvars);
 	lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
 
-	rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
-				 0444, &lov_proc_target_fops, obd);
-	if (rc)
-		CWARN("Error adding the target_obd file\n");
+	debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd,
+			    &lov_proc_target_fops);
 
 	lov->lov_pool_debugfs_entry = ldebugfs_register("pools",
 						     obd->obd_debugfs_entry,
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +2 -17
index 089a3d74f3ea..6e0ea4e76a1b 100644
@@ -1538,29 +1538,14 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
 }
 EXPORT_SYMBOL(lprocfs_find_named_value);
 
-int ldebugfs_seq_create(struct dentry *parent, const char *name,
-			umode_t mode, const struct file_operations *seq_fops,
-			void *data)
-{
-	struct dentry *entry;
-
-	/* Disallow secretly (un)writable entries. */
-	LASSERT((!seq_fops->write) == ((mode & 0222) == 0));
-
-	entry = debugfs_create_file(name, mode, parent, data, seq_fops);
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_seq_create);
-
 int ldebugfs_obd_seq_create(struct obd_device *dev,
 			    const char *name,
 			    umode_t mode,
 			    const struct file_operations *seq_fops,
 			    void *data)
 {
-	return ldebugfs_seq_create(dev->obd_debugfs_entry, name,
-				   mode, seq_fops, data);
+	debugfs_create_file(name, mode, dev->obd_debugfs_entry, data, seq_fops);
+	return 0;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_obd_seq_create);
 
drivers/staging/lustre/lustre/osc/lproc_osc.c +4 -5
index dc76c35ae801..31f49f3fca59 100644
@@ -805,11 +805,10 @@ int lproc_osc_attach_seqstat(struct obd_device *dev)
 {
 	int rc;
 
-	rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644,
-				 &osc_stats_fops, dev);
-	if (rc == 0)
-		rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
-					     &osc_rpc_stats_fops, dev);
+	debugfs_create_file("osc_stats", 0644, dev->obd_debugfs_entry, dev,
+			    &osc_stats_fops);
+	rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
+				     &osc_rpc_stats_fops, dev);
 
 	return rc;
 }
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +2 -6
index 6022246c4459..eb21a8dd3708 100644
@@ -1099,8 +1099,6 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry,
 		.release     = lprocfs_seq_release,
 	};
 
-	int rc;
-
 	ptlrpc_ldebugfs_register(entry, svc->srv_name,
 				 "stats", &svc->srv_debugfs_entry,
 				 &svc->srv_stats);
@@ -1110,10 +1108,8 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry,
 
 	ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL);
 
-	rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history",
-				 0400, &req_history_fops, svc);
-	if (rc)
-		CWARN("Error adding the req_history file\n");
+	debugfs_create_file("req_history", 0400, svc->srv_debugfs_entry, svc,
+			    &req_history_fops);
 }
 
 void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
Signature · 1 line
2.17.0
author maintainer
#8 lore raw

PATCH 9/13 staging: lustre: remove ldebugfs_obd_seq_create() wrapper function

In reply to a message not in the archive

It was just calling debugfs_create_file() so unwind things and just call the real function instead. This ends up saving a number of lines as there was never any error handling happening anyway, so that all can be removed as well.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Ben Evans <[email protected]>
Cc NeilBrown <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc Mathias Rav <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Roman Storozhenko <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/lustre/include/lprocfs_status.h    |  6 ------
 .../lustre/lustre/obdclass/lprocfs_status.c   | 11 ----------
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 10 +++------
 .../staging/lustre/lustre/osc/osc_internal.h  |  2 +-
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  | 21 ++++---------------
 5 files changed, 8 insertions(+), 42 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +0 -6
index 54abcc2eaeb6..cc230c520189 100644
@@ -465,12 +465,6 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
 		      const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
 
-int ldebugfs_obd_seq_create(struct obd_device *dev,
-			    const char *name,
-			    umode_t mode,
-			    const struct file_operations *seq_fops,
-			    void *data);
-
 /* Generic callbacks */
 
 int lprocfs_rd_uint(struct seq_file *m, void *data);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +0 -11
index 6e0ea4e76a1b..6e306cafa95a 100644
@@ -1538,17 +1538,6 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
 }
 EXPORT_SYMBOL(lprocfs_find_named_value);
 
-int ldebugfs_obd_seq_create(struct obd_device *dev,
-			    const char *name,
-			    umode_t mode,
-			    const struct file_operations *seq_fops,
-			    void *data)
-{
-	debugfs_create_file(name, mode, dev->obd_debugfs_entry, data, seq_fops);
-	return 0;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_obd_seq_create);
-
 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
 {
 	if (value >= OBD_HIST_MAX)
drivers/staging/lustre/lustre/osc/lproc_osc.c +3 -7
index 31f49f3fca59..6a705bc5420c 100644
@@ -801,16 +801,12 @@ static ssize_t osc_stats_seq_write(struct file *file,
 
 LPROC_SEQ_FOPS(osc_stats);
 
-int lproc_osc_attach_seqstat(struct obd_device *dev)
+void lproc_osc_attach_seqstat(struct obd_device *dev)
 {
-	int rc;
-
 	debugfs_create_file("osc_stats", 0644, dev->obd_debugfs_entry, dev,
 			    &osc_stats_fops);
-	rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
-				     &osc_rpc_stats_fops, dev);
-
-	return rc;
+	debugfs_create_file("rpc_stats", 0644, dev->obd_debugfs_entry, dev,
+			    &osc_rpc_stats_fops);
 }
 
 static struct attribute *osc_attrs[] = {
drivers/staging/lustre/lustre/osc/osc_internal.h +1 -1
index fca020568c19..4ddba1354bef 100644
@@ -141,7 +141,7 @@ unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock);
 
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
 
-int lproc_osc_attach_seqstat(struct obd_device *dev);
+void lproc_osc_attach_seqstat(struct obd_device *dev);
 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
 
 extern struct lu_device_type osc_device_type;
drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +4 -17
index fd609b63d2de..cd1bb3dabb63 100644
@@ -133,8 +133,6 @@ LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
 
 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
 {
-	int rc;
-
 	if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
 	    strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
 	    strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0) {
@@ -143,21 +141,10 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
 		return -EINVAL;
 	}
 
-	rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444,
-				     &sptlrpc_info_lprocfs_fops, dev);
-	if (rc) {
-		CERROR("create proc entry srpc_info for %s: %d\n",
-		       dev->obd_name, rc);
-		return rc;
-	}
-
-	rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444,
-				     &sptlrpc_ctxs_lprocfs_fops, dev);
-	if (rc) {
-		CERROR("create proc entry srpc_contexts for %s: %d\n",
-		       dev->obd_name, rc);
-		return rc;
-	}
+	debugfs_create_file("srpc_info", 0444, dev->obd_debugfs_entry, dev,
+			    &sptlrpc_info_lprocfs_fops);
+	debugfs_create_file("srpc_contexts", 0444, dev->obd_debugfs_entry, dev,
+			    &sptlrpc_ctxs_lprocfs_fops);
 
 	return 0;
 }
Signature · 1 line
2.17.0
author maintainer
#9 lore raw

PATCH 10/13 staging: lustre: unwrap some ldebugfs_register() calls

In reply to a message not in the archive

When the third option (list) to ldebugfs_register() is NULL, it's the same as just calling debugfs_create_dir(). So unwind this and call debugfs_create_dir() directly.

This ends up saving lots of code as we do not need to do any error checking of the return value (because it does not matter).

The ldebugfs_register() call will be removed in a later patch when it is fully removed, right now there are 2 outstanding users of it in the tree.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc NeilBrown <[email protected]>
Cc Aastha Gupta <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Patrick Farrell <[email protected]>
Cc Aliaksei Karaliou <[email protected]>
Cc "John L. Hammond" <[email protected]>
Cc Mathias Rav <[email protected]>
Cc Andriy Skulysh <[email protected]>
Cc Ben Evans <[email protected]>
Cc Bob Glosman <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../staging/lustre/lustre/fid/fid_request.c   | 20 +++--------
 .../staging/lustre/lustre/fld/fld_request.c   | 20 +++--------
 .../staging/lustre/lustre/ldlm/ldlm_pool.c    |  9 +----
 .../lustre/lustre/ldlm/ldlm_resource.c        | 34 +++----------------
 .../staging/lustre/lustre/llite/lproc_llite.c |  7 +---
 drivers/staging/lustre/lustre/lov/lov_obd.c   |  5 ++-
 .../staging/lustre/lustre/obdclass/genops.c   | 11 ++----
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c       | 11 ++----
 8 files changed, 24 insertions(+), 93 deletions(-)
drivers/staging/lustre/lustre/fid/fid_request.c +5 -15
index c674652af03a..dfcac0afa106 100644
@@ -299,17 +299,8 @@ static int seq_client_debugfs_init(struct lu_client_seq *seq)
 {
 	int rc;
 
-	seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name,
-						   seq_debugfs_dir,
-						   NULL, NULL);
-
-	if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) {
-		CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name);
-		rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry)
-					    : -ENOMEM;
-		seq->lcs_debugfs_entry = NULL;
-		return rc;
-	}
+	seq->lcs_debugfs_entry = debugfs_create_dir(seq->lcs_name,
+						    seq_debugfs_dir);
 
 	rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
 			       seq_client_debugfs_list, seq);
@@ -424,10 +415,9 @@ static int __init fid_init(void)
 	if (rc)
 		return rc;
 
-	seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
-					    debugfs_lustre_root,
-					    NULL, NULL);
-	return PTR_ERR_OR_ZERO(seq_debugfs_dir);
+	seq_debugfs_dir = debugfs_create_dir(LUSTRE_SEQ_NAME,
+					     debugfs_lustre_root);
+	return 0;
 }
 
 static void __exit fid_exit(void)
drivers/staging/lustre/lustre/fld/fld_request.c +5 -15
index 7b7ba93a4db6..409850379fc3 100644
@@ -221,17 +221,8 @@ static int fld_client_debugfs_init(struct lu_client_fld *fld)
 {
 	int rc;
 
-	fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name,
-						   fld_debugfs_dir,
-						   NULL, NULL);
-
-	if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) {
-		CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name);
-		rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry)
-					    : -ENOMEM;
-		fld->lcf_debugfs_entry = NULL;
-		return rc;
-	}
+	fld->lcf_debugfs_entry = debugfs_create_dir(fld->lcf_name,
+						    fld_debugfs_dir);
 
 	rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
 			       fld_client_debugfs_list, fld);
@@ -455,10 +446,9 @@ static int __init fld_init(void)
 	if (rc)
 		return rc;
 
-	fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME,
-					    debugfs_lustre_root,
-					    NULL, NULL);
-	return PTR_ERR_OR_ZERO(fld_debugfs_dir);
+	fld_debugfs_dir = debugfs_create_dir(LUSTRE_FLD_NAME,
+					     debugfs_lustre_root);
+	return 0;
 }
 
 static void __exit fld_exit(void)
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +1 -8
index b83e93256cd1..146b348ca312 100644
@@ -572,14 +572,7 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
 		rc = -EINVAL;
 		goto out_free_name;
 	}
-	pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
-						 NULL, NULL);
-	if (IS_ERR(pl->pl_debugfs_entry)) {
-		CERROR("LdebugFS failed in ldlm-pool-init\n");
-		rc = PTR_ERR(pl->pl_debugfs_entry);
-		pl->pl_debugfs_entry = NULL;
-		goto out_free_name;
-	}
+	pl->pl_debugfs_entry = debugfs_create_dir("pool", debugfs_ns_parent);
 
 	var_name[MAX_STRING_SIZE] = '\0';
 	memset(pool_vars, 0, sizeof(pool_vars));
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +5 -29
index 28cd8398d4ce..691899ef8044 100644
@@ -110,34 +110,13 @@ int ldlm_debugfs_setup(void)
 {
 	int rc;
 
-	ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME,
-					     debugfs_lustre_root,
-					     NULL, NULL);
-	if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) {
-		CERROR("LProcFS failed in ldlm-init\n");
-		rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM;
-		goto err;
-	}
+	ldlm_debugfs_dir = debugfs_create_dir(OBD_LDLM_DEVICENAME,
+					      debugfs_lustre_root);
 
-	ldlm_ns_debugfs_dir = ldebugfs_register("namespaces",
-						ldlm_debugfs_dir,
-						NULL, NULL);
-	if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) {
-		CERROR("LProcFS failed in ldlm-init\n");
-		rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir)
-					 : -ENOMEM;
-		goto err_type;
-	}
+	ldlm_ns_debugfs_dir = debugfs_create_dir("namespaces",
+						 ldlm_debugfs_dir);
 
-	ldlm_svc_debugfs_dir = ldebugfs_register("services",
-						 ldlm_debugfs_dir,
-						 NULL, NULL);
-	if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) {
-		CERROR("LProcFS failed in ldlm-init\n");
-		rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir)
-					  : -ENOMEM;
-		goto err_ns;
-	}
+	ldlm_svc_debugfs_dir = debugfs_create_dir("services", ldlm_debugfs_dir);
 
 	rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL);
 	if (rc) {
@@ -149,11 +128,8 @@ int ldlm_debugfs_setup(void)
 
 err_svc:
 	ldebugfs_remove(&ldlm_svc_debugfs_dir);
-err_ns:
 	ldebugfs_remove(&ldlm_ns_debugfs_dir);
-err_type:
 	ldebugfs_remove(&ldlm_debugfs_dir);
-err:
 	ldlm_svc_debugfs_dir = NULL;
 	ldlm_ns_debugfs_dir = NULL;
 	ldlm_debugfs_dir = NULL;
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -6
index 1f122f8a54dc..1ac36c9ed455 100644
@@ -1157,12 +1157,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 	snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len,
 		 lsi->lsi_lmd->lmd_profile, sb);
 
-	dir = ldebugfs_register(name, parent, NULL, NULL);
-	if (IS_ERR_OR_NULL(dir)) {
-		err = dir ? PTR_ERR(dir) : -ENOMEM;
-		sbi->ll_debugfs_entry = NULL;
-		return err;
-	}
+	dir = debugfs_create_dir(name, parent);
 	sbi->ll_debugfs_entry = dir;
 
 	debugfs_create_file("dump_page_cache", 0444, dir, sbi,
drivers/staging/lustre/lustre/lov/lov_obd.c +2 -3
index a2a5f59dfc7a..344ff4b20168 100644
@@ -809,9 +809,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 	debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd,
 			    &lov_proc_target_fops);
 
-	lov->lov_pool_debugfs_entry = ldebugfs_register("pools",
-						     obd->obd_debugfs_entry,
-						     NULL, NULL);
+	lov->lov_pool_debugfs_entry = debugfs_create_dir("pools",
+							 obd->obd_debugfs_entry);
 	return 0;
 
 out:
drivers/staging/lustre/lustre/obdclass/genops.c +2 -9
index af233b868742..3771452b836c 100644
@@ -170,15 +170,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	strcpy(type->typ_name, name);
 	spin_lock_init(&type->obd_type_lock);
 
-	type->typ_debugfs_entry = ldebugfs_register(type->typ_name,
-						    debugfs_lustre_root,
-						    NULL, type);
-	if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
-		rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
-					     : -ENOMEM;
-		type->typ_debugfs_entry = NULL;
-		goto failed;
-	}
+	type->typ_debugfs_entry = debugfs_create_dir(type->typ_name,
+						     debugfs_lustre_root);
 
 	type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
 	if (!type->typ_kobj) {
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +3 -8
index eb21a8dd3708..62404b08f390 100644
@@ -197,15 +197,10 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
 	if (!svc_stats)
 		return;
 
-	if (dir) {
-		svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL);
-		if (IS_ERR(svc_debugfs_entry)) {
-			lprocfs_free_stats(&svc_stats);
-			return;
-		}
-	} else {
+	if (dir)
+		svc_debugfs_entry = debugfs_create_dir(dir, root);
+	else
 		svc_debugfs_entry = root;
-	}
 
 	lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR,
 			     svc_counter_config, "req_waittime", "usec");
Signature · 1 line
2.17.0
author maintainer
#10 lore raw

PATCH 11/13 staging: lustre: remove last two users of ldebugfs_register()

In reply to a message not in the archive

ldebugfs_register() is just a call to debugfs_create_dir() and ldebugfs_add_vars() if the list option is set. Fix up the last two users of this function to just call these two functions instead, and delete the now unused ldebugfs_register() call.

This ends up cleaning up more code and making things smaller, always a good thing.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc NeilBrown <[email protected]>
Cc Ben Evans <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Julia Lawall <[email protected]>
Cc Mathias Rav <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Patrick Farrell <[email protected]>
Cc Nadav Amit <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../lustre/lustre/include/lprocfs_status.h    |  5 ---
 .../lustre/lustre/obdclass/lprocfs_status.c   | 39 ++-----------------
 .../lustre/lustre/ptlrpc/ptlrpc_internal.h    |  2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec.c    |  6 +--
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  | 17 ++------
 5 files changed, 8 insertions(+), 61 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +0 -5
index cc230c520189..912c65b2f72b 100644
@@ -454,11 +454,6 @@ int ldebugfs_add_vars(struct dentry *parent,
 		      struct lprocfs_vars *var,
 		      void *data);
 
-struct dentry *ldebugfs_register(const char *name,
-				 struct dentry *parent,
-				 struct lprocfs_vars *list,
-				 void *data);
-
 void ldebugfs_remove(struct dentry **entryp);
 
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +3 -36
index 6e306cafa95a..91af79facbc0 100644
@@ -338,32 +338,6 @@ void ldebugfs_remove(struct dentry **entryp)
 }
 EXPORT_SYMBOL_GPL(ldebugfs_remove);
 
-struct dentry *ldebugfs_register(const char *name,
-				 struct dentry *parent,
-				 struct lprocfs_vars *list, void *data)
-{
-	struct dentry *entry;
-
-	entry = debugfs_create_dir(name, parent);
-	if (IS_ERR_OR_NULL(entry)) {
-		entry = entry ?: ERR_PTR(-ENOMEM);
-		goto out;
-	}
-
-	if (!IS_ERR_OR_NULL(list)) {
-		int rc;
-
-		rc = ldebugfs_add_vars(entry, list, data);
-		if (rc != 0) {
-			debugfs_remove(entry);
-			entry = ERR_PTR(rc);
-		}
-	}
-out:
-	return entry;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_register);
-
 /* Generic callbacks */
 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
 			 char *buf)
@@ -1026,16 +1000,9 @@ int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
 		}
 	}
 
-	obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
-						   obd->obd_type->typ_debugfs_entry,
-						   list, obd);
-	if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
-		rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
-					    : -ENOMEM;
-		CERROR("error %d setting up lprocfs for %s\n",
-		       rc, obd->obd_name);
-		obd->obd_debugfs_entry = NULL;
-	}
+	obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name,
+					obd->obd_type->typ_debugfs_entry);
+	ldebugfs_add_vars(obd->obd_debugfs_entry, list, obd);
 
 	return rc;
 }
drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h +1 -1
index b7a8d7537a66..134b74234519 100644
@@ -264,7 +264,7 @@ void sptlrpc_enc_pool_fini(void);
 int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
 
 /* sec_lproc.c */
-int  sptlrpc_lproc_init(void);
+void sptlrpc_lproc_init(void);
 void sptlrpc_lproc_fini(void);
 
 /* sec_gc.c */
drivers/staging/lustre/lustre/ptlrpc/sec.c +1 -5
index 256421465bcd..e193f3346e6f 100644
@@ -2352,14 +2352,10 @@ int sptlrpc_init(void)
 	if (rc)
 		goto out_null;
 
-	rc = sptlrpc_lproc_init();
-	if (rc)
-		goto out_plain;
+	sptlrpc_lproc_init();
 
 	return 0;
 
-out_plain:
-	sptlrpc_plain_fini();
 out_null:
 	sptlrpc_null_fini();
 out_pool:
drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +3 -14
index cd1bb3dabb63..e8076dc7c950 100644
@@ -158,21 +158,10 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
 
 static struct dentry *sptlrpc_debugfs_dir;
 
-int sptlrpc_lproc_init(void)
+void sptlrpc_lproc_init(void)
 {
-	int rc;
-
-	LASSERT(!sptlrpc_debugfs_dir);
-
-	sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
-						sptlrpc_lprocfs_vars, NULL);
-	if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) {
-		rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir)
-					 : -ENOMEM;
-		sptlrpc_debugfs_dir = NULL;
-		return rc;
-	}
-	return 0;
+	sptlrpc_debugfs_dir = debugfs_create_dir("sptlrpc", debugfs_lustre_root);
+	ldebugfs_add_vars(sptlrpc_debugfs_dir, sptlrpc_lprocfs_vars, NULL);
 }
 
 void sptlrpc_lproc_fini(void)
Signature · 1 line
2.17.0
author maintainer
#11 lore raw

PATCH 12/13 staging: lustre: make ldebugfs_add_vars a void function

In reply to a message not in the archive

The call to ldebugfs_add_vars() can not really fail, so have it just return nothing, which allows us to clean up a lot of unused error handling code.

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc NeilBrown <[email protected]>
Cc Roman Storozhenko <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Aastha Gupta <[email protected]>
Cc Ben Evans <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Frank Zago <[email protected]>
Cc Patrick Farrell <[email protected]>
Cc Simo Koskinen <[email protected]>
Cc Andriy Skulysh <[email protected]>
Cc "John L. Hammond" <[email protected]>
Cc Mathias Rav <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../staging/lustre/lustre/fid/fid_request.c   | 37 ++++---------------
 .../staging/lustre/lustre/fld/fld_request.c   | 30 +++------------
 .../lustre/lustre/include/lprocfs_status.h    |  5 +--
 .../lustre/lustre/include/lustre_dlm.h        |  2 +-
 .../staging/lustre/lustre/ldlm/ldlm_lockd.c   |  4 +-
 .../lustre/lustre/ldlm/ldlm_resource.c        | 21 +----------
 .../staging/lustre/lustre/llite/lproc_llite.c |  5 +--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 17 ++++-----
 8 files changed, 27 insertions(+), 94 deletions(-)
drivers/staging/lustre/lustre/fid/fid_request.c +7 -30
index dfcac0afa106..bc748ab6645d 100644
@@ -295,26 +295,12 @@ static void seq_client_debugfs_fini(struct lu_client_seq *seq)
 		ldebugfs_remove(&seq->lcs_debugfs_entry);
 }
 
-static int seq_client_debugfs_init(struct lu_client_seq *seq)
+static void seq_client_debugfs_init(struct lu_client_seq *seq)
 {
-	int rc;
-
 	seq->lcs_debugfs_entry = debugfs_create_dir(seq->lcs_name,
 						    seq_debugfs_dir);
 
-	rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
-			       seq_client_debugfs_list, seq);
-	if (rc) {
-		CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
-		       seq->lcs_name, rc);
-		goto out_cleanup;
-	}
-
-	return 0;
-
-out_cleanup:
-	seq_client_debugfs_fini(seq);
-	return rc;
+	ldebugfs_add_vars(seq->lcs_debugfs_entry, seq_client_debugfs_list, seq);
 }
 
 static void seq_client_fini(struct lu_client_seq *seq)
@@ -327,13 +313,9 @@ static void seq_client_fini(struct lu_client_seq *seq)
 	}
 }
 
-static int seq_client_init(struct lu_client_seq *seq,
-			   struct obd_export *exp,
-			   enum lu_cli_type type,
-			   const char *prefix)
+static void seq_client_init(struct lu_client_seq *seq, struct obd_export *exp,
+			    enum lu_cli_type type, const char *prefix)
 {
-	int rc;
-
 	LASSERT(seq);
 	LASSERT(prefix);
 
@@ -354,10 +336,7 @@ static int seq_client_init(struct lu_client_seq *seq,
 	snprintf(seq->lcs_name, sizeof(seq->lcs_name),
 		 "cli-%s", prefix);
 
-	rc = seq_client_debugfs_init(seq);
-	if (rc)
-		seq_client_fini(seq);
-	return rc;
+	seq_client_debugfs_init(seq);
 }
 
 int client_fid_init(struct obd_device *obd,
@@ -380,12 +359,10 @@ int client_fid_init(struct obd_device *obd,
 	snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name);
 
 	/* Init client side sequence-manager */
-	rc = seq_client_init(cli->cl_seq, exp, type, prefix);
+	seq_client_init(cli->cl_seq, exp, type, prefix);
 	kfree(prefix);
-	if (rc)
-		goto out_free_seq;
 
-	return rc;
+	return 0;
 out_free_seq:
 	kfree(cli->cl_seq);
 	cli->cl_seq = NULL;
drivers/staging/lustre/lustre/fld/fld_request.c +6 -24
index 409850379fc3..cb67fee19451 100644
@@ -217,25 +217,12 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
 
 static struct dentry *fld_debugfs_dir;
 
-static int fld_client_debugfs_init(struct lu_client_fld *fld)
+static void fld_client_debugfs_init(struct lu_client_fld *fld)
 {
-	int rc;
-
 	fld->lcf_debugfs_entry = debugfs_create_dir(fld->lcf_name,
 						    fld_debugfs_dir);
 
-	rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
-			       fld_client_debugfs_list, fld);
-	if (rc) {
-		CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc);
-		goto out_cleanup;
-	}
-
-	return 0;
-
-out_cleanup:
-	fld_client_debugfs_fini(fld);
-	return rc;
+	ldebugfs_add_vars(fld->lcf_debugfs_entry, fld_client_debugfs_list, fld);
 }
 
 void fld_client_debugfs_fini(struct lu_client_fld *fld)
@@ -254,7 +241,7 @@ int fld_client_init(struct lu_client_fld *fld,
 		    const char *prefix, int hash)
 {
 	int cache_size, cache_threshold;
-	int rc;
+	int rc = 0;
 
 	snprintf(fld->lcf_name, sizeof(fld->lcf_name),
 		 "cli-%s", prefix);
@@ -284,15 +271,10 @@ int fld_client_init(struct lu_client_fld *fld,
 		goto out;
 	}
 
-	rc = fld_client_debugfs_init(fld);
-	if (rc)
-		goto out;
+	fld_client_debugfs_init(fld);
 out:
-	if (rc)
-		fld_client_fini(fld);
-	else
-		CDEBUG(D_INFO, "%s: Using \"%s\" hash\n",
-		       fld->lcf_name, fld->lcf_hash->fh_name);
+	CDEBUG(D_INFO, "%s: Using \"%s\" hash\n",
+	       fld->lcf_name, fld->lcf_hash->fh_name);
 	return rc;
 }
 EXPORT_SYMBOL(fld_client_init);
drivers/staging/lustre/lustre/include/lprocfs_status.h +2 -3
index 912c65b2f72b..b18bcb337504 100644
@@ -450,9 +450,8 @@ int lprocfs_exp_cleanup(struct obd_export *exp);
 extern const struct file_operations lprocfs_stats_seq_fops;
 
 /* lprocfs_status.c */
-int ldebugfs_add_vars(struct dentry *parent,
-		      struct lprocfs_vars *var,
-		      void *data);
+void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
+		       void *data);
 
 void ldebugfs_remove(struct dentry **entryp);
 
drivers/staging/lustre/lustre/include/lustre_dlm.h +1 -1
index b3532adac31c..2c55241258cc 100644
@@ -1185,7 +1185,7 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns,
 void ldlm_namespace_free_post(struct ldlm_namespace *ns);
 void ldlm_namespace_get(struct ldlm_namespace *ns);
 void ldlm_namespace_put(struct ldlm_namespace *ns);
-int ldlm_debugfs_setup(void);
+void ldlm_debugfs_setup(void);
 void ldlm_debugfs_cleanup(void);
 
 /* resource.c - internal */
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -3
index b0a29f50c7d6..5963e90d0938 100644
@@ -979,9 +979,7 @@ static int ldlm_setup(void)
 		goto out;
 	}
 
-	rc = ldlm_debugfs_setup();
-	if (rc != 0)
-		goto out;
+	ldlm_debugfs_setup();
 
 	memset(&conf, 0, sizeof(conf));
 	conf = (typeof(conf)) {
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +2 -19
index 691899ef8044..6b94a2b2a0fc 100644
@@ -106,10 +106,8 @@ static struct lprocfs_vars ldlm_debugfs_list[] = {
 	{ NULL }
 };
 
-int ldlm_debugfs_setup(void)
+void ldlm_debugfs_setup(void)
 {
-	int rc;
-
 	ldlm_debugfs_dir = debugfs_create_dir(OBD_LDLM_DEVICENAME,
 					      debugfs_lustre_root);
 
@@ -118,22 +116,7 @@ int ldlm_debugfs_setup(void)
 
 	ldlm_svc_debugfs_dir = debugfs_create_dir("services", ldlm_debugfs_dir);
 
-	rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL);
-	if (rc) {
-		CERROR("LProcFS failed in ldlm-init\n");
-		goto err_svc;
-	}
-
-	return 0;
-
-err_svc:
-	ldebugfs_remove(&ldlm_svc_debugfs_dir);
-	ldebugfs_remove(&ldlm_ns_debugfs_dir);
-	ldebugfs_remove(&ldlm_debugfs_dir);
-	ldlm_svc_debugfs_dir = NULL;
-	ldlm_ns_debugfs_dir = NULL;
-	ldlm_debugfs_dir = NULL;
-	return rc;
+	ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL);
 }
 
 void ldlm_debugfs_cleanup(void)
drivers/staging/lustre/lustre/llite/lproc_llite.c +1 -4
index 1ac36c9ed455..d2f42c727ed4 100644
@@ -1210,10 +1210,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 	debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry,
 			    sbi->ll_ra_stats, &lprocfs_stats_seq_fops);
 
-	err = ldebugfs_add_vars(sbi->ll_debugfs_entry,
-				lprocfs_llite_obd_vars, sb);
-	if (err)
-		goto out;
+	ldebugfs_add_vars(sbi->ll_debugfs_entry, lprocfs_llite_obd_vars, sb);
 
 	sbi->ll_kobj.kset = llite_kset;
 	init_completion(&sbi->ll_kobj_unregister);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +7 -10
index 91af79facbc0..a8299a8cdad9 100644
@@ -302,15 +302,13 @@ EXPORT_SYMBOL(lprocfs_seq_release);
 
 static const struct file_operations lprocfs_generic_fops = { };
 
-int ldebugfs_add_vars(struct dentry *parent,
-		      struct lprocfs_vars *list,
-		      void *data)
+void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *list,
+		       void *data)
 {
 	if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list))
-		return -EINVAL;
+		return;
 
 	while (list->name) {
-		struct dentry *entry;
 		umode_t mode = 0;
 
 		if (list->proc_mode != 0000) {
@@ -321,13 +319,12 @@ int ldebugfs_add_vars(struct dentry *parent,
 			if (list->fops->write)
 				mode |= 0200;
 		}
-		entry = debugfs_create_file(list->name, mode, parent,
-					    list->data ?: data,
-					    list->fops ?: &lprocfs_generic_fops
-					   );
+		debugfs_create_file(list->name, mode, parent,
+				    list->data ?: data,
+				    list->fops ?: &lprocfs_generic_fops);
 		list++;
 	}
-	return 0;
+	return;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_add_vars);
 
Signature · 1 line
2.17.0
author maintainer
#12 lore raw

PATCH 13/13 staging: lustre: get rid of ldebugfs_remove()

In reply to a message not in the archive

It was just a dumb wrapper around debugfs_remove_recursive() so just call the function properly. Also, there is no need to set the dentry to NULL, it's gone, who cares about it anymore...

Cc Oleg Drokin <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc James Simmons <[email protected]>
Cc NeilBrown <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Roman Storozhenko <[email protected]>
Cc Aastha Gupta <[email protected]>
Cc Ben Evans <[email protected]>
Cc Quentin Bouget <[email protected]>
Cc Arvind Yadav <[email protected]>
Cc Arushi Singhal <[email protected]>
Cc Patrick Farrell <[email protected]>
Cc Aliaksei Karaliou <[email protected]>
Cc Mathias Rav <[email protected]>
Cc Andriy Skulysh <[email protected]>
Cc Dafna Hirschfeld <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Bob Glosman <[email protected]>
Cc lustre-devel at lists.lustre.org
---
 .../staging/lustre/lustre/fid/fid_request.c   |  6 ++----
 .../staging/lustre/lustre/fld/fld_request.c   |  6 ++----
 .../lustre/lustre/include/lprocfs_status.h    |  2 --
 .../staging/lustre/lustre/ldlm/ldlm_pool.c    |  5 +----
 .../lustre/lustre/ldlm/ldlm_resource.c        | 21 ++++---------------
 .../staging/lustre/lustre/llite/lproc_llite.c | 14 ++++++-------
 drivers/staging/lustre/lustre/lov/lov_pool.c  |  4 ++--
 .../staging/lustre/lustre/obdclass/genops.c   |  3 +--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 10 +--------
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c       |  6 ++----
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  |  3 +--
 11 files changed, 22 insertions(+), 58 deletions(-)
drivers/staging/lustre/lustre/fid/fid_request.c +2 -4
index bc748ab6645d..a34fd90ca5e5 100644
@@ -291,8 +291,7 @@ EXPORT_SYMBOL(seq_client_flush);
 
 static void seq_client_debugfs_fini(struct lu_client_seq *seq)
 {
-	if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry))
-		ldebugfs_remove(&seq->lcs_debugfs_entry);
+	debugfs_remove_recursive(seq->lcs_debugfs_entry);
 }
 
 static void seq_client_debugfs_init(struct lu_client_seq *seq)
@@ -399,8 +398,7 @@ static int __init fid_init(void)
 
 static void __exit fid_exit(void)
 {
-	if (!IS_ERR_OR_NULL(seq_debugfs_dir))
-		ldebugfs_remove(&seq_debugfs_dir);
+	debugfs_remove_recursive(seq_debugfs_dir);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
drivers/staging/lustre/lustre/fld/fld_request.c +2 -4
index cb67fee19451..97f7ea632346 100644
@@ -227,8 +227,7 @@ static void fld_client_debugfs_init(struct lu_client_fld *fld)
 
 void fld_client_debugfs_fini(struct lu_client_fld *fld)
 {
-	if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry))
-		ldebugfs_remove(&fld->lcf_debugfs_entry);
+	debugfs_remove_recursive(fld->lcf_debugfs_entry);
 }
 EXPORT_SYMBOL(fld_client_debugfs_fini);
 
@@ -435,8 +434,7 @@ static int __init fld_init(void)
 
 static void __exit fld_exit(void)
 {
-	if (!IS_ERR_OR_NULL(fld_debugfs_dir))
-		ldebugfs_remove(&fld_debugfs_dir);
+	debugfs_remove_recursive(fld_debugfs_dir);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
drivers/staging/lustre/lustre/include/lprocfs_status.h +0 -2
index b18bcb337504..495e6f5f676b 100644
@@ -453,8 +453,6 @@ extern const struct file_operations lprocfs_stats_seq_fops;
 void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
 		       void *data);
 
-void ldebugfs_remove(struct dentry **entryp);
-
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
 		      const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +1 -4
index 146b348ca312..36d14ee4e5b1 100644
@@ -640,10 +640,7 @@ static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl)
 		lprocfs_free_stats(&pl->pl_stats);
 		pl->pl_stats = NULL;
 	}
-	if (pl->pl_debugfs_entry) {
-		ldebugfs_remove(&pl->pl_debugfs_entry);
-		pl->pl_debugfs_entry = NULL;
-	}
+	debugfs_remove_recursive(pl->pl_debugfs_entry);
 }
 
 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +4 -17
index 6b94a2b2a0fc..c93b019b8e37 100644
@@ -121,18 +121,9 @@ void ldlm_debugfs_setup(void)
 
 void ldlm_debugfs_cleanup(void)
 {
-	if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir))
-		ldebugfs_remove(&ldlm_svc_debugfs_dir);
-
-	if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir))
-		ldebugfs_remove(&ldlm_ns_debugfs_dir);
-
-	if (!IS_ERR_OR_NULL(ldlm_debugfs_dir))
-		ldebugfs_remove(&ldlm_debugfs_dir);
-
-	ldlm_svc_debugfs_dir = NULL;
-	ldlm_ns_debugfs_dir = NULL;
-	ldlm_debugfs_dir = NULL;
+	debugfs_remove_recursive(ldlm_svc_debugfs_dir);
+	debugfs_remove_recursive(ldlm_ns_debugfs_dir);
+	debugfs_remove_recursive(ldlm_debugfs_dir);
 }
 
 static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr,
@@ -358,11 +349,7 @@ static struct kobj_type ldlm_ns_ktype = {
 
 static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns)
 {
-	if (IS_ERR_OR_NULL(ns->ns_debugfs_entry))
-		CERROR("dlm namespace %s has no procfs dir?\n",
-		       ldlm_ns_name(ns));
-	else
-		ldebugfs_remove(&ns->ns_debugfs_entry);
+	debugfs_remove_recursive(ns->ns_debugfs_entry);
 
 	if (ns->ns_stats)
 		lprocfs_free_stats(&ns->ns_stats);
drivers/staging/lustre/lustre/llite/lproc_llite.c +6 -8
index d2f42c727ed4..49bf1b7ee311 100644
@@ -1234,7 +1234,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 				obd->obd_type->typ_name);
 out:
 	if (err) {
-		ldebugfs_remove(&sbi->ll_debugfs_entry);
+		debugfs_remove_recursive(sbi->ll_debugfs_entry);
 		lprocfs_free_stats(&sbi->ll_ra_stats);
 		lprocfs_free_stats(&sbi->ll_stats);
 	}
@@ -1243,13 +1243,11 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 
 void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi)
 {
-	if (sbi->ll_debugfs_entry) {
-		ldebugfs_remove(&sbi->ll_debugfs_entry);
-		kobject_put(&sbi->ll_kobj);
-		wait_for_completion(&sbi->ll_kobj_unregister);
-		lprocfs_free_stats(&sbi->ll_ra_stats);
-		lprocfs_free_stats(&sbi->ll_stats);
-	}
+	debugfs_remove_recursive(sbi->ll_debugfs_entry);
+	kobject_put(&sbi->ll_kobj);
+	wait_for_completion(&sbi->ll_kobj_unregister);
+	lprocfs_free_stats(&sbi->ll_ra_stats);
+	lprocfs_free_stats(&sbi->ll_stats);
 }
 
 #undef MAX_STRING_SIZE
drivers/staging/lustre/lustre/lov/lov_pool.c +2 -2
index 9ce7038c9b0e..b2a88ba72eb2 100644
@@ -410,7 +410,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 	list_del_init(&new_pool->pool_list);
 	lov->lov_pool_count--;
 	spin_unlock(&obd->obd_dev_lock);
-	ldebugfs_remove(&new_pool->pool_debugfs_entry);
+	debugfs_remove_recursive(new_pool->pool_debugfs_entry);
 	lov_ost_pool_free(&new_pool->pool_obds);
 	kfree(new_pool);
 
@@ -435,7 +435,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
 	if (!pool)
 		return -ENOENT;
 
-	ldebugfs_remove(&pool->pool_debugfs_entry);
+	debugfs_remove_recursive(pool->pool_debugfs_entry);
 	lov_pool_putref(pool);
 
 	spin_lock(&obd->obd_dev_lock);
drivers/staging/lustre/lustre/obdclass/genops.c +1 -2
index 3771452b836c..234f383ce6d9 100644
@@ -224,8 +224,7 @@ int class_unregister_type(const char *name)
 	if (type->typ_kobj)
 		kobject_put(type->typ_kobj);
 
-	if (!IS_ERR_OR_NULL(type->typ_debugfs_entry))
-		ldebugfs_remove(&type->typ_debugfs_entry);
+	debugfs_remove_recursive(type->typ_debugfs_entry);
 
 	if (type->typ_lu)
 		lu_device_type_fini(type->typ_lu);
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +1 -9
index a8299a8cdad9..bdbe6f52031a 100644
@@ -328,13 +328,6 @@ void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *list,
 }
 EXPORT_SYMBOL_GPL(ldebugfs_add_vars);
 
-void ldebugfs_remove(struct dentry **entryp)
-{
-	debugfs_remove_recursive(*entryp);
-	*entryp = NULL;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_remove);
-
 /* Generic callbacks */
 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
 			 char *buf)
@@ -1010,8 +1003,7 @@ int lprocfs_obd_cleanup(struct obd_device *obd)
 	if (!obd)
 		return -EINVAL;
 
-	if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry))
-		ldebugfs_remove(&obd->obd_debugfs_entry);
+	debugfs_remove_recursive(obd->obd_debugfs_entry);
 
 	kobject_put(&obd->obd_kobj);
 	wait_for_completion(&obd->obd_kobj_unregister);
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +2 -4
index 62404b08f390..0b638837f88b 100644
@@ -1158,8 +1158,7 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
 
 void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
 {
-	if (!IS_ERR_OR_NULL(svc->srv_debugfs_entry))
-		ldebugfs_remove(&svc->srv_debugfs_entry);
+	debugfs_remove_recursive(svc->srv_debugfs_entry);
 
 	if (svc->srv_stats)
 		lprocfs_free_stats(&svc->srv_stats);
@@ -1167,8 +1166,7 @@ void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
 
 void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
 {
-	if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry))
-		ldebugfs_remove(&obd->obd_svc_debugfs_entry);
+	debugfs_remove_recursive(obd->obd_svc_debugfs_entry);
 
 	if (obd->obd_svc_stats)
 		lprocfs_free_stats(&obd->obd_svc_stats);
drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +1 -2
index e8076dc7c950..2bb75ebd5d98 100644
@@ -166,6 +166,5 @@ void sptlrpc_lproc_init(void)
 
 void sptlrpc_lproc_fini(void)
 {
-	if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir))
-		ldebugfs_remove(&sptlrpc_debugfs_dir);
+	debugfs_remove_recursive(sptlrpc_debugfs_dir);
 }
Signature · 1 line
2.17.0