From fc117cc92d224466c1ec45de422f9f6624bbb1da Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 27 Jan 2017 22:47:24 -0500 Subject: [PATCH] LU-6245 libcfs: replace IS_PO2 with is_power_of_2 in server code Replaces IS_PO2 by is_power_of_2. It is more accurate to use is_power_of_2 since it returns 1 for numbers that are powers of 2 only whereas IS_PO2 returns 1 for 0 and numbers that are powers of 2. Change-Id: I595053a658a96818ac9b434377c275d3ed7143ec Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/24575 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- lustre/mdt/mdt_internal.h | 6 ++++-- lustre/obdclass/genops.c | 2 +- lustre/ofd/ofd_dev.c | 2 +- lustre/osd-zfs/osd_io.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index f48b9af..7b90b58 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -979,15 +979,17 @@ static inline bool mdt_slc_is_enabled(struct mdt_device *mdt) extern mdl_mode_t mdt_mdl_lock_modes[]; extern enum ldlm_mode mdt_dlm_lock_modes[]; +/* LCK_MINMODE which is zero returns false for is_power_of_2 */ + static inline mdl_mode_t mdt_dlm_mode2mdl_mode(enum ldlm_mode mode) { - LASSERT(IS_PO2(mode)); + LASSERT(mode == LCK_MINMODE || is_power_of_2(mode)); return mdt_mdl_lock_modes[mode]; } static inline enum ldlm_mode mdt_mdl_mode2dlm_mode(mdl_mode_t mode) { - LASSERT(IS_PO2(mode)); + LASSERT(mode == MDL_MINMODE || is_power_of_2(mode)); return mdt_dlm_lock_modes[mode]; } diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 9c05633..54edf1d 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1598,7 +1598,7 @@ void obd_exports_barrier(struct obd_device *obd) spin_unlock(&obd->obd_dev_lock); set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(waited)); - if (waited > 5 && IS_PO2(waited)) { + if (waited > 5 && is_power_of_2(waited)) { LCONSOLE_WARN("%s is waiting for obd_unlinked_exports " "more than %d seconds. " "The obd refcount = %d. Is it stuck?\n", diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 7dadae9..137a05d 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2984,7 +2984,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m, CERROR("%s: can't get statfs data, rc %d\n", obd->obd_name, rc); GOTO(err_fini_stack, rc); } - if (!IS_PO2(osfs->os_bsize)) { + if (!is_power_of_2(osfs->os_bsize)) { CERROR("%s: blocksize (%d) is not a power of 2\n", obd->obd_name, osfs->os_bsize); GOTO(err_fini_stack, rc = -EPROTO); diff --git a/lustre/osd-zfs/osd_io.c b/lustre/osd-zfs/osd_io.c index c8c17b5..1d3b230 100644 --- a/lustre/osd-zfs/osd_io.c +++ b/lustre/osd-zfs/osd_io.c @@ -527,7 +527,7 @@ static inline uint64_t osd_roundup2blocksz(uint64_t size, size += offset % blksz; - if (likely(IS_PO2(blksz))) + if (likely(is_power_of_2(blksz))) return PO2_ROUNDUP_TYPED(size, blksz, uint64_t); size += blksz - 1; -- 1.8.3.1