Whamcloud - gitweb
LU-3963 Revert bitops changes 78/9978/3
authorOleg Drokin <oleg.drokin@intel.com>
Wed, 16 Apr 2014 18:37:53 +0000 (14:37 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 17 Apr 2014 04:42:21 +0000 (04:42 +0000)
This reverts bitops portions of http://review.whamcloud.com/7803
commit 001b8dbfacb747f1649a2eb047a5f118ce32fdc7

The uncovered problem is such that previously used fls returned 0
for the case of no bits set where as __fls return value
for such a case is undefined in the case of at least Linux kernel.

Change-Id: I993674161b08791157781a2b1da0872b12358bb1
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: http://review.whamcloud.com/9978
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
libcfs/include/libcfs/user-bitops.h
libcfs/include/libcfs/winnt/portals_utils.h
libcfs/libcfs/hash.c
libcfs/libcfs/user-bitops.c
lustre/obdclass/lprocfs_status.c
lustre/ofd/ofd_dev.c

index 7b31bc9..1b16ca7 100644 (file)
@@ -76,7 +76,7 @@ static inline int test_bit(int nr, const unsigned long *addr)
 }
 
 /* using binary seach */
-static inline unsigned long __fls(long data)
+static __inline__ unsigned long fls(long data)
 {
        int pos = 32;
 
@@ -115,7 +115,7 @@ static inline unsigned long __fls(long data)
        return pos;
 }
 
-static inline unsigned long __ffs(long data)
+static __inline__ unsigned long __cfs_ffs(long data)
 {
         int pos = 0;
 
@@ -147,8 +147,8 @@ static inline unsigned long __ffs(long data)
         return pos;
 }
 
-#define __ffz(x)       __ffs(~(x))
-#define __flz(x)       __fls(~(x))
+#define ffz(x)         ffs(~(x))
+#define flz(x)         fls(~(x))
 
 unsigned long find_next_bit(unsigned long *addr,
                            unsigned long size, unsigned long offset);
index b8678d9..39ab41f 100644 (file)
@@ -141,7 +141,7 @@ static inline int ffs(int x)
         return r;
 }
 
-static inline unsigned long __ffs(unsigned long word)
+static inline unsigned long __cfs_ffs(unsigned long word)
 {
         int num = 0;
 
@@ -180,7 +180,7 @@ static inline unsigned long __ffs(unsigned long word)
  * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
  */
 static inline
-int __fls(int x)
+int fls(int x)
 {
         int r = 32;
 
@@ -217,7 +217,7 @@ static inline unsigned find_first_bit(const unsigned long *addr,
         while (x < size) {
                 unsigned long val = *addr++;
                 if (val)
-                        return __ffs(val) + x;
+                        return __cfs_ffs(val) + x;
                 x += (sizeof(*addr)<<3);
         }
         return x;
index af0b3a9..0c4faf8 100644 (file)
@@ -2131,7 +2131,7 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size)
 #endif
                 }
                 total += bd.bd_bucket->hsb_count;
-               dist[min(__fls(bd.bd_bucket->hsb_count/max(theta,1)),7UL)]++;
+                dist[min(fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++;
                 cfs_hash_bd_unlock(hs, &bd, 0);
         }
 
@@ -2200,7 +2200,7 @@ int cfs_hash_debug_str_seq(cfs_hash_t *hs, struct seq_file *m)
 #endif
                }
                total += bd.bd_bucket->hsb_count;
-               dist[min(__fls(bd.bd_bucket->hsb_count/max(theta,1)),7UL)]++;
+               dist[min(fls(bd.bd_bucket->hsb_count/max(theta,1)),7)]++;
                cfs_hash_bd_unlock(hs, &bd, 0);
        }
 
index 26228ee..65f2da9 100644 (file)
@@ -55,7 +55,7 @@ unsigned long find_next_bit(unsigned long *addr,
                 return size;
         if (first_bit != 0) {
                 int tmp = (*word++) & (~0UL << first_bit);
-                bit = __ffs(tmp);
+                bit = __cfs_ffs(tmp);
                 if (bit < BITS_PER_LONG)
                         goto found;
                 word++;
@@ -63,7 +63,7 @@ unsigned long find_next_bit(unsigned long *addr,
         }
         while (word <= last) {
                 if (*word != 0UL) {
-                        bit = __ffs(*word);
+                        bit = __cfs_ffs(*word);
                         goto found;
                 }
                 word++;
@@ -89,7 +89,7 @@ unsigned long find_next_zero_bit(unsigned long *addr,
                 return size;
         if (first_bit != 0) {
                 int tmp = (*word++) & (~0UL << first_bit);
-               bit = __ffz(tmp);
+                bit = ffz(tmp);
                 if (bit < BITS_PER_LONG)
                         goto found;
                 word++;
@@ -97,7 +97,7 @@ unsigned long find_next_zero_bit(unsigned long *addr,
         }
         while (word <= last) {
                 if (*word != ~0UL) {
-                       bit = __ffz(*word);
+                        bit = ffz(*word);
                         goto found;
                 }
                 word++;
index 9527bb2..9956ada 100644 (file)
@@ -3281,7 +3281,7 @@ void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
        unsigned int val = 0;
 
        if (likely(value != 0))
-               val = min_t(unsigned int, __fls(value - 1), OBD_HIST_MAX);
+               val = min(fls(value - 1), OBD_HIST_MAX);
 
        lprocfs_oh_tally(oh, val);
 }
index d7ca3f4..3166fb7 100644 (file)
@@ -2200,7 +2200,7 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m,
                                obd->obd_name, osfs->os_bsize);
                GOTO(err_fini_stack, rc = -EPROTO);
        }
-       m->ofd_blockbits = __fls(osfs->os_bsize) - 1;
+       m->ofd_blockbits = fls(osfs->os_bsize) - 1;
 
        m->ofd_precreate_batch = OFD_PRECREATE_BATCH_DEFAULT;
        if (osfs->os_bsize * osfs->os_blocks < OFD_PRECREATE_SMALL_FS)