Skip to contentSkip to conversation

Staging: lustre: Use static inline functions instead of macros

PATCH Superseded Ksenija Stanojevic 2 participants 10 messages Oct 14, 2015 – Oct 17, 2015 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Staging: lustre: Use static inline functions instead of macros

Convert macros class_export_lock_get and class_export_lock_put into static inline functions and also remove some unused macros.

Ksenija Stanojevic (4):
Staging: lustre: include: Move function prototypes
Staging: lustre: include: Convert macro class_export_lock_get into
static inline function
Staging: lustre: include: Convert macro class_export_lock_put into
static inline function
Staging: lustre: include : Remove unused macros

 drivers/staging/lustre/lustre/include/obd_class.h | 90 ++++++++++-------------
 1 file changed, 38 insertions(+), 52 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 Staging: lustre: include: Move function prototypes

Function prototypes need to be declared before functions are being used.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 37 ++++++++++++-----------
 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +19 -18
index 82f1a26..4c2076e 100644
@@ -189,6 +189,25 @@ extern void (*class_export_dump_hook)(struct obd_export *);
 
 #endif
 
+/* genops.c */
+struct obd_export *class_export_get(struct obd_export *exp);
+void class_export_put(struct obd_export *exp);
+struct obd_export *class_new_export(struct obd_device *obddev,
+				struct obd_uuid *cluuid);
+void class_unlink_export(struct obd_export *exp);
+
+struct obd_import *class_import_get(struct obd_import *);
+void class_import_put(struct obd_import *);
+struct obd_import *class_new_import(struct obd_device *obd);
+void class_destroy_import(struct obd_import *exp);
+
+void class_put_type(struct obd_type *type);
+int class_connect(struct lustre_handle *conn, struct obd_device *obd,
+		struct obd_uuid *cluuid);
+int class_disconnect(struct obd_export *exp);
+void class_fail_export(struct obd_export *exp);
+int class_manual_cleanup(struct obd_device *obd);
+
 static inline void class_export_rpc_inc(struct obd_export *exp)
 {
 	atomic_inc(&(exp)->exp_rpc_count);
@@ -240,24 +259,6 @@ static inline void class_export_rpc_dec(struct obd_export *exp)
 	class_export_put(exp);					  \
 })
 
-/* genops.c */
-struct obd_export *class_export_get(struct obd_export *exp);
-void class_export_put(struct obd_export *exp);
-struct obd_export *class_new_export(struct obd_device *obddev,
-				    struct obd_uuid *cluuid);
-void class_unlink_export(struct obd_export *exp);
-
-struct obd_import *class_import_get(struct obd_import *);
-void class_import_put(struct obd_import *);
-struct obd_import *class_new_import(struct obd_device *obd);
-void class_destroy_import(struct obd_import *exp);
-
-void class_put_type(struct obd_type *type);
-int class_connect(struct lustre_handle *conn, struct obd_device *obd,
-		  struct obd_uuid *cluuid);
-int class_disconnect(struct obd_export *exp);
-void class_fail_export(struct obd_export *exp);
-int class_manual_cleanup(struct obd_device *obd);
 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
 {
 	return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
Signature · 1 line
1.9.1
maintainer
#2 lore raw

Re: [Outreachy kernel] [PATCH 1/4] Staging: lustre: include: Move function prototypes

Quoted 2 lines · Ksenija Stanojevic

Function prototypes need to be declared before functions are being used.

They do? What problem is this patch fixing, I don't see the error...

confused,

greg k-h

#3 lore raw

Re: [Outreachy kernel] [PATCH 1/4] Staging: lustre: include: Move function prototypes

Hi,

Quoted 5 lines · Greg KH
Quoted 2 lines · Ksenija Stanojevic

Function prototypes need to be declared before functions are being used.

They do? What problem is this patch fixing, I don't see the error...

These functions:

+struct obd_export *class_export_get(struct obd_export *exp); +void class_export_put(struct obd_export *exp)

are used in macros that I changed into static inline
functions. So if I don't move them, there will be warning: implicit declaration...

maintainer
#4 lore raw

Re: [Outreachy kernel] [PATCH 1/4] Staging: lustre: include: Move function prototypes

Quoted 15 lines · Ksenija Stanojević

Hi,

Quoted 5 lines · Greg KH
Quoted 2 lines · Ksenija Stanojevic

Function prototypes need to be declared before functions are being used.

They do? What problem is this patch fixing, I don't see the error...

These functions:

(quoted diff) +2 -0
+struct obd_export *class_export_get(struct obd_export *exp);
+void class_export_put(struct obd_export *exp)
 
 are used in macros that I changed into static inline
Quoted 2 lines

functions. So if I don't move them, there will be warning: implicit declaration...

Ah, then you needed to say that, please be more specific, I dropped this patch, and then the later ones failed horribly.

Please fix up and resend the series.

thanks,

greg k-h

#5 lore raw

PATCH 2/4 Staging: lustre: include: Convert macro class_export_lock_get into static inline function

In reply to Ksenija Stanojevic

Static inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +9 -8
index 4c2076e..5a57876 100644
@@ -223,14 +223,15 @@ static inline void class_export_rpc_dec(struct obd_export *exp)
 	       (exp), atomic_read(&(exp)->exp_rpc_count));
 }
 
-#define class_export_lock_get(exp, lock)				\
-({								      \
-	atomic_inc(&(exp)->exp_locks_count);			\
-	__class_export_add_lock_ref(exp, lock);			 \
-	CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n", \
-	       (exp), atomic_read(&(exp)->exp_locks_count));	\
-	class_export_get(exp);					  \
-})
+static inline struct obd_export *class_export_lock_get(struct obd_export *exp,
+						       struct ldlm_lock *lock)
+{
+	atomic_inc(&(exp)->exp_locks_count);
+	__class_export_add_lock_ref(exp, lock);
+	CDEBUG(D_INFO, "lock GETting export %p : new locks_count %d\n",
+	       (exp), atomic_read(&(exp)->exp_locks_count));
+	return class_export_get(exp);
+}
 
 #define class_export_lock_put(exp, lock)				\
 ({								      \
Signature · 1 line
1.9.1
maintainer
#6 lore raw

Re: [Outreachy kernel] [PATCH 2/4] Staging: lustre: include: Convert macro class_export_lock_get into static inline function

Quoted 7 lines · Ksenija Stanojevic

Static inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

This, and patch 3/4, break the build very badly, did you test these patches?

greg k-h

#7 lore raw

Re: [Outreachy kernel] [PATCH 2/4] Staging: lustre: include: Convert macro class_export_lock_get into static inline function

Quoted 11 lines · Greg KH
Quoted 7 lines · Ksenija Stanojevic

Static inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

This, and patch 3/4, break the build very badly, did you test these patches?

I'm sorry. Yes I did test them, with doing make on top of the directory. I will try again...

#8 lore raw

PATCH 3/4 Staging: lustre: include: Convert macro class_export_lock_put into static inline function

In reply to Ksenija Stanojevic

Static inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +10 -9
index 5a57876..4871b6a 100644
@@ -233,15 +233,16 @@ static inline struct obd_export *class_export_lock_get(struct obd_export *exp,
 	return class_export_get(exp);
 }
 
-#define class_export_lock_put(exp, lock)				\
-({								      \
-	LASSERT_ATOMIC_POS(&exp->exp_locks_count);		      \
-	atomic_dec(&(exp)->exp_locks_count);			\
-	__class_export_del_lock_ref(exp, lock);			 \
-	CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n", \
-	       (exp), atomic_read(&(exp)->exp_locks_count));	\
-	class_export_put(exp);					  \
-})
+static inline void class_export_lock_put(struct obd_export *exp,
+					 struct ldlm_lock *lock)
+{
+	LASSERT_ATOMIC_POS(&exp->exp_locks_count);
+	atomic_dec(&(exp)->exp_locks_count);
+	__class_export_del_lock_ref(exp, lock);
+	CDEBUG(D_INFO, "lock PUTting export %p : new locks_count %d\n",
+	       (exp), atomic_read(&(exp)->exp_locks_count));
+	class_export_put(exp);
+}
 
 #define class_export_cb_get(exp)					\
 ({								      \
Signature · 1 line
1.9.1
#9 lore raw

PATCH 4/4 Staging: lustre: include : Remove unused macros

In reply to Ksenija Stanojevic

These macro are not used anymore, therefore remove them.

---
 drivers/staging/lustre/lustre/include/obd_class.h | 17 -----------------
 1 file changed, 17 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +0 -17
index 4871b6a..53c255c 100644
@@ -244,23 +244,6 @@ static inline void class_export_lock_put(struct obd_export *exp,
 	class_export_put(exp);
 }
 
-#define class_export_cb_get(exp)					\
-({								      \
-	atomic_inc(&(exp)->exp_cb_count);			   \
-	CDEBUG(D_INFO, "callback GETting export %p : new cb_count %d\n",\
-	       (exp), atomic_read(&(exp)->exp_cb_count));	   \
-	class_export_get(exp);					  \
-})
-
-#define class_export_cb_put(exp)					\
-({								      \
-	LASSERT_ATOMIC_POS(&exp->exp_cb_count);			 \
-	atomic_dec(&(exp)->exp_cb_count);			   \
-	CDEBUG(D_INFO, "callback PUTting export %p : new cb_count %d\n",\
-	       (exp), atomic_read(&(exp)->exp_cb_count));	   \
-	class_export_put(exp);					  \
-})
-
 static inline enum obd_option exp_flags_from_obd(struct obd_device *obd)
 {
 	return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) |
Signature · 1 line
1.9.1