linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mkfs.f2fs: remove extent_cache entry for parent directory
@ 2015-12-15 21:19 Jaegeuk Kim
  2015-12-15 21:19 ` [PATCH 2/3] lib: fix test_bit_le functions Jaegeuk Kim
  2015-12-15 21:19 ` [PATCH 3/3] lib: use u8/u32/u64 for bit operations Jaegeuk Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2015-12-15 21:19 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

Currently, directory should not have any extent cache entry.
Otherwise, fsck.f2fs will trigger a false-alarmed report.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 mkfs/f2fs_format.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index fff74a9..98a6bce 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -769,8 +769,8 @@ static int f2fs_write_root_inode(void)
 	raw_node->i.i_addr[0] = cpu_to_le32(data_blk_nor);
 
 	raw_node->i.i_ext.fofs = 0;
-	raw_node->i.i_ext.blk_addr = cpu_to_le32(data_blk_nor);
-	raw_node->i.i_ext.len = cpu_to_le32(1);
+	raw_node->i.i_ext.blk_addr = 0;
+	raw_node->i.i_ext.len = 0;
 
 	main_area_node_seg_blk_offset = get_sb(main_blkaddr);
 	main_area_node_seg_blk_offset += config.cur_seg[CURSEG_HOT_NODE] *
-- 
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] lib: fix test_bit_le functions
  2015-12-15 21:19 [PATCH 1/3] mkfs.f2fs: remove extent_cache entry for parent directory Jaegeuk Kim
@ 2015-12-15 21:19 ` Jaegeuk Kim
  2015-12-15 21:19 ` [PATCH 3/3] lib: use u8/u32/u64 for bit operations Jaegeuk Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2015-12-15 21:19 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch fixes test_bit_le functions for dentry bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c        | 12 ++++++------
 include/f2fs_fs.h  |  6 +++---
 lib/libf2fs.c      | 26 ++++++++++----------------
 mkfs/f2fs_format.c |  3 ++-
 4 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 58786f2..38391a9 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -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,
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 4927d24..decc7f4 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -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 *);
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 1802d9c..ab98a11 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -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)
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index 98a6bce..cb5379a 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -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] *
-- 
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] lib: use u8/u32/u64 for bit operations
  2015-12-15 21:19 [PATCH 1/3] mkfs.f2fs: remove extent_cache entry for parent directory Jaegeuk Kim
  2015-12-15 21:19 ` [PATCH 2/3] lib: fix test_bit_le functions Jaegeuk Kim
@ 2015-12-15 21:19 ` Jaegeuk Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2015-12-15 21:19 UTC (permalink / raw)
  To: linux-f2fs-devel; +Cc: Jaegeuk Kim

This cleans up the bit operations.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c       |  6 ++----
 include/f2fs_fs.h | 12 +++++-------
 lib/libf2fs.c     | 19 ++++++++-----------
 3 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 38391a9..3e67ffc 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -869,8 +869,7 @@ static void convert_encrypted_name(unsigned char *name, int len,
 }
 
 static void print_dentry(__u32 depth, __u8 *name,
-		unsigned char *bitmap,
-		struct f2fs_dir_entry *dentry,
+		u8 *bitmap, struct f2fs_dir_entry *dentry,
 		int max, int idx, int last_blk, int encrypted)
 {
 	int last_de = 0;
@@ -937,8 +936,7 @@ static int f2fs_check_hash_code(struct f2fs_dir_entry *dentry,
 }
 
 static int __chk_dentries(struct f2fs_sb_info *sbi, struct child_info *child,
-			unsigned char *bitmap,
-			struct f2fs_dir_entry *dentry,
+			u8 *bitmap, struct f2fs_dir_entry *dentry,
 			__u8 (*filenames)[F2FS_SLOT_LEN],
 			int max, int last_blk, int encrypted)
 {
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index decc7f4..f9060f2 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -855,16 +855,14 @@ 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 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 test_and_set_bit_le(u32, u8 *);
+extern int test_and_clear_bit_le(u32, u8 *);
+extern int test_bit_le(u32, const u8 *);
 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 *);
-extern unsigned long find_next_bit_le(const unsigned char *, unsigned long,
-		unsigned long);
-extern unsigned long find_next_zero_bit_le(const unsigned char *, unsigned long,
-		unsigned long);
+extern unsigned long find_next_bit_le(const u8 *, u64, u64);
+extern unsigned long find_next_zero_bit_le(const u8 *, u64, u64);
 
 extern u_int32_t f2fs_cal_crc32(u_int32_t, void *, int);
 extern int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len);
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index ab98a11..e9a1606 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -234,7 +234,7 @@ int get_bits_in_byte(unsigned char n)
 	return bits_in_byte[n];
 }
 
-int test_and_set_bit_le(unsigned int nr, unsigned char *addr)
+int test_and_set_bit_le(u32 nr, u8 *addr)
 {
 	int mask, retval;
 
@@ -245,7 +245,7 @@ int test_and_set_bit_le(unsigned int nr, unsigned char *addr)
 	return retval;
 }
 
-int test_and_clear_bit_le(unsigned int nr, unsigned char *addr)
+int test_and_clear_bit_le(u32 nr, u8 *addr)
 {
 	int mask, retval;
 
@@ -256,7 +256,7 @@ int test_and_clear_bit_le(unsigned int nr, unsigned char *addr)
 	return retval;
 }
 
-int test_bit_le(unsigned int nr, const unsigned char *addr)
+int test_bit_le(u32 nr, const u8 *addr)
 {
 	return ((1 << (nr & 7)) & (addr[nr >> 3]));
 }
@@ -295,7 +295,7 @@ int f2fs_clear_bit(unsigned int nr, char *addr)
 	return ret;
 }
 
-static inline unsigned long __ffs(unsigned char word)
+static inline u64 __ffs(u8 word)
 {
 	int num = 0;
 
@@ -315,10 +315,9 @@ static inline unsigned long __ffs(unsigned char word)
 /* Copied from linux/lib/find_bit.c */
 #define BITMAP_FIRST_BYTE_MASK(start) (0xff << ((start) & (BITS_PER_BYTE - 1)))
 
-static unsigned long _find_next_bit_le(const unsigned char *addr,
-		unsigned long nbits, unsigned long start, char invert)
+static u64 _find_next_bit_le(const u8 *addr, u64 nbits, u64 start, char invert)
 {
-	unsigned char tmp;
+	u8 tmp;
 
 	if (!nbits || start >= nbits)
 		return nbits;
@@ -340,15 +339,13 @@ static unsigned long _find_next_bit_le(const unsigned char *addr,
 	return min(start + __ffs(tmp), nbits);
 }
 
-unsigned long find_next_bit_le(const unsigned char *addr, unsigned long size,
-		unsigned long offset)
+u64 find_next_bit_le(const u8 *addr, u64 size, u64 offset)
 {
 	return _find_next_bit_le(addr, size, offset, 0);
 }
 
 
-unsigned long find_next_zero_bit_le(const unsigned char *addr,
-		unsigned long size, unsigned long offset)
+u64 find_next_zero_bit_le(const u8 *addr, u64 size, u64 offset)
 {
 	return _find_next_bit_le(addr, size, offset, 0xff);
 }
-- 
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-15 21:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 21:19 [PATCH 1/3] mkfs.f2fs: remove extent_cache entry for parent directory Jaegeuk Kim
2015-12-15 21:19 ` [PATCH 2/3] lib: fix test_bit_le functions Jaegeuk Kim
2015-12-15 21:19 ` [PATCH 3/3] lib: use u8/u32/u64 for bit operations Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).