Skip to contentSkip to conversation

staging: lustre: fix undefined references to obd_memory

PATCH In review John L. Hammond 2 participants 2 messages Sep 15, 2014 – Sep 19, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: fix undefined references to obd_memory

From: "John L. Hammond" <[email protected]>

If CONFIG_PROC_FS=n then obd_memory is not defined. So put the setup and cleanup of this variable within #ifdef CONFIG_PROC_FS guards.

---
 .../staging/lustre/lustre/include/obd_support.h    |    2 ++
 drivers/staging/lustre/lustre/obdclass/class_obd.c |    5 +++++
 2 files changed, 7 insertions(+)
drivers/staging/lustre/lustre/include/obd_support.h +2 -0
index 2991d2e..408ce7f 100644
@@ -43,12 +43,14 @@
 #include "lprocfs_status.h"
 
 /* global variables */
+#ifdef CONFIG_PROC_FS
 extern struct lprocfs_stats *obd_memory;
 enum {
 	OBD_MEMORY_STAT = 0,
 	OBD_MEMORY_PAGES_STAT = 1,
 	OBD_STATS_NUM,
 };
+#endif /* CONFIG_PROC_FS */
 
 extern unsigned int obd_debug_peer_on_timeout;
 extern unsigned int obd_dump_on_timeout;
drivers/staging/lustre/lustre/obdclass/class_obd.c +5 -0
index 8b8d338..2939f0c 100644
@@ -534,6 +534,7 @@ static int __init init_obdclass(void)
 	spin_lock_init(&obd_types_lock);
 	obd_zombie_impexp_init();
 
+#ifdef CONFIG_PROC_FS
 	obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
 					 LPROCFS_STATS_FLAG_NONE |
 					 LPROCFS_STATS_FLAG_IRQ_SAFE);
@@ -548,6 +549,7 @@ static int __init init_obdclass(void)
 	lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
 			     LPROCFS_CNTR_AVGMINMAX,
 			     "pagesused", "pages");
+#endif /* CONFIG_PROC_FS */
 
 	err = obd_init_checks();
 	if (err == -EOVERFLOW)
@@ -688,7 +690,10 @@ static void cleanup_obdclass(void)
 	memory_max = obd_memory_max();
 	pages_max = obd_pages_max();
 
+#ifdef CONFIG_PROC_FS
 	lprocfs_free_stats(&obd_memory);
+#endif /* CONFIG_PROC_FS */
+
 	CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
 	       "obd_memory max: %llu, leaked: %llu\n",
 	       memory_max, memory_leaked);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 51 lines · John L. Hammond

From: "John L. Hammond" <[email protected]>

If CONFIG_PROC_FS=n then obd_memory is not defined. So put the setup and cleanup of this variable within #ifdef CONFIG_PROC_FS guards.

---
 .../staging/lustre/lustre/include/obd_support.h    |    2 ++
 drivers/staging/lustre/lustre/obdclass/class_obd.c |    5 +++++
 2 files changed, 7 insertions(+)
drivers/staging/lustre/lustre/include/obd_support.h +2 -0
index 2991d2e..408ce7f 100644
@@ -43,12 +43,14 @@
 #include "lprocfs_status.h"
 
 /* global variables */
+#ifdef CONFIG_PROC_FS
 extern struct lprocfs_stats *obd_memory;
 enum {
 	OBD_MEMORY_STAT = 0,
 	OBD_MEMORY_PAGES_STAT = 1,
 	OBD_STATS_NUM,
 };
+#endif /* CONFIG_PROC_FS */
 
 extern unsigned int obd_debug_peer_on_timeout;
 extern unsigned int obd_dump_on_timeout;
drivers/staging/lustre/lustre/obdclass/class_obd.c +2 -0
index 8b8d338..2939f0c 100644
@@ -534,6 +534,7 @@ static int __init init_obdclass(void)
 	spin_lock_init(&obd_types_lock);
 	obd_zombie_impexp_init();
 
+#ifdef CONFIG_PROC_FS
 	obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
 					 LPROCFS_STATS_FLAG_NONE |
 					 LPROCFS_STATS_FLAG_IRQ_SAFE);
@@ -548,6 +549,7 @@ static int __init init_obdclass(void)
 	lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
 			     LPROCFS_CNTR_AVGMINMAX,
 			     "pagesused", "pages");
+#endif /* CONFIG_PROC_FS */
 
 	err = obd_init_checks();
 	if (err == -EOVERFLOW)

drivers/staging/lustre/lustre/obdclass/class_obd.c static void cleanup_obdclass(void) · line 695

Quoted 6 lines
drivers/staging/lustre/lustre/obdclass/class_obd.c +2 -0
@@ -688,7 +690,10 @@ static void cleanup_obdclass(void)
 	memory_max = obd_memory_max();
 	pages_max = obd_pages_max();
 
+#ifdef CONFIG_PROC_FS
 	lprocfs_free_stats(&obd_memory);
+#endif /* CONFIG_PROC_FS */

That's horrid.

Don't put #ifdef lines in .c files, put the proper stuff in the .h files, that way there is always a lprocfs_free_stats call.

thanks,

greg k-h