f2fs: enhance the bit operation for SSR
This patch enhances the existing bit operation when f2fs allocates SSR blocks. Reviewed-by: Chao Yu <chao2.yu@samsung.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
0cab80ee0c
commit
80609448cd
@ -132,47 +132,37 @@ static unsigned long __find_rev_next_zero_bit(const unsigned long *addr,
|
|||||||
unsigned long size, unsigned long offset)
|
unsigned long size, unsigned long offset)
|
||||||
{
|
{
|
||||||
const unsigned long *p = addr + BIT_WORD(offset);
|
const unsigned long *p = addr + BIT_WORD(offset);
|
||||||
unsigned long result = offset & ~(BITS_PER_LONG - 1);
|
unsigned long result = size;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
|
|
||||||
if (offset >= size)
|
if (offset >= size)
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
size -= result;
|
size -= (offset & ~(BITS_PER_LONG - 1));
|
||||||
offset %= BITS_PER_LONG;
|
offset %= BITS_PER_LONG;
|
||||||
if (!offset)
|
|
||||||
goto aligned;
|
|
||||||
|
|
||||||
tmp = __reverse_ulong((unsigned char *)p);
|
while (1) {
|
||||||
tmp |= ~((~0UL << offset) >> offset);
|
if (*p == ~0UL)
|
||||||
|
goto pass;
|
||||||
|
|
||||||
if (size < BITS_PER_LONG)
|
|
||||||
goto found_first;
|
|
||||||
if (tmp != ~0UL)
|
|
||||||
goto found_middle;
|
|
||||||
|
|
||||||
size -= BITS_PER_LONG;
|
|
||||||
result += BITS_PER_LONG;
|
|
||||||
p++;
|
|
||||||
aligned:
|
|
||||||
while (size & ~(BITS_PER_LONG - 1)) {
|
|
||||||
tmp = __reverse_ulong((unsigned char *)p);
|
tmp = __reverse_ulong((unsigned char *)p);
|
||||||
|
|
||||||
|
if (offset)
|
||||||
|
tmp |= ~0UL << (BITS_PER_LONG - offset);
|
||||||
|
if (size < BITS_PER_LONG)
|
||||||
|
tmp |= ~0UL >> size;
|
||||||
if (tmp != ~0UL)
|
if (tmp != ~0UL)
|
||||||
goto found_middle;
|
goto found;
|
||||||
result += BITS_PER_LONG;
|
pass:
|
||||||
|
if (size <= BITS_PER_LONG)
|
||||||
|
break;
|
||||||
size -= BITS_PER_LONG;
|
size -= BITS_PER_LONG;
|
||||||
|
offset = 0;
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (!size)
|
return result;
|
||||||
return result;
|
found:
|
||||||
|
return result - size + __reverse_ffz(tmp);
|
||||||
tmp = __reverse_ulong((unsigned char *)p);
|
|
||||||
found_first:
|
|
||||||
tmp |= ~(~0UL << (BITS_PER_LONG - size));
|
|
||||||
if (tmp == ~0UL) /* Are any bits zero? */
|
|
||||||
return result + size; /* Nope. */
|
|
||||||
found_middle:
|
|
||||||
return result + __reverse_ffz(tmp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void register_inmem_page(struct inode *inode, struct page *page)
|
void register_inmem_page(struct inode *inode, struct page *page)
|
||||||
|
Loading…
Reference in New Issue
Block a user