f2fs: avoid to issue redundant discard commands
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 27 Feb 2017 19:57:11 +0000 (11:57 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 27 Feb 2017 21:44:08 +0000 (13:44 -0800)
If segs_per_sec is over 1 like under SMR, previously f2fs issues discard
commands redundantly on the same section, since we didn't move end position
for the previous discard command.

E.g.,

                       start  end
                         |    |
      prefree_bitmap = [01111100111100]

And, after issue discard for this section,
                             end      start
                              |        |
      prefree_bitmap = [01111100111100]

Select this section again by searching from (end + 1),
                             start  end
                                |   |
      prefree_bitmap = [01111100111100]

Fixes: 36abef4e796d38 ("f2fs: introduce mode=lfs mount option")
Cc: <stable@vger.kernel.org>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index 9006d8ed6f525a69ecf8149d06443558e1384eca..4bd7a8b19332d176d78b0a40c24e7bb12bbe2f5e 100644 (file)
@@ -1036,6 +1036,8 @@ next:
                start = start_segno + sbi->segs_per_sec;
                if (start < end)
                        goto next;
+               else
+                       end = start - 1;
        }
        mutex_unlock(&dirty_i->seglist_lock);