lib: fix test_bit_le functions

This patch fixes test_bit_le functions for dentry bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2015-12-15 10:10:15 -08:00
parent c8514f82aa
commit ee65f6ebf2
4 changed files with 21 additions and 26 deletions

View File

@ -955,7 +955,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
/* readahead inode blocks */
for (i = 0; i < max; i++) {
if (test_bit(i, bitmap) == 0)
if (test_bit_le(i, bitmap) == 0)
continue;
ino = le32_to_cpu(dentry[i].ino);
@ -975,7 +975,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
}
for (i = 0; i < max;) {
if (test_bit(i, bitmap) == 0) {
if (test_bit_le(i, bitmap) == 0) {
i++;
continue;
}
@ -985,7 +985,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
if (config.fix_on) {
FIX_MSG("Clear bad dentry 0x%x with bad ino 0x%x",
i, le32_to_cpu(dentry[i].ino));
clear_bit(i, bitmap);
test_and_clear_bit_le(i, bitmap);
fixed = 1;
}
i++;
@ -998,7 +998,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
if (config.fix_on) {
FIX_MSG("Clear bad dentry 0x%x with bad ftype 0x%x",
i, ftype);
clear_bit(i, bitmap);
test_and_clear_bit_le(i, bitmap);
fixed = 1;
}
i++;
@ -1011,7 +1011,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
ASSERT_MSG("Bad dentry 0x%x with zero name_len", i);
if (config.fix_on) {
FIX_MSG("Clear bad dentry 0x%x", i);
clear_bit(i, bitmap);
test_and_clear_bit_le(i, bitmap);
fixed = 1;
}
i++;
@ -1053,7 +1053,7 @@ static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
int j;
for (j = 0; j < slots; j++)
clear_bit(i + j, bitmap);
test_and_clear_bit_le(i + j, bitmap);
FIX_MSG("Unlink [0x%x] - %s len[0x%x], type[0x%x]",
le32_to_cpu(dentry[i].ino),
name, name_len,

View File

@ -855,9 +855,9 @@ extern int log_base_2(u_int32_t);
extern unsigned int addrs_per_inode(struct f2fs_inode *);
extern int get_bits_in_byte(unsigned char n);
extern int set_bit(unsigned int nr,void * addr);
extern int clear_bit(unsigned int nr, void * addr);
extern int test_bit(unsigned int nr, const void * addr);
extern int test_and_set_bit_le(unsigned int, unsigned char *);
extern int test_and_clear_bit_le(unsigned int, unsigned char*);
extern int test_bit_le(unsigned int, const unsigned char *);
extern int f2fs_test_bit(unsigned int, const char *);
extern int f2fs_set_bit(unsigned int, char *);
extern int f2fs_clear_bit(unsigned int, char *);

View File

@ -234,37 +234,31 @@ int get_bits_in_byte(unsigned char n)
return bits_in_byte[n];
}
int set_bit(unsigned int nr, void *addr)
int test_and_set_bit_le(unsigned int nr, unsigned char *addr)
{
int mask, retval;
unsigned char *ADDR = (unsigned char *)addr;
ADDR += nr >> 3;
addr += nr >> 3;
mask = 1 << ((nr & 0x07));
retval = mask & *ADDR;
*ADDR |= mask;
retval = mask & *addr;
*addr |= mask;
return retval;
}
int clear_bit(unsigned int nr, void *addr)
int test_and_clear_bit_le(unsigned int nr, unsigned char *addr)
{
int mask, retval;
unsigned char *ADDR = (unsigned char *)addr;
ADDR += nr >> 3;
addr += nr >> 3;
mask = 1 << ((nr & 0x07));
retval = mask & *ADDR;
*ADDR &= ~mask;
retval = mask & *addr;
*addr &= ~mask;
return retval;
}
int test_bit(unsigned int nr, const void *addr)
int test_bit_le(unsigned int nr, const unsigned char *addr)
{
const __u32 *p = (const __u32 *)addr;
nr = nr ^ 0;
return ((1 << (nr & 31)) & (p[nr >> 5])) != 0;
return ((1 << (nr & 7)) & (addr[nr >> 3]));
}
int f2fs_test_bit(unsigned int nr, const char *p)

View File

@ -862,7 +862,8 @@ static int f2fs_add_default_dentry_root(void)
memcpy(dent_blk->filename[1], "..", 2);
/* bitmap for . and .. */
dent_blk->dentry_bitmap[0] = (1 << 1) | (1 << 0);
test_and_set_bit_le(0, dent_blk->dentry_bitmap);
test_and_set_bit_le(1, dent_blk->dentry_bitmap);
blk_size_bytes = 1 << get_sb(log_blocksize);
data_blk_offset = get_sb(main_blkaddr);
data_blk_offset += config.cur_seg[CURSEG_HOT_DATA] *