Skip to contentSkip to conversation

defrag.f2fs: enhance allocation speed

PATCH In review Jaegeuk Kim 2 participants 3 messages Dec 18, 2015 – Dec 19, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 defrag.f2fs: enhance allocation speed

This patch improves the allocation speed.

---
 fsck/f2fs.h  |  2 +-
 fsck/mount.c | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
fsck/f2fs.h +1 -1
index af5cc40..f990527 100644
@@ -295,7 +295,7 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi)
 #define GET_R2L_SEGNO(sbi, segno)	(segno + FREE_I_START_SEGNO(sbi))
 
 #define START_BLOCK(sbi, segno)	(SM_I(sbi)->main_blkaddr +		\
-	(segno << sbi->log_blocks_per_seg))
+	((segno) << sbi->log_blocks_per_seg))
 
 static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type)
 {
fsck/mount.c +6 -4
index 4b38df8..82af895 100644
@@ -1401,9 +1401,11 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		se = get_seg_entry(sbi, segno);
 
 		if (se->valid_blocks == sbi->blocks_per_seg ||
-				IS_CUR_SEGNO(sbi, segno, type))
-			goto next;
-
+				IS_CUR_SEGNO(sbi, segno, type)) {
+			*to = left ? START_BLOCK(sbi, segno - 1) :
+						START_BLOCK(sbi, segno + 1);
+			continue;
+		}
 		if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) {
 			struct seg_entry *se2;
 			int i;
@@ -1420,7 +1422,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		if (se->type == type &&
 			!f2fs_test_bit(offset, (const char *)se->cur_valid_map))
 			return 0;
-next:
+
 		*to = left ? *to - 1: *to + 1;
 	}
 	return -1;
Signature · 4 lines
2.5.4 (Apple Git-61)


------------------------------------------------------------------------------
#1 lore raw

Hi Jaegeuk,

Quoted 26 lines · Jaegeuk Kim

This patch improves the allocation speed.

---
 fsck/f2fs.h  |  2 +-
 fsck/mount.c | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
fsck/f2fs.h +1 -1
index af5cc40..f990527 100644
@@ -295,7 +295,7 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi)
 #define GET_R2L_SEGNO(sbi, segno)	(segno + FREE_I_START_SEGNO(sbi))
 
 #define START_BLOCK(sbi, segno)	(SM_I(sbi)->main_blkaddr +		\
-	(segno << sbi->log_blocks_per_seg))
+	((segno) << sbi->log_blocks_per_seg))
 
 static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type)
 {
fsck/mount.c +0 -0
index 4b38df8..82af895 100644

fsck/mount.c int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) · line 1405

Quoted 8 lines
fsck/mount.c +2 -3
@@ -1401,9 +1401,11 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		se = get_seg_entry(sbi, segno);
 
 		if (se->valid_blocks == sbi->blocks_per_seg ||
-				IS_CUR_SEGNO(sbi, segno, type))
-			goto next;
-
+				IS_CUR_SEGNO(sbi, segno, type)) {
+			*to = left ? START_BLOCK(sbi, segno - 1) :

When traversing leftward, shouldn't next position be

*to = left ? START_BLOCK(sbi, segno) - 1 : ?

Thanks,

Quoted 8 lines
fsck/mount.c +3 -0
+						START_BLOCK(sbi, segno + 1);
+			continue;
+		}
 		if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) {
 			struct seg_entry *se2;
 			int i;

fsck/mount.c int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) · line 1428

Quoted 8 lines
fsck/mount.c +1 -1
@@ -1420,7 +1422,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		if (se->type == type &&
 			!f2fs_test_bit(offset, (const char *)se->cur_valid_map))
 			return 0;
-next:
+
 		*to = left ? *to - 1: *to + 1;
 	}
 	return -1;

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

#2 lore raw

Hi Chao,

Quoted 40 lines · Chao Yu

Hi Jaegeuk,

Quoted 26 lines · Jaegeuk Kim

This patch improves the allocation speed.

---
 fsck/f2fs.h  |  2 +-
 fsck/mount.c | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)
fsck/f2fs.h +1 -1
index af5cc40..f990527 100644
@@ -295,7 +295,7 @@ static inline block_t __end_block_addr(struct f2fs_sb_info *sbi)
 #define GET_R2L_SEGNO(sbi, segno)	(segno + FREE_I_START_SEGNO(sbi))
 
 #define START_BLOCK(sbi, segno)	(SM_I(sbi)->main_blkaddr +		\
-	(segno << sbi->log_blocks_per_seg))
+	((segno) << sbi->log_blocks_per_seg))
 
 static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type)
 {
fsck/mount.c +0 -0
index 4b38df8..82af895 100644

fsck/mount.c int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) · line 1405

Quoted 8 lines
fsck/mount.c +2 -3
@@ -1401,9 +1401,11 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		se = get_seg_entry(sbi, segno);
 
 		if (se->valid_blocks == sbi->blocks_per_seg ||
-				IS_CUR_SEGNO(sbi, segno, type))
-			goto next;
-
+				IS_CUR_SEGNO(sbi, segno, type)) {
+			*to = left ? START_BLOCK(sbi, segno - 1) :

When traversing leftward, shouldn't next position be

Quoted 1 line

*to = left ? START_BLOCK(sbi, segno) - 1 : ?

Right. :)

Thanks,

Quoted 19 lines

Thanks,

Quoted 8 lines
fsck/mount.c +3 -0
+						START_BLOCK(sbi, segno + 1);
+			continue;
+		}
 		if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) {
 			struct seg_entry *se2;
 			int i;

fsck/mount.c int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) · line 1428

Quoted 8 lines
fsck/mount.c +1 -1
@@ -1420,7 +1422,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)
 		if (se->type == type &&
 			!f2fs_test_bit(offset, (const char *)se->cur_valid_map))
 			return 0;
-next:
+
 		*to = left ? *to - 1: *to + 1;
 	}
 	return -1;

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