Staging: lustre: Use static inline functions instead of macros
v3 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.
Changes in v3:
- change commit message
- add space in signed-off-by line
Changes in v2:
- be more specific in commit message
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
PATCH v3 1/4 Staging: lustre: include: Move function prototypes
Functions:
struct obd_export *class_export_get(struct obd_export *exp); void class_export_put(struct obd_export *exp)
are being used in macros that are converted into static inline functions, therefore move function prototypes to avoid build error in later patches.
---
Changes in v3:
- change commit message
- add space in signed-off-by line
Changes in v2:
- be more specific in commit message
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
@@ -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
PATCH v3 2/4 Staging: lustre: include: Convert macro class_export_lock_get into static inline function
In reply to Ksenija StanojevicStatic inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.
---
Changes in v3:
- add space in signed-off-by line
Changes in v2:
- nothing
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
@@ -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
PATCH v3 3/4 Staging: lustre: include: Convert macro class_export_lock_put into static inline function
In reply to Ksenija StanojevicStatic inline functions are preferred over macros. This change is safe because the types of arguments at all the call sites are same.
---
Changes in v3:
- add space in signed-off-by line
Changes in v2:
- nothing
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
@@ -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
PATCH v3 4/4 Staging: lustre: include : Remove unused macros
In reply to Ksenija StanojevicThese macro are not used anymore, therefore remove them.
---
Changes in v3:
- add space in signed-off-by line
Changes in v2:
- nothing
drivers/staging/lustre/lustre/include/obd_class.h | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +0 -17
@@ -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
Quoted 4 lines · On Saturday 17 October 2015 18:13:15 Ksenija Stanojevic wrote:
Convert macros
class_export_lock_getandclass_export_lock_putinto static inline functions and also remove some unused macros.Signed-off-by Ksenija Stanojevic <[email protected]>
Whole series,
Hi Arnd,
Quoted 9 lines · Arnd Bergmann
Quoted 4 lines · On Saturday 17 October 2015 18:13:15 Ksenija Stanojevic wrote:
Convert macros
class_export_lock_getandclass_export_lock_putinto static inline functions and also remove some unused macros.Signed-off-by Ksenija Stanojevic <[email protected]>Whole series,
Reviewed-by Arnd Bergmann <[email protected]>
Greg already merged these patches