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>
}
/* using binary seach */
-static inline unsigned long __fls(long data)
+static __inline__ unsigned long fls(long data)
{
int pos = 32;
return pos;
}
-static inline unsigned long __ffs(long data)
+static __inline__ unsigned long __cfs_ffs(long data)
{
int pos = 0;
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);
return r;
}
-static inline unsigned long __ffs(unsigned long word)
+static inline unsigned long __cfs_ffs(unsigned long word)
{
int num = 0;
* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
*/
static inline
-int __fls(int x)
+int fls(int x)
{
int r = 32;
while (x < size) {
unsigned long val = *addr++;
if (val)
- return __ffs(val) + x;
+ return __cfs_ffs(val) + x;
x += (sizeof(*addr)<<3);
}
return x;
#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);
}
#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);
}
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++;
}
while (word <= last) {
if (*word != 0UL) {
- bit = __ffs(*word);
+ bit = __cfs_ffs(*word);
goto found;
}
word++;
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++;
}
while (word <= last) {
if (*word != ~0UL) {
- bit = __ffz(*word);
+ bit = ffz(*word);
goto found;
}
word++;
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);
}
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)