Whamcloud - gitweb
LU-6245 libcfs: replace IS_PO2 with is_power_of_2 in server code 75/24575/10
authorJames Simmons <uja.ornl@yahoo.com>
Sat, 28 Jan 2017 03:47:24 +0000 (22:47 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 7 Feb 2017 06:16:50 +0000 (06:16 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/24575
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/mdt/mdt_internal.h
lustre/obdclass/genops.c
lustre/ofd/ofd_dev.c
lustre/osd-zfs/osd_io.c

index f48b9af..7b90b58 100644 (file)
@@ -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[];
 
 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)
 {
 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)
 {
        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];
 }
 
        return mdt_dlm_lock_modes[mode];
 }
 
index 9c05633..54edf1d 100644 (file)
@@ -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));
                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",
                        LCONSOLE_WARN("%s is waiting for obd_unlinked_exports "
                                      "more than %d seconds. "
                                      "The obd refcount = %d. Is it stuck?\n",
index 7dadae9..137a05d 100644 (file)
@@ -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);
        }
                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);
                CERROR("%s: blocksize (%d) is not a power of 2\n",
                                obd->obd_name, osfs->os_bsize);
                GOTO(err_fini_stack, rc = -EPROTO);
index c8c17b5..1d3b230 100644 (file)
@@ -527,7 +527,7 @@ static inline uint64_t osd_roundup2blocksz(uint64_t size,
 
        size += offset % blksz;
 
 
        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;
                return PO2_ROUNDUP_TYPED(size, blksz, uint64_t);
 
        size += blksz - 1;