All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix to cover allocate_segment() with lock
@ 2021-04-14  1:21 ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2021-04-14  1:21 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

As we did for other cases, in fix_curseg_write_pointer(), let's
change as below:
- use callback function s_ops->allocate_segment() instead of
raw function allocate_segment_by_default();
- cover allocate_segment() with curseg_lock and sentry_lock.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/segment.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b2ee6b7791b0..daf9531ec58f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
 
 	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
 		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
-	allocate_segment_by_default(sbi, type, true);
+
+	down_read(&SM_I(sbi)->curseg_lock);
+	down_write(&SIT_I(sbi)->sentry_lock);
+	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
+	up_write(&SIT_I(sbi)->sentry_lock);
+	up_read(&SM_I(sbi)->curseg_lock);
 
 	/* check consistency of the zone curseg pointed to */
 	if (check_zone_write_pointer(sbi, zbd, &zone))
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [f2fs-dev] [PATCH] f2fs: fix to cover allocate_segment() with lock
@ 2021-04-14  1:21 ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2021-04-14  1:21 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel

As we did for other cases, in fix_curseg_write_pointer(), let's
change as below:
- use callback function s_ops->allocate_segment() instead of
raw function allocate_segment_by_default();
- cover allocate_segment() with curseg_lock and sentry_lock.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/segment.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index b2ee6b7791b0..daf9531ec58f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
 
 	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
 		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
-	allocate_segment_by_default(sbi, type, true);
+
+	down_read(&SM_I(sbi)->curseg_lock);
+	down_write(&SIT_I(sbi)->sentry_lock);
+	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
+	up_write(&SIT_I(sbi)->sentry_lock);
+	up_read(&SM_I(sbi)->curseg_lock);
 
 	/* check consistency of the zone curseg pointed to */
 	if (check_zone_write_pointer(sbi, zbd, &zone))
-- 
2.29.2



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] f2fs: fix to cover allocate_segment() with lock
  2021-04-14  1:21 ` [f2fs-dev] " Chao Yu
@ 2021-04-19 16:57   ` Jaegeuk Kim
  -1 siblings, 0 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2021-04-19 16:57 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel, chao

On 04/14, Chao Yu wrote:
> As we did for other cases, in fix_curseg_write_pointer(), let's
> change as below:
> - use callback function s_ops->allocate_segment() instead of
> raw function allocate_segment_by_default();
> - cover allocate_segment() with curseg_lock and sentry_lock.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/segment.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index b2ee6b7791b0..daf9531ec58f 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>  
>  	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>  		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
> -	allocate_segment_by_default(sbi, type, true);
> +
> +	down_read(&SM_I(sbi)->curseg_lock);
> +	down_write(&SIT_I(sbi)->sentry_lock);
> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
> +	up_write(&SIT_I(sbi)->sentry_lock);
> +	up_read(&SM_I(sbi)->curseg_lock);

Seems f2fs_allocate_new_section()?

>  
>  	/* check consistency of the zone curseg pointed to */
>  	if (check_zone_write_pointer(sbi, zbd, &zone))
> -- 
> 2.29.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix to cover allocate_segment() with lock
@ 2021-04-19 16:57   ` Jaegeuk Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2021-04-19 16:57 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 04/14, Chao Yu wrote:
> As we did for other cases, in fix_curseg_write_pointer(), let's
> change as below:
> - use callback function s_ops->allocate_segment() instead of
> raw function allocate_segment_by_default();
> - cover allocate_segment() with curseg_lock and sentry_lock.
> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
>  fs/f2fs/segment.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index b2ee6b7791b0..daf9531ec58f 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>  
>  	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>  		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
> -	allocate_segment_by_default(sbi, type, true);
> +
> +	down_read(&SM_I(sbi)->curseg_lock);
> +	down_write(&SIT_I(sbi)->sentry_lock);
> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
> +	up_write(&SIT_I(sbi)->sentry_lock);
> +	up_read(&SM_I(sbi)->curseg_lock);

Seems f2fs_allocate_new_section()?

>  
>  	/* check consistency of the zone curseg pointed to */
>  	if (check_zone_write_pointer(sbi, zbd, &zone))
> -- 
> 2.29.2


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] f2fs: fix to cover allocate_segment() with lock
  2021-04-19 16:57   ` [f2fs-dev] " Jaegeuk Kim
@ 2021-04-20  1:52     ` Chao Yu
  -1 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2021-04-20  1:52 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel, chao

On 2021/4/20 0:57, Jaegeuk Kim wrote:
> On 04/14, Chao Yu wrote:
>> As we did for other cases, in fix_curseg_write_pointer(), let's
>> change as below:
>> - use callback function s_ops->allocate_segment() instead of
>> raw function allocate_segment_by_default();
>> - cover allocate_segment() with curseg_lock and sentry_lock.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>   fs/f2fs/segment.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index b2ee6b7791b0..daf9531ec58f 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>>   
>>   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>>   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
>> -	allocate_segment_by_default(sbi, type, true);
>> +
>> +	down_read(&SM_I(sbi)->curseg_lock);
>> +	down_write(&SIT_I(sbi)->sentry_lock);
>> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
>> +	up_write(&SIT_I(sbi)->sentry_lock);
>> +	up_read(&SM_I(sbi)->curseg_lock);
> 
> Seems f2fs_allocate_new_section()?

f2fs_allocate_new_section() will allocate new section only when current
section has been initialized and has valid block/ckpt_block.

It looks fix_curseg_write_pointer() wants to force migrating current segment
to new section whenever write pointer and curseg->next_blkoff is inconsistent.

So how about adding a parameter to force f2fs_allocate_new_section() to
allocate new section?

Thanks,

> 
>>   
>>   	/* check consistency of the zone curseg pointed to */
>>   	if (check_zone_write_pointer(sbi, zbd, &zone))
>> -- 
>> 2.29.2
> .
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix to cover allocate_segment() with lock
@ 2021-04-20  1:52     ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2021-04-20  1:52 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

On 2021/4/20 0:57, Jaegeuk Kim wrote:
> On 04/14, Chao Yu wrote:
>> As we did for other cases, in fix_curseg_write_pointer(), let's
>> change as below:
>> - use callback function s_ops->allocate_segment() instead of
>> raw function allocate_segment_by_default();
>> - cover allocate_segment() with curseg_lock and sentry_lock.
>>
>> Signed-off-by: Chao Yu <yuchao0@huawei.com>
>> ---
>>   fs/f2fs/segment.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index b2ee6b7791b0..daf9531ec58f 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
>>   
>>   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
>>   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
>> -	allocate_segment_by_default(sbi, type, true);
>> +
>> +	down_read(&SM_I(sbi)->curseg_lock);
>> +	down_write(&SIT_I(sbi)->sentry_lock);
>> +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
>> +	up_write(&SIT_I(sbi)->sentry_lock);
>> +	up_read(&SM_I(sbi)->curseg_lock);
> 
> Seems f2fs_allocate_new_section()?

f2fs_allocate_new_section() will allocate new section only when current
section has been initialized and has valid block/ckpt_block.

It looks fix_curseg_write_pointer() wants to force migrating current segment
to new section whenever write pointer and curseg->next_blkoff is inconsistent.

So how about adding a parameter to force f2fs_allocate_new_section() to
allocate new section?

Thanks,

> 
>>   
>>   	/* check consistency of the zone curseg pointed to */
>>   	if (check_zone_write_pointer(sbi, zbd, &zone))
>> -- 
>> 2.29.2
> .
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] f2fs: fix to cover allocate_segment() with lock
  2021-04-20  1:52     ` [f2fs-dev] " Chao Yu
@ 2021-04-20 18:26       ` Jaegeuk Kim
  -1 siblings, 0 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2021-04-20 18:26 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel, chao

On 04/20, Chao Yu wrote:
> On 2021/4/20 0:57, Jaegeuk Kim wrote:
> > On 04/14, Chao Yu wrote:
> > > As we did for other cases, in fix_curseg_write_pointer(), let's
> > > change as below:
> > > - use callback function s_ops->allocate_segment() instead of
> > > raw function allocate_segment_by_default();
> > > - cover allocate_segment() with curseg_lock and sentry_lock.
> > > 
> > > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > > ---
> > >   fs/f2fs/segment.c | 7 ++++++-
> > >   1 file changed, 6 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > > index b2ee6b7791b0..daf9531ec58f 100644
> > > --- a/fs/f2fs/segment.c
> > > +++ b/fs/f2fs/segment.c
> > > @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
> > >   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
> > >   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
> > > -	allocate_segment_by_default(sbi, type, true);
> > > +
> > > +	down_read(&SM_I(sbi)->curseg_lock);
> > > +	down_write(&SIT_I(sbi)->sentry_lock);
> > > +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
> > > +	up_write(&SIT_I(sbi)->sentry_lock);
> > > +	up_read(&SM_I(sbi)->curseg_lock);
> > 
> > Seems f2fs_allocate_new_section()?
> 
> f2fs_allocate_new_section() will allocate new section only when current
> section has been initialized and has valid block/ckpt_block.
> 
> It looks fix_curseg_write_pointer() wants to force migrating current segment
> to new section whenever write pointer and curseg->next_blkoff is inconsistent.
> 
> So how about adding a parameter to force f2fs_allocate_new_section() to
> allocate new section?

I think that can be doable. Hope to avoid native calls as much as possible.

> 
> Thanks,
> 
> > 
> > >   	/* check consistency of the zone curseg pointed to */
> > >   	if (check_zone_write_pointer(sbi, zbd, &zone))
> > > -- 
> > > 2.29.2
> > .
> > 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: fix to cover allocate_segment() with lock
@ 2021-04-20 18:26       ` Jaegeuk Kim
  0 siblings, 0 replies; 8+ messages in thread
From: Jaegeuk Kim @ 2021-04-20 18:26 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel

On 04/20, Chao Yu wrote:
> On 2021/4/20 0:57, Jaegeuk Kim wrote:
> > On 04/14, Chao Yu wrote:
> > > As we did for other cases, in fix_curseg_write_pointer(), let's
> > > change as below:
> > > - use callback function s_ops->allocate_segment() instead of
> > > raw function allocate_segment_by_default();
> > > - cover allocate_segment() with curseg_lock and sentry_lock.
> > > 
> > > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > > ---
> > >   fs/f2fs/segment.c | 7 ++++++-
> > >   1 file changed, 6 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > > index b2ee6b7791b0..daf9531ec58f 100644
> > > --- a/fs/f2fs/segment.c
> > > +++ b/fs/f2fs/segment.c
> > > @@ -4848,7 +4848,12 @@ static int fix_curseg_write_pointer(struct f2fs_sb_info *sbi, int type)
> > >   	f2fs_notice(sbi, "Assign new section to curseg[%d]: "
> > >   		    "curseg[0x%x,0x%x]", type, cs->segno, cs->next_blkoff);
> > > -	allocate_segment_by_default(sbi, type, true);
> > > +
> > > +	down_read(&SM_I(sbi)->curseg_lock);
> > > +	down_write(&SIT_I(sbi)->sentry_lock);
> > > +	SIT_I(sbi)->s_ops->allocate_segment(sbi, type, true);
> > > +	up_write(&SIT_I(sbi)->sentry_lock);
> > > +	up_read(&SM_I(sbi)->curseg_lock);
> > 
> > Seems f2fs_allocate_new_section()?
> 
> f2fs_allocate_new_section() will allocate new section only when current
> section has been initialized and has valid block/ckpt_block.
> 
> It looks fix_curseg_write_pointer() wants to force migrating current segment
> to new section whenever write pointer and curseg->next_blkoff is inconsistent.
> 
> So how about adding a parameter to force f2fs_allocate_new_section() to
> allocate new section?

I think that can be doable. Hope to avoid native calls as much as possible.

> 
> Thanks,
> 
> > 
> > >   	/* check consistency of the zone curseg pointed to */
> > >   	if (check_zone_write_pointer(sbi, zbd, &zone))
> > > -- 
> > > 2.29.2
> > .
> > 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-04-20 18:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  1:21 [PATCH] f2fs: fix to cover allocate_segment() with lock Chao Yu
2021-04-14  1:21 ` [f2fs-dev] " Chao Yu
2021-04-19 16:57 ` Jaegeuk Kim
2021-04-19 16:57   ` [f2fs-dev] " Jaegeuk Kim
2021-04-20  1:52   ` Chao Yu
2021-04-20  1:52     ` [f2fs-dev] " Chao Yu
2021-04-20 18:26     ` Jaegeuk Kim
2021-04-20 18:26       ` [f2fs-dev] " Jaegeuk Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.