Hi Jaegeuk, Yunlei,

On 2016/12/20 11:11, Yunlei He wrote:
> If userspace issue a fstrim with a range not involve prefree segments,
> it will reuse these segments without discard. This patch fix it.

>From v1 patch, I guess originally Yunlei wants to skip clearing prefree 
>segments
which is not be included in fstrim range, now v2 patch doesn't follow the
original intention.

So I guess below modification is enough:

-               if (force || !test_opt(sbi, DISCARD))
+               if (!test_opt(sbi, DISCARD))

Only we should consider is whether we would send redundant discards though
fstrim when small discard is on.

Thoughts?

> 
> Signed-off-by: Yunlei He <[email protected]>
> ---
>  fs/f2fs/segment.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 0738f48..a40a34b 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -916,7 +916,11 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, 
> struct cp_control *cpc)
>  
>               dirty_i->nr_dirty[PRE] -= end - start;
>  
> -             if (force || !test_opt(sbi, DISCARD))
> +             if (!test_opt(sbi, DISCARD))
> +                     continue;
> +
> +             if (force && start * sbi->blocks_per_seg >= cpc->trim_start &&
> +                                             end * sbi->blocks_per_seg <= 
> cpc->trim_end)
>                       continue;
>  
>               if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
> 


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to