Use free segments if free segments is enough

Signed-off-by: Yunlei He <[email protected]>
---
 fsck/mount.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 678eeae..3e25165 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1890,23 +1890,14 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 
*to, int left, int type)
                        continue;
                }
 
-               if (se->valid_blocks == 0 && not_enough) {
-                       *to = left ? START_BLOCK(sbi, segno) - 1:
+               if (se->valid_blocks == 0) {
+                       if (not_enough) {
+                               *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;
-                       unsigned int i;
-
-                       for (i = 1; i < sbi->segs_per_sec; i++) {
-                               se2 = get_seg_entry(sbi, segno + i);
-                               if (se2->valid_blocks)
-                                       break;
-                       }
-                       if (i == sbi->segs_per_sec)
+                               continue;
+                       } else {
                                return 0;
+                       }
                }
 
                if (se->type == type &&
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to