2020-12-06 06:54:26

by Yun Levi

[permalink] [raw]
Subject: [PATCH v2 8/8] ufs/util.h: Apply new find_last_zero_bit.

Former find_last_zero_bit in ufs makes complie error when we add
find_last_zero_bit in lib/find_bit.c
We remove former find_last_zero_bit in ufs which iterates per char,
And apply new find_last_zero_bit in lib.

Signed-off-by: Levi Yun <[email protected]>
---
fs/ufs/util.h | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 4931bec1a01c..3024f2076feb 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -413,29 +413,6 @@ static inline unsigned _ubh_find_next_zero_bit_(
return (base << uspi->s_bpfshift) + pos - begin;
}

-static inline unsigned find_last_zero_bit (unsigned char * bitmap,
- unsigned size, unsigned offset)
-{
- unsigned bit, i;
- unsigned char * mapp;
- unsigned char map;
-
- mapp = bitmap + (size >> 3);
- map = *mapp--;
- bit = 1 << (size & 7);
- for (i = size; i > offset; i--) {
- if ((map & bit) == 0)
- break;
- if ((i & 7) != 0) {
- bit >>= 1;
- } else {
- map = *mapp--;
- bit = 1 << 7;
- }
- }
- return i;
-}
-
#define ubh_find_last_zero_bit(ubh,begin,size,offset) _ubh_find_last_zero_bit_(uspi,ubh,begin,size,offset)
static inline unsigned _ubh_find_last_zero_bit_(
struct ufs_sb_private_info * uspi, struct ufs_buffer_head * ubh,
@@ -453,15 +430,14 @@ static inline unsigned _ubh_find_last_zero_bit_(
size + (uspi->s_bpf - start), uspi->s_bpf)
- (uspi->s_bpf - start);
size -= count;
- pos = find_last_zero_bit (ubh->bh[base]->b_data,
- start, start - count);
- if (pos > start - count || !size)
+ pos = find_last_zero_bit_le(ubh->bh[base]->b_data, start + 1);
+ if ((pos < start + 1 && pos > start - count) || !size)
break;
base--;
start = uspi->s_bpf;
}
return (base << uspi->s_bpfshift) + pos - begin;
-}
+}

#define ubh_isblockclear(ubh,begin,block) (!_ubh_isblockset_(uspi,ubh,begin,block))

--
2.27.0