f2fs: no need to check other dirty_segmap when the seg has been found
authorHaicheng Li <haicheng.li@linux.intel.com>
Fri, 18 Oct 2013 09:24:08 +0000 (17:24 +0800)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 22 Oct 2013 10:57:31 +0000 (19:57 +0900)
Because one dirty seg can only be mapped to one dirty_type. Otherwise, it's a bug.

Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
[Jaegeuk Kim: modify a comment related to this patch]
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/segment.c

index 862fef3ae253db7605b52c64fae7ceedd84fc34f..8ac1619652420a26330d402e8dcf58a18bc049c0 100644 (file)
@@ -78,10 +78,14 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
        if (dirty_type == DIRTY) {
                enum dirty_type t = DIRTY_HOT_DATA;
 
-               /* clear all the bitmaps */
-               for (; t <= DIRTY_COLD_NODE; t++)
-                       if (test_and_clear_bit(segno, dirty_i->dirty_segmap[t]))
+               /* clear its dirty bitmap */
+               for (; t <= DIRTY_COLD_NODE; t++) {
+                       if (test_and_clear_bit(segno,
+                                               dirty_i->dirty_segmap[t])) {
                                dirty_i->nr_dirty[t]--;
+                               break;
+                       }
+               }
 
                if (get_valid_blocks(sbi, segno, sbi->segs_per_sec) == 0)
                        clear_bit(GET_SECNO(sbi, segno),