From 32dbb80b0dcf6774fcab1f4d79bfc119d27a25a2 Mon Sep 17 00:00:00 2001 From: Aya Mahfouz Date: Sat, 1 Sep 2018 15:03:55 -0400 Subject: [PATCH] LU-9855 include: replace OBD_CHECK_DEV by obd_check_dev Static inline functions are preferred over macros. Hence, the function obd_check_dev was introduced. obd_check_dev replaces the macro OBD_CHECK_DEV. All functions that call obd_check_dev store the return values and return them if they represent an error code. Some of the changes were carried out manually while others were done using coccinelle. Linux-commit: 4ca1b8fbe609b7c52aeaa78a5f4678efcc9b8d73 Test-Parameters: trivial Signed-off-by: Aya Mahfouz Signed-off-by: Greg Kroah-Hartman Signed-off-by: James Simmons Change-Id: Iad96cc151a711892d950bd2ccaa93b13d6b23ae5 Reviewed-on: https://review.whamcloud.com/33101 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans --- lustre/include/obd_class.h | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 8350cb1..293924e 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -358,6 +358,7 @@ void class_disconnect_exports(struct obd_device *obddev); int class_manual_cleanup(struct obd_device *obd); void class_disconnect_stale_exports(struct obd_device *, int (*test_export)(struct obd_export *)); + static inline enum obd_option exp_flags_from_obd(struct obd_device *obd) { return ((obd->obd_fail ? OBD_OPT_FAILOVER : 0) | @@ -395,20 +396,22 @@ void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj); #define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op #define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op -/* Ensure obd_setup: used for cleanup which must be called - while obd is stopping */ -#define OBD_CHECK_DEV(obd) \ -do { \ - if (!(obd)) { \ - CERROR("NULL device\n"); \ - RETURN(-ENODEV); \ - } \ -} while (0) +static inline int obd_check_dev(struct obd_device *obd) +{ + if (!obd) { + CERROR("NULL device\n"); + return -ENODEV; + } + return 0; +} /* ensure obd_setup and !obd_stopping */ #define OBD_CHECK_DEV_ACTIVE(obd) \ do { \ - OBD_CHECK_DEV(obd); \ + rc = obd_check_dev(obd); \ + if (rc) \ + return rc; \ + \ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ @@ -1172,7 +1175,10 @@ static inline int obd_notify(struct obd_device *obd, { int rc; ENTRY; - OBD_CHECK_DEV(obd); + + rc = obd_check_dev(obd); + if (rc) + return rc; if (!obd->obd_set_up) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); @@ -1261,8 +1267,13 @@ static inline int obd_health_check(const struct lu_env *env, static inline int obd_register_observer(struct obd_device *obd, struct obd_device *observer) { + int rc; ENTRY; - OBD_CHECK_DEV(obd); + + rc = obd_check_dev(obd); + if (rc) + return rc; + down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { up_write(&obd->obd_observer_link_sem); -- 1.8.3.1