[f2fs-dev] [PATCH] f2fs: hide unused procfs helpers
When CONFIG_PROC_FS isn't set, gcc warning this: fs/f2fs/sysfs.c:519:12: warning: ‘segment_info_seq_show’ defined but not used [-Wunused-function] static int segment_info_seq_show(struct seq_file *seq, void *offset) ^ fs/f2fs/sysfs.c:546:12: warning: ‘segment_bits_seq_show’ defined but not used [-Wunused-function] static int segment_bits_seq_show(struct seq_file *seq, void *offset) ^ fs/f2fs/sysfs.c:570:12: warning: ‘iostat_info_seq_show’ defined but not used [-Wunused-function] static int iostat_info_seq_show(struct seq_file *seq, void *offset) We can fix the warning by adding the same #ifdef around them. Signed-off-by: YueHaibing --- fs/f2fs/sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 2e7e611..7d45e65 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -516,6 +516,7 @@ static struct kobject f2fs_feat = { .kset = _kset, }; +#ifdef CONFIG_PROC_FS static int segment_info_seq_show(struct seq_file *seq, void *offset) { struct super_block *sb = seq->private; @@ -608,6 +609,7 @@ static int iostat_info_seq_show(struct seq_file *seq, void *offset) return 0; } +#endif int __init f2fs_init_sysfs(void) { -- 2.7.0 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/5] f2fs: clear the remaining prefree_map of the section
Because in f2fs_clear_prefree_segments, the codes: ... while (1) { int i; start = find_next_bit(prefree_map, MAIN_SEGS(sbi), end + 1); if (start >= MAIN_SEGS(sbi)) break; end = find_next_zero_bit(prefree_map, MAIN_SEGS(sbi), start + 1); for (i = start; i < end; i++) clear_bit(i, prefree_map); ... next: secno = GET_SEC_FROM_SEG(sbi, start); start_segno = GET_SEG_FROM_SEC(sbi, secno); if (!IS_CURSEC(sbi, secno) && !get_valid_blocks(sbi, start, true)) f2fs_issue_discard(sbi, START_BLOCK(sbi, start_segno), sbi->segs_per_sec << sbi->log_blocks_per_seg); start = start_segno + sbi->segs_per_sec; if (start < end) goto next; else end = start - 1; ... In round 2, for prefree_map: 1 1 0 1 1, start = 0, end = 2, then start = start_segno + sbi->segs_per_sec makes start = 5 if (start < end) --> start = 5, end = 2 so end = start -1 --> end = 4, then return to while again, this time skips prefree bit 3 and 4. On 2018/7/13 11:42, Chao Yu wrote: On 2018/7/13 11:28, Yunlong Song wrote: round 1: section bitmap : 1 1 1 1 1, all valid, prefree_map: 0 0 0 0 0 then rm data block NO.2, block NO.2 becomes invalid, prefree_map: 0 0 1 0 0 write_checkpoint: section bitmap: 1 1 0 1 1, prefree_map: 0 0 0 0 0, prefree of NO.2 is cleared, and no discard issued round2: rm data block NO.0, NO.1, NO.3, NO.4 all invalid, but prefree bit of NO.2 is set and cleared in round1, then prefree_map: 1 1 0 1 1 write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1, no Why prefree_map is not 0 0 0 0 0? Thanks, valid blocks of this section, so discard issued but this time prefree bit of NO.3 and NO.4 is skipped... round3: write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1 - > 0 0 0 0 0, no valid blocks of this section, so discard issued this time prefree bit of NO.3 and NO.4 is cleared, but the discard of this section is sent again... On 2018/7/13 11:13, Chao Yu wrote: On 2018/7/12 23:09, Yunlong Song wrote: For the case when sbi->segs_per_sec > 1, take section:segment = 5 for example, if the section prefree_map is ...previous section | current section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, after start = start_segno + sbi->segs_per_sec, start = x + 5, then it will skip x + 3 and x + 4, but their bitmap is still set, which will cause duplicated f2fs_issue_discard of this same section in the next write_checkpoint, so fix it. I didn't get it, if # 2 segment is not prefree state, so it still has valid blocks there, so we won't issue discard due to below condition, right? if (!IS_CURSEC(sbi, secno) && !get_valid_blocks(sbi, start, true)) Thanks, Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 47b6595..fd38b61 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, start = start_segno + sbi->segs_per_sec; if (start < end) goto next; - else - end = start - 1; + else { + start_segno = start; + + while (1) { + start = find_next_bit(prefree_map, start_segno, + end + 1); + if (start >= start_segno) + break; + end = find_next_zero_bit(prefree_map, start_segno, + start + 1); + for (i = start; i < end; i++) + clear_bit(i, prefree_map); + dirty_i->nr_dirty[PRE] -= end - start; + } + + end = start_segno - 1; + } } mutex_unlock(_i->seglist_lock); . . -- Thanks, Yunlong Song -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 4/5] f2fs: disable small discard in lfs mode
On 2018/7/13 11:39, Yunlong Song wrote: > How about change test_opt(sbi, LFS) to f2fs_sb_has_blkzoned(sbi->sb) in > this patch, we apply > this patch to zoned block device? IIRC, we will use blkdev_reset_zones instead of __queue_discard_cmd for such kind of device, so we will not encounter the issue you described. Thanks, > > On 2018/7/13 11:17, Chao Yu wrote: >> On 2018/7/12 23:09, Yunlong Song wrote: >>> In lfs mode, it is better to send the discard of the overall section >>> each time to avoid missing alignment with flash. >> Hmm.. I think LFS mode can be used widely on different kind of device >> instead of >> just on zoned block device, so let's just keep old implementation here. >> >> Thanks, >> >>> Signed-off-by: Yunlong Song >>> --- >>> fs/f2fs/segment.c | 3 ++- >>> fs/f2fs/sysfs.c | 4 >>> 2 files changed, 6 insertions(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index fd38b61..f6c20e0 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -1766,7 +1766,8 @@ static int create_discard_cmd_control(struct >>> f2fs_sb_info *sbi) >>> atomic_set(>issing_discard, 0); >>> atomic_set(>discard_cmd_cnt, 0); >>> dcc->nr_discards = 0; >>> - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; >>> + dcc->max_discards = test_opt(sbi, LFS) ? 0 : >>> + MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; >>> dcc->undiscard_blks = 0; >>> dcc->root = RB_ROOT; >>> dcc->rbtree_check = false; >>> diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c >>> index 2e7e611..4b6c457 100644 >>> --- a/fs/f2fs/sysfs.c >>> +++ b/fs/f2fs/sysfs.c >>> @@ -271,6 +271,10 @@ static ssize_t __sbi_store(struct f2fs_attr *a, >>> return count; >>> } >>> >>> + if (!strcmp(a->attr.name, "max_small_discards") && >>> + test_opt(sbi, LFS)) >>> + return -EINVAL; >>> + >>> *ui = t; >>> >>> if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) >>> >> >> . >> > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/5] f2fs: clear the remaining prefree_map of the section
On 2018/7/13 11:28, Yunlong Song wrote: > round 1: section bitmap : 1 1 1 1 1, all valid, prefree_map: 0 0 0 0 0 > then rm data block NO.2, block NO.2 becomes invalid, prefree_map: 0 0 1 0 0 > write_checkpoint: section bitmap: 1 1 0 1 1, prefree_map: 0 0 0 0 0, > prefree of NO.2 is cleared, and no discard issued > > round2: rm data block NO.0, NO.1, NO.3, NO.4 > all invalid, but prefree bit of NO.2 is set and cleared in round1, then > prefree_map: 1 1 0 1 1 > write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1, no Why prefree_map is not 0 0 0 0 0? Thanks, > valid blocks of this section, so discard issued > but this time prefree bit of NO.3 and NO.4 is skipped... > > round3: > write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1 - > > 0 0 0 0 0, no valid blocks of this section, so discard issued > this time prefree bit of NO.3 and NO.4 is cleared, but the discard of > this section is sent again... > > On 2018/7/13 11:13, Chao Yu wrote: >> On 2018/7/12 23:09, Yunlong Song wrote: >>> For the case when sbi->segs_per_sec > 1, take section:segment = 5 for >>> example, if the section prefree_map is ...previous section | current >>> section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, >>> after start = start_segno + sbi->segs_per_sec, start = x + 5, then it >>> will skip x + 3 and x + 4, but their bitmap is still set, which will >>> cause duplicated f2fs_issue_discard of this same section in the next >>> write_checkpoint, so fix it. >> I didn't get it, if # 2 segment is not prefree state, so it still has valid >> blocks there, so we won't issue discard due to below condition, right? >> >> if (!IS_CURSEC(sbi, secno) && >> !get_valid_blocks(sbi, start, true)) >> >> Thanks, >> >>> Signed-off-by: Yunlong Song >>> --- >>> fs/f2fs/segment.c | 19 +-- >>> 1 file changed, 17 insertions(+), 2 deletions(-) >>> >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index 47b6595..fd38b61 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info >>> *sbi, >>> start = start_segno + sbi->segs_per_sec; >>> if (start < end) >>> goto next; >>> - else >>> - end = start - 1; >>> + else { >>> + start_segno = start; >>> + >>> + while (1) { >>> + start = find_next_bit(prefree_map, start_segno, >>> + end + >>> 1); >>> + if (start >= start_segno) >>> + break; >>> + end = find_next_zero_bit(prefree_map, >>> start_segno, >>> + >>> start + 1); >>> + for (i = start; i < end; i++) >>> + clear_bit(i, prefree_map); >>> + dirty_i->nr_dirty[PRE] -= end - start; >>> + } >>> + >>> + end = start_segno - 1; >>> + } >>> } >>> mutex_unlock(_i->seglist_lock); >>> >>> >> >> . >> > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 5/5] f2fs: do not __punch_discard_cmd in lfs mode
How about change test_opt(sbi, LFS) to f2fs_sb_has_blkzoned(sbi->sb) in this patch, which can avoid punch discard (creating small discard) in zoned block device. On 2018/7/13 11:26, Chao Yu wrote: On 2018/7/12 23:09, Yunlong Song wrote: In lfs mode, it is better to submit and wait for discard of the new_blkaddr's overall section, rather than punch it which makes more small discards and is not friendly with flash alignment. And f2fs does not have to wait discard of each new_blkaddr except for the start_block of each section with this patch. For non-zoned block device, unaligned discard can be allowed; and if synchronous discard is very slow, it will block block allocator here, rather than that, I prefer just punch 4k lba of discard entry for performance. If you don't want to encounter this condition, I suggest issue large size discard more quickly. Thanks, Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 76 ++- fs/f2fs/segment.h | 7 - 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index f6c20e0..bce321a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -893,7 +893,19 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, static void f2fs_submit_discard_endio(struct bio *bio) { struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; + struct f2fs_sb_info *sbi = F2FS_SB(dc->bdev->bd_super); + if (test_opt(sbi, LFS)) { + unsigned int segno = GET_SEGNO(sbi, dc->lstart); + unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); + int cnt = (dc->len >> sbi->log_blocks_per_seg) / + sbi->segs_per_sec; + + while (cnt--) { + set_bit(secno, FREE_I(sbi)->discard_secmap); + secno++; + } + } dc->error = blk_status_to_errno(bio->bi_status); dc->state = D_DONE; complete_all(>wait); @@ -1349,8 +1361,15 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) dc = (struct discard_cmd *)f2fs_lookup_rb_tree(>root, NULL, blkaddr); if (dc) { - if (dc->state == D_PREP) { + if (dc->state == D_PREP && !test_opt(sbi, LFS)) __punch_discard_cmd(sbi, dc, blkaddr); + else if (dc->state == D_PREP && test_opt(sbi, LFS)) { + struct discard_policy dpolicy; + + __init_discard_policy(sbi, , DPOLICY_FORCE, 1); + __submit_discard_cmd(sbi, , dc); + dc->ref++; + need_wait = true; } else { dc->ref++; need_wait = true; @@ -2071,9 +2090,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); unsigned int left_start = hint; - bool init = true; + bool init = true, check_discard = test_opt(sbi, LFS) ? true : false; int go_left = 0; int i; + unsigned long *free_secmap; spin_lock(_i->segmap_lock); @@ -2084,11 +2104,25 @@ static void get_new_segment(struct f2fs_sb_info *sbi, goto got_it; } find_other_zone: - secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); + if (check_discard) { + int entries = f2fs_bitmap_size(MAIN_SECS(sbi)) / sizeof(unsigned long); + + free_secmap = free_i->tmp_secmap; + for (i = 0; i < entries; i++) + free_secmap[i] = (!(free_i->free_secmap[i] ^ + free_i->discard_secmap[i])) | free_i->free_secmap[i]; + } else + free_secmap = free_i->free_secmap; + + secno = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { if (dir == ALLOC_RIGHT) { - secno = find_next_zero_bit(free_i->free_secmap, + secno = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), 0); + if (secno >= MAIN_SECS(sbi) && check_discard) { + check_discard = false; + goto find_other_zone; + } f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } else { go_left = 1; @@ -2098,13 +2132,17 @@ static void get_new_segment(struct f2fs_sb_info *sbi, if (go_left == 0) goto skip_left; - while (test_bit(left_start, free_i->free_secmap)) { + while (test_bit(left_start, free_secmap)) { if (left_start
Re: [f2fs-dev] [PATCH 4/5] f2fs: disable small discard in lfs mode
How about change test_opt(sbi, LFS) to f2fs_sb_has_blkzoned(sbi->sb) in this patch, we apply this patch to zoned block device? On 2018/7/13 11:17, Chao Yu wrote: On 2018/7/12 23:09, Yunlong Song wrote: In lfs mode, it is better to send the discard of the overall section each time to avoid missing alignment with flash. Hmm.. I think LFS mode can be used widely on different kind of device instead of just on zoned block device, so let's just keep old implementation here. Thanks, Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 4 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index fd38b61..f6c20e0 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1766,7 +1766,8 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) atomic_set(>issing_discard, 0); atomic_set(>discard_cmd_cnt, 0); dcc->nr_discards = 0; - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; + dcc->max_discards = test_opt(sbi, LFS) ? 0 : + MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; dcc->undiscard_blks = 0; dcc->root = RB_ROOT; dcc->rbtree_check = false; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 2e7e611..4b6c457 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -271,6 +271,10 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } + if (!strcmp(a->attr.name, "max_small_discards") && + test_opt(sbi, LFS)) + return -EINVAL; + *ui = t; if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) . -- Thanks, Yunlong Song -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/5] f2fs: clear the remaining prefree_map of the section
round 1: section bitmap : 1 1 1 1 1, all valid, prefree_map: 0 0 0 0 0 then rm data block NO.2, block NO.2 becomes invalid, prefree_map: 0 0 1 0 0 write_checkpoint: section bitmap: 1 1 0 1 1, prefree_map: 0 0 0 0 0, prefree of NO.2 is cleared, and no discard issued round2: rm data block NO.0, NO.1, NO.3, NO.4 all invalid, but prefree bit of NO.2 is set and cleared in round1, then prefree_map: 1 1 0 1 1 write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1, no valid blocks of this section, so discard issued but this time prefree bit of NO.3 and NO.4 is skipped... round3: write_checkpoint: section bitmap: 0 0 0 0 0, prefree_map: 0 0 0 1 1 - > 0 0 0 0 0, no valid blocks of this section, so discard issued this time prefree bit of NO.3 and NO.4 is cleared, but the discard of this section is sent again... On 2018/7/13 11:13, Chao Yu wrote: On 2018/7/12 23:09, Yunlong Song wrote: For the case when sbi->segs_per_sec > 1, take section:segment = 5 for example, if the section prefree_map is ...previous section | current section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, after start = start_segno + sbi->segs_per_sec, start = x + 5, then it will skip x + 3 and x + 4, but their bitmap is still set, which will cause duplicated f2fs_issue_discard of this same section in the next write_checkpoint, so fix it. I didn't get it, if # 2 segment is not prefree state, so it still has valid blocks there, so we won't issue discard due to below condition, right? if (!IS_CURSEC(sbi, secno) && !get_valid_blocks(sbi, start, true)) Thanks, Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 47b6595..fd38b61 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, start = start_segno + sbi->segs_per_sec; if (start < end) goto next; - else - end = start - 1; + else { + start_segno = start; + + while (1) { + start = find_next_bit(prefree_map, start_segno, + end + 1); + if (start >= start_segno) + break; + end = find_next_zero_bit(prefree_map, start_segno, + start + 1); + for (i = start; i < end; i++) + clear_bit(i, prefree_map); + dirty_i->nr_dirty[PRE] -= end - start; + } + + end = start_segno - 1; + } } mutex_unlock(_i->seglist_lock); . -- Thanks, Yunlong Song -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 5/5] f2fs: do not __punch_discard_cmd in lfs mode
On 2018/7/12 23:09, Yunlong Song wrote: > In lfs mode, it is better to submit and wait for discard of the > new_blkaddr's overall section, rather than punch it which makes > more small discards and is not friendly with flash alignment. And > f2fs does not have to wait discard of each new_blkaddr except for the > start_block of each section with this patch. For non-zoned block device, unaligned discard can be allowed; and if synchronous discard is very slow, it will block block allocator here, rather than that, I prefer just punch 4k lba of discard entry for performance. If you don't want to encounter this condition, I suggest issue large size discard more quickly. Thanks, > > Signed-off-by: Yunlong Song > --- > fs/f2fs/segment.c | 76 > ++- > fs/f2fs/segment.h | 7 - > 2 files changed, 75 insertions(+), 8 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index f6c20e0..bce321a 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -893,7 +893,19 @@ static void __remove_discard_cmd(struct f2fs_sb_info > *sbi, > static void f2fs_submit_discard_endio(struct bio *bio) > { > struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; > + struct f2fs_sb_info *sbi = F2FS_SB(dc->bdev->bd_super); > > + if (test_opt(sbi, LFS)) { > + unsigned int segno = GET_SEGNO(sbi, dc->lstart); > + unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); > + int cnt = (dc->len >> sbi->log_blocks_per_seg) / > + sbi->segs_per_sec; > + > + while (cnt--) { > + set_bit(secno, FREE_I(sbi)->discard_secmap); > + secno++; > + } > + } > dc->error = blk_status_to_errno(bio->bi_status); > dc->state = D_DONE; > complete_all(>wait); > @@ -1349,8 +1361,15 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info > *sbi, block_t blkaddr) > dc = (struct discard_cmd *)f2fs_lookup_rb_tree(>root, > NULL, blkaddr); > if (dc) { > - if (dc->state == D_PREP) { > + if (dc->state == D_PREP && !test_opt(sbi, LFS)) > __punch_discard_cmd(sbi, dc, blkaddr); > + else if (dc->state == D_PREP && test_opt(sbi, LFS)) { > + struct discard_policy dpolicy; > + > + __init_discard_policy(sbi, , DPOLICY_FORCE, 1); > + __submit_discard_cmd(sbi, , dc); > + dc->ref++; > + need_wait = true; > } else { > dc->ref++; > need_wait = true; > @@ -2071,9 +2090,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); > unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); > unsigned int left_start = hint; > - bool init = true; > + bool init = true, check_discard = test_opt(sbi, LFS) ? true : false; > int go_left = 0; > int i; > + unsigned long *free_secmap; > > spin_lock(_i->segmap_lock); > > @@ -2084,11 +2104,25 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > goto got_it; > } > find_other_zone: > - secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); > + if (check_discard) { > + int entries = f2fs_bitmap_size(MAIN_SECS(sbi)) / > sizeof(unsigned long); > + > + free_secmap = free_i->tmp_secmap; > + for (i = 0; i < entries; i++) > + free_secmap[i] = (!(free_i->free_secmap[i] ^ > + free_i->discard_secmap[i])) | > free_i->free_secmap[i]; > + } else > + free_secmap = free_i->free_secmap; > + > + secno = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), hint); > if (secno >= MAIN_SECS(sbi)) { > if (dir == ALLOC_RIGHT) { > - secno = find_next_zero_bit(free_i->free_secmap, > + secno = find_next_zero_bit(free_secmap, > MAIN_SECS(sbi), 0); > + if (secno >= MAIN_SECS(sbi) && check_discard) { > + check_discard = false; > + goto find_other_zone; > + } > f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); > } else { > go_left = 1; > @@ -2098,13 +2132,17 @@ static void get_new_segment(struct f2fs_sb_info *sbi, > if (go_left == 0) > goto skip_left; > > - while (test_bit(left_start, free_i->free_secmap)) { > + while (test_bit(left_start, free_secmap)) { > if (left_start > 0) { > left_start--; > continue; > } > -
Re: [f2fs-dev] [PATCH 4/5] f2fs: disable small discard in lfs mode
On 2018/7/12 23:09, Yunlong Song wrote: > In lfs mode, it is better to send the discard of the overall section > each time to avoid missing alignment with flash. Hmm.. I think LFS mode can be used widely on different kind of device instead of just on zoned block device, so let's just keep old implementation here. Thanks, > > Signed-off-by: Yunlong Song > --- > fs/f2fs/segment.c | 3 ++- > fs/f2fs/sysfs.c | 4 > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index fd38b61..f6c20e0 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -1766,7 +1766,8 @@ static int create_discard_cmd_control(struct > f2fs_sb_info *sbi) > atomic_set(>issing_discard, 0); > atomic_set(>discard_cmd_cnt, 0); > dcc->nr_discards = 0; > - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; > + dcc->max_discards = test_opt(sbi, LFS) ? 0 : > + MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; > dcc->undiscard_blks = 0; > dcc->root = RB_ROOT; > dcc->rbtree_check = false; > diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c > index 2e7e611..4b6c457 100644 > --- a/fs/f2fs/sysfs.c > +++ b/fs/f2fs/sysfs.c > @@ -271,6 +271,10 @@ static ssize_t __sbi_store(struct f2fs_attr *a, > return count; > } > > + if (!strcmp(a->attr.name, "max_small_discards") && > + test_opt(sbi, LFS)) > + return -EINVAL; > + > *ui = t; > > if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 3/5] f2fs: blk_finish_plug of submit_bio in lfs mode
On 2018/7/12 23:09, Yunlong Song wrote: > Expand the blk_finish_plug action from blkzoned to normal lfs mode, > since plug will cause the out-of-order IO submission, which is not > friendly to flash in lfs mode. > > Signed-off-by: Yunlong Song Reviewed-by: Chao Yu Thanks, -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 2/5] f2fs: clear the remaining prefree_map of the section
On 2018/7/12 23:09, Yunlong Song wrote: > For the case when sbi->segs_per_sec > 1, take section:segment = 5 for > example, if the section prefree_map is ...previous section | current > section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, > after start = start_segno + sbi->segs_per_sec, start = x + 5, then it > will skip x + 3 and x + 4, but their bitmap is still set, which will > cause duplicated f2fs_issue_discard of this same section in the next > write_checkpoint, so fix it. I didn't get it, if # 2 segment is not prefree state, so it still has valid blocks there, so we won't issue discard due to below condition, right? if (!IS_CURSEC(sbi, secno) && !get_valid_blocks(sbi, start, true)) Thanks, > > Signed-off-by: Yunlong Song > --- > fs/f2fs/segment.c | 19 +-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 47b6595..fd38b61 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info > *sbi, > start = start_segno + sbi->segs_per_sec; > if (start < end) > goto next; > - else > - end = start - 1; > + else { > + start_segno = start; > + > + while (1) { > + start = find_next_bit(prefree_map, start_segno, > + end + > 1); > + if (start >= start_segno) > + break; > + end = find_next_zero_bit(prefree_map, > start_segno, > + > start + 1); > + for (i = start; i < end; i++) > + clear_bit(i, prefree_map); > + dirty_i->nr_dirty[PRE] -= end - start; > + } > + > + end = start_segno - 1; > + } > } > mutex_unlock(_i->seglist_lock); > > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH 1/5] f2fs: do not set free of current section
On 2018/7/12 23:09, Yunlong Song wrote: > For the case when sbi->segs_per_sec > 1, take section:segment = 5 for > example, if segment 1 is just used and allocate new segment 2, and the > blocks of segment 1 is invalidated, at this time, the previous code will > use __set_test_and_free to free the free_secmap and free_sections++, > this is not correct since it is still a current section, so fix it. > > Signed-off-by: Yunlong Song Reviewed-by: Chao Yu Thanks, -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [f2fs-dev v2] [PATCH 2/4] f2fs: allow wrong configure dio to buffered write
This fixes to support dio having unaligned buffers as buffered writes. xfs_io -f -d -c "pwrite 0 512" $testfile -> okay xfs_io -f -d -c "pwrite 1 512" $testfile -> EINVAL Signed-off-by: Jaegeuk Kim --- v2 from v1: - return error depending on sector size fs/f2fs/data.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8f931d699287..5e53d210e222 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2371,14 +2371,20 @@ static int f2fs_write_end(struct file *file, static int check_direct_IO(struct inode *inode, struct iov_iter *iter, loff_t offset) { - unsigned blocksize_mask = inode->i_sb->s_blocksize - 1; - - if (offset & blocksize_mask) - return -EINVAL; - - if (iov_iter_alignment(iter) & blocksize_mask) - return -EINVAL; - + unsigned i_blkbits = READ_ONCE(inode->i_blkbits); + unsigned blkbits = i_blkbits; + unsigned blocksize_mask = (1 << blkbits) - 1; + unsigned long align = offset | iov_iter_alignment(iter); + struct block_device *bdev = inode->i_sb->s_bdev; + + if (align & blocksize_mask) { + if (bdev) + blkbits = blksize_bits(bdev_logical_block_size(bdev)); + blocksize_mask = (1 << blkbits) - 1; + if (align & blocksize_mask) + return -EINVAL; + return 1; + } return 0; } @@ -2396,7 +2402,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) err = check_direct_IO(inode, iter, offset); if (err) - return err; + return err < 0 ? err : 0; if (f2fs_force_buffered_io(inode, rw)) return 0; -- 2.17.0.441.gb46fe60e1d-goog -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH 4/5] f2fs: disable small discard in lfs mode
In lfs mode, it is better to send the discard of the overall section each time to avoid missing alignment with flash. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 4 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index fd38b61..f6c20e0 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1766,7 +1766,8 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) atomic_set(>issing_discard, 0); atomic_set(>discard_cmd_cnt, 0); dcc->nr_discards = 0; - dcc->max_discards = MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; + dcc->max_discards = test_opt(sbi, LFS) ? 0 : + MAIN_SEGS(sbi) << sbi->log_blocks_per_seg; dcc->undiscard_blks = 0; dcc->root = RB_ROOT; dcc->rbtree_check = false; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 2e7e611..4b6c457 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -271,6 +271,10 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } + if (!strcmp(a->attr.name, "max_small_discards") && + test_opt(sbi, LFS)) + return -EINVAL; + *ui = t; if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) -- 1.8.5.2 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH 5/5] f2fs: do not __punch_discard_cmd in lfs mode
In lfs mode, it is better to submit and wait for discard of the new_blkaddr's overall section, rather than punch it which makes more small discards and is not friendly with flash alignment. And f2fs does not have to wait discard of each new_blkaddr except for the start_block of each section with this patch. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 76 ++- fs/f2fs/segment.h | 7 - 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index f6c20e0..bce321a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -893,7 +893,19 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi, static void f2fs_submit_discard_endio(struct bio *bio) { struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private; + struct f2fs_sb_info *sbi = F2FS_SB(dc->bdev->bd_super); + if (test_opt(sbi, LFS)) { + unsigned int segno = GET_SEGNO(sbi, dc->lstart); + unsigned int secno = GET_SEC_FROM_SEG(sbi, segno); + int cnt = (dc->len >> sbi->log_blocks_per_seg) / + sbi->segs_per_sec; + + while (cnt--) { + set_bit(secno, FREE_I(sbi)->discard_secmap); + secno++; + } + } dc->error = blk_status_to_errno(bio->bi_status); dc->state = D_DONE; complete_all(>wait); @@ -1349,8 +1361,15 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr) dc = (struct discard_cmd *)f2fs_lookup_rb_tree(>root, NULL, blkaddr); if (dc) { - if (dc->state == D_PREP) { + if (dc->state == D_PREP && !test_opt(sbi, LFS)) __punch_discard_cmd(sbi, dc, blkaddr); + else if (dc->state == D_PREP && test_opt(sbi, LFS)) { + struct discard_policy dpolicy; + + __init_discard_policy(sbi, , DPOLICY_FORCE, 1); + __submit_discard_cmd(sbi, , dc); + dc->ref++; + need_wait = true; } else { dc->ref++; need_wait = true; @@ -2071,9 +2090,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); unsigned int left_start = hint; - bool init = true; + bool init = true, check_discard = test_opt(sbi, LFS) ? true : false; int go_left = 0; int i; + unsigned long *free_secmap; spin_lock(_i->segmap_lock); @@ -2084,11 +2104,25 @@ static void get_new_segment(struct f2fs_sb_info *sbi, goto got_it; } find_other_zone: - secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); + if (check_discard) { + int entries = f2fs_bitmap_size(MAIN_SECS(sbi)) / sizeof(unsigned long); + + free_secmap = free_i->tmp_secmap; + for (i = 0; i < entries; i++) + free_secmap[i] = (!(free_i->free_secmap[i] ^ + free_i->discard_secmap[i])) | free_i->free_secmap[i]; + } else + free_secmap = free_i->free_secmap; + + secno = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { if (dir == ALLOC_RIGHT) { - secno = find_next_zero_bit(free_i->free_secmap, + secno = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), 0); + if (secno >= MAIN_SECS(sbi) && check_discard) { + check_discard = false; + goto find_other_zone; + } f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } else { go_left = 1; @@ -2098,13 +2132,17 @@ static void get_new_segment(struct f2fs_sb_info *sbi, if (go_left == 0) goto skip_left; - while (test_bit(left_start, free_i->free_secmap)) { + while (test_bit(left_start, free_secmap)) { if (left_start > 0) { left_start--; continue; } - left_start = find_next_zero_bit(free_i->free_secmap, + left_start = find_next_zero_bit(free_secmap, MAIN_SECS(sbi), 0); + if (left_start >= MAIN_SECS(sbi) && check_discard) { + check_discard = false; + goto find_other_zone; + } f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi));
[f2fs-dev] [PATCH 2/5] f2fs: clear the remaining prefree_map of the section
For the case when sbi->segs_per_sec > 1, take section:segment = 5 for example, if the section prefree_map is ...previous section | current section (1 1 0 1 1) | next section..., then the start = x, end = x + 1, after start = start_segno + sbi->segs_per_sec, start = x + 5, then it will skip x + 3 and x + 4, but their bitmap is still set, which will cause duplicated f2fs_issue_discard of this same section in the next write_checkpoint, so fix it. Signed-off-by: Yunlong Song --- fs/f2fs/segment.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 47b6595..fd38b61 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1684,8 +1684,23 @@ void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi, start = start_segno + sbi->segs_per_sec; if (start < end) goto next; - else - end = start - 1; + else { + start_segno = start; + + while (1) { + start = find_next_bit(prefree_map, start_segno, + end + 1); + if (start >= start_segno) + break; + end = find_next_zero_bit(prefree_map, start_segno, + start + 1); + for (i = start; i < end; i++) + clear_bit(i, prefree_map); + dirty_i->nr_dirty[PRE] -= end - start; + } + + end = start_segno - 1; + } } mutex_unlock(_i->seglist_lock); -- 1.8.5.2 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH 1/5] f2fs: do not set free of current section
For the case when sbi->segs_per_sec > 1, take section:segment = 5 for example, if segment 1 is just used and allocate new segment 2, and the blocks of segment 1 is invalidated, at this time, the previous code will use __set_test_and_free to free the free_secmap and free_sections++, this is not correct since it is still a current section, so fix it. Signed-off-by: Yunlong Song --- fs/f2fs/segment.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index b5bd328..5049551 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -448,6 +448,8 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, if (test_and_clear_bit(segno, free_i->free_segmap)) { free_i->free_segments++; + if (IS_CURSEC(sbi, secno)) + goto skip_free; next = find_next_bit(free_i->free_segmap, start_segno + sbi->segs_per_sec, start_segno); if (next >= start_segno + sbi->segs_per_sec) { @@ -455,6 +457,7 @@ static inline void __set_test_and_free(struct f2fs_sb_info *sbi, free_i->free_sections++; } } +skip_free: spin_unlock(_i->segmap_lock); } -- 1.8.5.2 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH 3/5] f2fs: blk_finish_plug of submit_bio in lfs mode
Expand the blk_finish_plug action from blkzoned to normal lfs mode, since plug will cause the out-of-order IO submission, which is not friendly to flash in lfs mode. Signed-off-by: Yunlong Song --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 70813a4..f12151d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -263,7 +263,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi, if (type != DATA && type != NODE) goto submit_io; - if (f2fs_sb_has_blkzoned(sbi->sb) && current->plug) + if (test_opt(sbi, LFS) && current->plug) blk_finish_plug(current->plug); start = bio->bi_iter.bi_size >> F2FS_BLKSIZE_BITS; -- 1.8.5.2 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [PATCH 0/5] f2fs: fix some bugs in lfs mode with large section
f2fs has some bugs in section:segment > 1 and lfs mode, so fix them. Yunlong Song (5): f2fs: do not set free of current section f2fs: clear the remaining prefree_map of the section f2fs: blk_finish_plug of submit_bio in lfs mode f2fs: disable small discard in lfs mode f2fs: do not __punch_discard_cmd in lfs mode fs/f2fs/data.c| 2 +- fs/f2fs/segment.c | 98 +-- fs/f2fs/segment.h | 10 +- fs/f2fs/sysfs.c | 4 +++ 4 files changed, 102 insertions(+), 12 deletions(-) -- 1.8.5.2 -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs-tools: set namelen parameter of convert_encrypted_name as unsigned
On 2018/7/10 22:47, Sheng Yong wrote: > To avoid overflow, set namelen parameter of convert_encrypted_name as > unsigned int. convert_encrypted_name() will check if namelen exceeds the > limitation. > > Signed-off-by: Sheng Yong Reviewed-by: Chao Yu Thanks, -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] fsck.f2fs: init quota_file before re-create quota file
On 2018/7/12 11:36, Sheng Yong wrote: > `quota_handle->qh_qf->filesize' is not initialized by quota_create_file(). > It contains random value, which is updated to quota file's i_size in > quota_file_close(). Since quota file is re-created, `filesize' can be > initialized as 0. > > Signed-off-by: Sheng Yong Reviewed-by: Chao Yu Thanks, -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: do checkpoint in kill_sb
On 2018/7/12 15:34, Jaegeuk Kim wrote: > On 07/10, Chao Yu wrote: >> On 2018/7/10 4:36, Jaegeuk Kim wrote: >>> On 07/09, Chao Yu wrote: On 2018/7/7 9:20, Jaegeuk Kim wrote: > When unmounting f2fs in force mode, we can get it stuck by io_schedule() force mode means force shutdown? >>> >>> Yes. >>> > by some pending IOs in meta_inode. > > io_schedule+0xd/0x30 > wait_on_page_bit_common+0xc6/0x130 Looks like a deadlock here? Does this mean we forget to submit cached bio in somewhere? >>> >>> I'm hitting this randomly, when running all the testcases in xfstests. >>> I can't find the missing flow, and only get this during kill_sb. >> >> I guess we need this before returning from ->writepage{,s}: >> >> if (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)) >> f2fs_submit_merged_write() >> >> How about trying this instead? > > No, it's not shutdown case unfortunately. Still I didn't understand why this patch can fix the issue... :( Thanks, > >> >> Thanks, >> >>> Thanks, > __filemap_fdatawait_range+0xbd/0x100 > filemap_fdatawait_keep_errors+0x15/0x40 > sync_inodes_sb+0x1cf/0x240 > sync_filesystem+0x52/0x90 > generic_shutdown_super+0x1d/0x110 > ceph_kill_sb+0x28/0x80 [ceph] > deactivate_locked_super+0x35/0x60 > cleanup_mnt+0x36/0x70 > task_work_run+0x79/0xa0 > exit_to_usermode_loop+0x62/0x70 > do_syscall_64+0xdb/0xf0 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > 0x > > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/super.c | 16 +--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 3995e926ba3a..1dc6809fac38 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -3089,9 +3089,19 @@ static struct dentry *f2fs_mount(struct > file_system_type *fs_type, int flags, > static void kill_f2fs_super(struct super_block *sb) > { > if (sb->s_root) { > - set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE); > - f2fs_stop_gc_thread(F2FS_SB(sb)); > - f2fs_stop_discard_thread(F2FS_SB(sb)); > + struct f2fs_sb_info *sbi = F2FS_SB(sb); > + > + set_sbi_flag(sbi, SBI_IS_CLOSE); > + f2fs_stop_gc_thread(sbi); > + f2fs_stop_discard_thread(sbi); > + > + if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) || > + !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { > + struct cp_control cpc = { > + .reason = CP_UMOUNT, > + }; > + f2fs_write_checkpoint(sbi, ); > + } > } > kill_block_super(sb); > } > >>> >>> . >>> > > . > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: fix defined but not used build warnings
On 2018/7/12 11:35, Randy Dunlap wrote: > On 07/09/2018 06:09 PM, Chao Yu wrote: >> On 2018/7/7 11:50, Randy Dunlap wrote: >>> From: Randy Dunlap >>> >>> Fix build warnings in f2fs when CONFIG_PROC_FS is not enabled >>> by marking the unused functions as __maybe_unused. >>> >>> ../fs/f2fs/sysfs.c:519:12: warning: 'segment_info_seq_show' defined but not >>> used [-Wunused-function] >>> ../fs/f2fs/sysfs.c:546:12: warning: 'segment_bits_seq_show' defined but not >>> used [-Wunused-function] >>> ../fs/f2fs/sysfs.c:570:12: warning: 'iostat_info_seq_show' defined but not >>> used [-Wunused-function] >>> >>> Signed-off-by: Randy Dunlap >>> Cc: Jaegeuk Kim >>> Cc: Chao Yu >>> Cc: linux-f2fs-devel@lists.sourceforge.net >> >> Reviewed-by: Chao Yu > > Hi, > Who would you like to merge this patch? or could you do so? Hello, Jaegeuk will merge it. :) Thanks, > > thanks, > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Re: [f2fs-dev] [PATCH] f2fs: do checkpoint in kill_sb
On 07/10, Chao Yu wrote: > On 2018/7/10 4:36, Jaegeuk Kim wrote: > > On 07/09, Chao Yu wrote: > >> On 2018/7/7 9:20, Jaegeuk Kim wrote: > >>> When unmounting f2fs in force mode, we can get it stuck by io_schedule() > >> > >> force mode means force shutdown? > > > > Yes. > > > >> > >>> by some pending IOs in meta_inode. > >>> > >>> io_schedule+0xd/0x30 > >>> wait_on_page_bit_common+0xc6/0x130 > >> > >> Looks like a deadlock here? Does this mean we forget to submit cached bio > >> in > >> somewhere? > > > > I'm hitting this randomly, when running all the testcases in xfstests. > > I can't find the missing flow, and only get this during kill_sb. > > I guess we need this before returning from ->writepage{,s}: > > if (is_sbi_flag_set(sbi, SBI_IS_SHUTDOWN)) > f2fs_submit_merged_write() > > How about trying this instead? No, it's not shutdown case unfortunately. > > Thanks, > > > > >> > >> Thanks, > >> > >>> __filemap_fdatawait_range+0xbd/0x100 > >>> filemap_fdatawait_keep_errors+0x15/0x40 > >>> sync_inodes_sb+0x1cf/0x240 > >>> sync_filesystem+0x52/0x90 > >>> generic_shutdown_super+0x1d/0x110 > >>> ceph_kill_sb+0x28/0x80 [ceph] > >>> deactivate_locked_super+0x35/0x60 > >>> cleanup_mnt+0x36/0x70 > >>> task_work_run+0x79/0xa0 > >>> exit_to_usermode_loop+0x62/0x70 > >>> do_syscall_64+0xdb/0xf0 > >>> entry_SYSCALL_64_after_hwframe+0x44/0xa9 > >>> 0x > >>> > >>> Signed-off-by: Jaegeuk Kim > >>> --- > >>> fs/f2fs/super.c | 16 +--- > >>> 1 file changed, 13 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > >>> index 3995e926ba3a..1dc6809fac38 100644 > >>> --- a/fs/f2fs/super.c > >>> +++ b/fs/f2fs/super.c > >>> @@ -3089,9 +3089,19 @@ static struct dentry *f2fs_mount(struct > >>> file_system_type *fs_type, int flags, > >>> static void kill_f2fs_super(struct super_block *sb) > >>> { > >>> if (sb->s_root) { > >>> - set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE); > >>> - f2fs_stop_gc_thread(F2FS_SB(sb)); > >>> - f2fs_stop_discard_thread(F2FS_SB(sb)); > >>> + struct f2fs_sb_info *sbi = F2FS_SB(sb); > >>> + > >>> + set_sbi_flag(sbi, SBI_IS_CLOSE); > >>> + f2fs_stop_gc_thread(sbi); > >>> + f2fs_stop_discard_thread(sbi); > >>> + > >>> + if (is_sbi_flag_set(sbi, SBI_IS_DIRTY) || > >>> + !is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) { > >>> + struct cp_control cpc = { > >>> + .reason = CP_UMOUNT, > >>> + }; > >>> + f2fs_write_checkpoint(sbi, ); > >>> + } > >>> } > >>> kill_block_super(sb); > >>> } > >>> > > > > . > > -- 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 Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel