Re: [f2fs-dev] [PATCH 10/10] f2fs: return fs_trim if there is no candidate
From: Jaegeuk Kim
Date: Wed Feb 22 2017 - 21:48:42 EST
On 02/23, Chao Yu wrote:
> Hi Jaegeuk,
>
> On 2017/2/23 5:26, Jaegeuk Kim wrote:
...
> >>> + __u64 trim_start = cpc->trim_start;
> >>
> >> bool has_candidate = false;
> >>
> >>> +
> >>> + mutex_lock(&SIT_I(sbi)->sentry_lock);
> >>> + for (; trim_start <= cpc->trim_end; trim_start++)
> >>> + if (add_discard_addrs(sbi, cpc, true))
> >>> + break;
> >>
> >> for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++)
> >> if (add_discard_addrs(sbi, cpc, true)) {
> >> has_candidate = true;
> >> break;
> >> }
> >
> > Why do we need to do like this in which needs additional variable with multiple
> > assignment?
>
> Because add_discard_addrs will check segment which cpc->trim_start points to,
> but if we do not increase cpc->trim_start in loop, we will always check one
> segment, right?
Yeah~ ;)
>
> Thanks,
>
> >
> > Thanks,
> >
> >>
> >> cpc->trim_start = trim_start;
> >>
> >>> + mutex_unlock(&SIT_I(sbi)->sentry_lock);
> >>> +
> >>> + return trim_start <= cpc->trim_end;
> >>
> >> return has_candidate;
> >>
> >> Thanks,
> >>
> >>> +}
> >>> +
> >>> int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
> >>> {
> >>> __u64 start = F2FS_BYTES_TO_BLK(range->start);
> >>> @@ -2251,7 +2269,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> >>> /* add discard candidates */
> >>> if (cpc->reason != CP_DISCARD) {
> >>> cpc->trim_start = segno;
> >>> - add_discard_addrs(sbi, cpc);
> >>> + add_discard_addrs(sbi, cpc, false);
> >>> }
> >>>
> >>> if (to_journal) {
> >>> @@ -2289,7 +2307,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
> >>> __u64 trim_start = cpc->trim_start;
> >>>
> >>> for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++)
> >>> - add_discard_addrs(sbi, cpc);
> >>> + add_discard_addrs(sbi, cpc, false);
> >>>
> >>> cpc->trim_start = trim_start;
> >>> }
> >>>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> 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@xxxxxxxxxxxxxxxxxxxxx
> >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> >
> > .
> >
>
>
> ------------------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxxxxxxx
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel