2018-11-24 07:58:54

by Sahitya Tummala

[permalink] [raw]
Subject: [PATCH] f2fs: fix to allow node segment for GC by ioctl path

Allow node type segments also to be GC'd via f2fs ioctls
F2FS_IOC_GARBAGE_COLLECT and F2FS_IOC_GARBAGE_COLLECT_RANGE.

Signed-off-by: Sahitya Tummala <[email protected]>
---
fs/f2fs/gc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index a07241f..e4689c6 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -323,8 +323,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
p.min_cost = get_max_cost(sbi, &p);

if (*result != NULL_SEGNO) {
- if (IS_DATASEG(get_seg_entry(sbi, *result)->type) &&
- get_valid_blocks(sbi, *result, false) &&
+ if (get_valid_blocks(sbi, *result, false) &&
!sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result)))
p.min_segno = *result;
goto out;
@@ -404,11 +403,12 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
}
*result = (p.min_segno / p.ofs_unit) * p.ofs_unit;

+ }
+out:
+ if (p.min_segno != NULL_SEGNO)
trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
sbi->cur_victim_sec,
prefree_segments(sbi), free_segments(sbi));
- }
-out:
mutex_unlock(&dirty_i->seglist_lock);

return (p.min_segno == NULL_SEGNO) ? 0 : 1;
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.



2018-11-24 10:25:02

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH] f2fs: fix to allow node segment for GC by ioctl path

On 2018/11/23 13:12, Sahitya Tummala wrote:
> Allow node type segments also to be GC'd via f2fs ioctls
> F2FS_IOC_GARBAGE_COLLECT and F2FS_IOC_GARBAGE_COLLECT_RANGE.

IIRC, only F2FS_IOC_GARBAGE_COLLECT_RANGE pass a valid segment number via
@result parameter in get_victim_by_default(), so in commit message, it
needs to remove F2FS_IOC_GARBAGE_COLLECT, right?

Thanks,

>
> Signed-off-by: Sahitya Tummala <[email protected]>
> ---
> fs/f2fs/gc.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index a07241f..e4689c6 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -323,8 +323,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
> p.min_cost = get_max_cost(sbi, &p);
>
> if (*result != NULL_SEGNO) {
> - if (IS_DATASEG(get_seg_entry(sbi, *result)->type) &&
> - get_valid_blocks(sbi, *result, false) &&
> + if (get_valid_blocks(sbi, *result, false) &&
> !sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result)))
> p.min_segno = *result;
> goto out;
> @@ -404,11 +403,12 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
> }
> *result = (p.min_segno / p.ofs_unit) * p.ofs_unit;
>
> + }
> +out:
> + if (p.min_segno != NULL_SEGNO)
> trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
> sbi->cur_victim_sec,
> prefree_segments(sbi), free_segments(sbi));
> - }
> -out:
> mutex_unlock(&dirty_i->seglist_lock);
>
> return (p.min_segno == NULL_SEGNO) ? 0 : 1;
>


2018-11-26 04:31:48

by Sahitya Tummala

[permalink] [raw]
Subject: Re: [PATCH] f2fs: fix to allow node segment for GC by ioctl path

On Sat, Nov 24, 2018 at 06:23:55PM +0800, Chao Yu wrote:
> On 2018/11/23 13:12, Sahitya Tummala wrote:
> > Allow node type segments also to be GC'd via f2fs ioctls
> > F2FS_IOC_GARBAGE_COLLECT and F2FS_IOC_GARBAGE_COLLECT_RANGE.
>
> IIRC, only F2FS_IOC_GARBAGE_COLLECT_RANGE pass a valid segment number via
> @result parameter in get_victim_by_default(), so in commit message, it
> needs to remove F2FS_IOC_GARBAGE_COLLECT, right?
>

Yes Chao, my mistake. Thanks for pointing it out. I will update it
and send the patch for review.

> Thanks,
>
> >
> > Signed-off-by: Sahitya Tummala <[email protected]>
> > ---
> > fs/f2fs/gc.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> > index a07241f..e4689c6 100644
> > --- a/fs/f2fs/gc.c
> > +++ b/fs/f2fs/gc.c
> > @@ -323,8 +323,7 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
> > p.min_cost = get_max_cost(sbi, &p);
> >
> > if (*result != NULL_SEGNO) {
> > - if (IS_DATASEG(get_seg_entry(sbi, *result)->type) &&
> > - get_valid_blocks(sbi, *result, false) &&
> > + if (get_valid_blocks(sbi, *result, false) &&
> > !sec_usage_check(sbi, GET_SEC_FROM_SEG(sbi, *result)))
> > p.min_segno = *result;
> > goto out;
> > @@ -404,11 +403,12 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
> > }
> > *result = (p.min_segno / p.ofs_unit) * p.ofs_unit;
> >
> > + }
> > +out:
> > + if (p.min_segno != NULL_SEGNO)
> > trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
> > sbi->cur_victim_sec,
> > prefree_segments(sbi), free_segments(sbi));
> > - }
> > -out:
> > mutex_unlock(&dirty_i->seglist_lock);
> >
> > return (p.min_segno == NULL_SEGNO) ? 0 : 1;
> >
>

--
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.