summaryrefslogtreecommitdiffstats
path: root/fs/f2fs
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2017-06-30 05:19:02 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2017-07-07 13:34:43 -0400
commit6915ea9d8dd8690570fe4a9864b898447a4f3da0 (patch)
tree4869631259426e1b6985d66002761d10e5bef037 /fs/f2fs
parentcce1325247b9faafc520c5789fe60feef1fd7092 (diff)
f2fs: introduce __check_sit_bitmap
After we introduce discard thread, discard command can be issued concurrently with data allocating, this patch adds new function to heck sit bitmap to ensure that userdata was invalid in which on-going discard command covered. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r--fs/f2fs/segment.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 6eaa98ea8ec6..4c246e351103 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -763,6 +763,30 @@ static void f2fs_submit_discard_endio(struct bio *bio)
763 bio_put(bio); 763 bio_put(bio);
764} 764}
765 765
766void __check_sit_bitmap(struct f2fs_sb_info *sbi,
767 block_t start, block_t end)
768{
769#ifdef CONFIG_F2FS_CHECK_FS
770 struct seg_entry *sentry;
771 unsigned int segno;
772 block_t blk = start;
773 unsigned long offset, size, max_blocks = sbi->blocks_per_seg;
774 unsigned long *map;
775
776 while (blk < end) {
777 segno = GET_SEGNO(sbi, blk);
778 sentry = get_seg_entry(sbi, segno);
779 offset = GET_BLKOFF_FROM_SEG0(sbi, blk);
780
781 size = min((unsigned long)(end - blk), max_blocks);
782 map = (unsigned long *)(sentry->cur_valid_map);
783 offset = __find_rev_next_bit(map, size, offset);
784 f2fs_bug_on(sbi, offset != size);
785 blk += size;
786 }
787#endif
788}
789
766/* this function is copied from blkdev_issue_discard from block/blk-lib.c */ 790/* this function is copied from blkdev_issue_discard from block/blk-lib.c */
767static void __submit_discard_cmd(struct f2fs_sb_info *sbi, 791static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
768 struct discard_cmd *dc) 792 struct discard_cmd *dc)
@@ -790,6 +814,7 @@ static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
790 bio->bi_opf |= REQ_SYNC; 814 bio->bi_opf |= REQ_SYNC;
791 submit_bio(bio); 815 submit_bio(bio);
792 list_move_tail(&dc->list, &dcc->wait_list); 816 list_move_tail(&dc->list, &dcc->wait_list);
817 __check_sit_bitmap(sbi, dc->start, dc->start + dc->len);
793 } 818 }
794 } else { 819 } else {
795 __remove_discard_cmd(sbi, dc); 820 __remove_discard_cmd(sbi, dc);