linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
@ 2023-08-31  7:10 Chunhai Guo via Linux-f2fs-devel
  2023-08-31  7:43 ` Chao Yu
  2023-09-04  8:21 ` Chao Yu
  0 siblings, 2 replies; 6+ messages in thread
From: Chunhai Guo via Linux-f2fs-devel @ 2023-08-31  7:10 UTC (permalink / raw)
  To: chao; +Cc: jaegeuk, Chunhai Guo, linux-f2fs-devel

The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
requires unplugging current->plug. Using blk_finish_plug() is unnecessary
as it sets current->plug as NULL and prevents wb_writeback() from using
plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.

Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
---
 fs/f2fs/data.c | 3 +--
 fs/f2fs/node.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 916e317ac925..77b4a55d6d94 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3346,8 +3346,7 @@ static int __f2fs_write_data_pages(struct address_space *mapping,
 		atomic_inc(&sbi->wb_sync_req[DATA]);
 	else if (atomic_read(&sbi->wb_sync_req[DATA])) {
 		/* to avoid potential deadlock */
-		if (current->plug)
-			blk_finish_plug(current->plug);
+		blk_flush_plug(current->plug, false);
 		goto skip_write;
 	}
 
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index ee2e1dd64f25..c4b5717a8c1a 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2126,8 +2126,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
 		atomic_inc(&sbi->wb_sync_req[NODE]);
 	else if (atomic_read(&sbi->wb_sync_req[NODE])) {
 		/* to avoid potential deadlock */
-		if (current->plug)
-			blk_finish_plug(current->plug);
+		blk_flush_plug(current->plug, false);
 		goto skip_write;
 	}
 
-- 
2.25.1



_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
  2023-08-31  7:10 [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug() Chunhai Guo via Linux-f2fs-devel
@ 2023-08-31  7:43 ` Chao Yu
  2023-09-04  8:21 ` Chao Yu
  1 sibling, 0 replies; 6+ messages in thread
From: Chao Yu @ 2023-08-31  7:43 UTC (permalink / raw)
  To: Chunhai Guo; +Cc: jaegeuk, linux-f2fs-devel

On 2023/8/31 15:10, Chunhai Guo wrote:
> The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
> requires unplugging current->plug. Using blk_finish_plug() is unnecessary
> as it sets current->plug as NULL and prevents wb_writeback() from using
> plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.
> 
> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
  2023-08-31  7:10 [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug() Chunhai Guo via Linux-f2fs-devel
  2023-08-31  7:43 ` Chao Yu
@ 2023-09-04  8:21 ` Chao Yu
  2023-09-04 16:40   ` Jaegeuk Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Chao Yu @ 2023-09-04  8:21 UTC (permalink / raw)
  To: Chunhai Guo, jaegeuk; +Cc: linux-f2fs-devel

On 2023/8/31 15:10, Chunhai Guo wrote:
> The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
> requires unplugging current->plug. Using blk_finish_plug() is unnecessary
> as it sets current->plug as NULL and prevents wb_writeback() from using
> plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.
> 
> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
> ---
>   fs/f2fs/data.c | 3 +--
>   fs/f2fs/node.c | 3 +--
>   2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 916e317ac925..77b4a55d6d94 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -3346,8 +3346,7 @@ static int __f2fs_write_data_pages(struct address_space *mapping,
>   		atomic_inc(&sbi->wb_sync_req[DATA]);
>   	else if (atomic_read(&sbi->wb_sync_req[DATA])) {
>   		/* to avoid potential deadlock */
> -		if (current->plug)
> -			blk_finish_plug(current->plug);

What about?

if (current->plug) {
	struct blk_plug *plug = current->plug;

	blk_finish_plug(plug);
	blk_start_plug(plug);
}

Jaegeuk, thoughts?

Thanks,

> +		blk_flush_plug(current->plug, false);
>   		goto skip_write;
>   	}
>   
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index ee2e1dd64f25..c4b5717a8c1a 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -2126,8 +2126,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
>   		atomic_inc(&sbi->wb_sync_req[NODE]);
>   	else if (atomic_read(&sbi->wb_sync_req[NODE])) {
>   		/* to avoid potential deadlock */
> -		if (current->plug)
> -			blk_finish_plug(current->plug);
> +		blk_flush_plug(current->plug, false);
>   		goto skip_write;
>   	}
>   


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
  2023-09-04  8:21 ` Chao Yu
@ 2023-09-04 16:40   ` Jaegeuk Kim
  2023-09-05 13:42     ` Chunhai Guo via Linux-f2fs-devel
  0 siblings, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2023-09-04 16:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: Chunhai Guo, linux-f2fs-devel

On 09/04, Chao Yu wrote:
> On 2023/8/31 15:10, Chunhai Guo wrote:
> > The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
> > requires unplugging current->plug. Using blk_finish_plug() is unnecessary
> > as it sets current->plug as NULL and prevents wb_writeback() from using
> > plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.
> > 
> > Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
> > ---
> >   fs/f2fs/data.c | 3 +--
> >   fs/f2fs/node.c | 3 +--
> >   2 files changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 916e317ac925..77b4a55d6d94 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -3346,8 +3346,7 @@ static int __f2fs_write_data_pages(struct address_space *mapping,
> >   		atomic_inc(&sbi->wb_sync_req[DATA]);
> >   	else if (atomic_read(&sbi->wb_sync_req[DATA])) {
> >   		/* to avoid potential deadlock */
> > -		if (current->plug)
> > -			blk_finish_plug(current->plug);
> 
> What about?
> 
> if (current->plug) {
> 	struct blk_plug *plug = current->plug;
> 
> 	blk_finish_plug(plug);
> 	blk_start_plug(plug);
> }
> 
> Jaegeuk, thoughts?

By the way, do we really need to reuse current->plug again? After checkpoint
being done, we can use the plug in __f2fs_write_data_pages. Are there some
numbers to show the benefit?

> 
> Thanks,
> 
> > +		blk_flush_plug(current->plug, false);
> >   		goto skip_write;
> >   	}
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index ee2e1dd64f25..c4b5717a8c1a 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -2126,8 +2126,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
> >   		atomic_inc(&sbi->wb_sync_req[NODE]);
> >   	else if (atomic_read(&sbi->wb_sync_req[NODE])) {
> >   		/* to avoid potential deadlock */
> > -		if (current->plug)
> > -			blk_finish_plug(current->plug);
> > +		blk_flush_plug(current->plug, false);
> >   		goto skip_write;
> >   	}


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
  2023-09-04 16:40   ` Jaegeuk Kim
@ 2023-09-05 13:42     ` Chunhai Guo via Linux-f2fs-devel
  2023-09-06 13:31       ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: Chunhai Guo via Linux-f2fs-devel @ 2023-09-05 13:42 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu; +Cc: linux-f2fs-devel@lists.sourceforge.net



On 2023/9/5 0:40, Jaegeuk Kim wrote:
> On 09/04, Chao Yu wrote:
>> On 2023/8/31 15:10, Chunhai Guo wrote:
>>> The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
>>> requires unplugging current->plug. Using blk_finish_plug() is unnecessary
>>> as it sets current->plug as NULL and prevents wb_writeback() from using
>>> plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.
>>>
>>> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
>>> ---
>>>    fs/f2fs/data.c | 3 +--
>>>    fs/f2fs/node.c | 3 +--
>>>    2 files changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>>> index 916e317ac925..77b4a55d6d94 100644
>>> --- a/fs/f2fs/data.c
>>> +++ b/fs/f2fs/data.c
>>> @@ -3346,8 +3346,7 @@ static int __f2fs_write_data_pages(struct address_space *mapping,
>>>    		atomic_inc(&sbi->wb_sync_req[DATA]);
>>>    	else if (atomic_read(&sbi->wb_sync_req[DATA])) {
>>>    		/* to avoid potential deadlock */
>>> -		if (current->plug)
>>> -			blk_finish_plug(current->plug);
>>
>> What about?
>>
>> if (current->plug) {
>> 	struct blk_plug *plug = current->plug;
>>
>> 	blk_finish_plug(plug);
>> 	blk_start_plug(plug);
>> }
>>
>> Jaegeuk, thoughts?
> 
> By the way, do we really need to reuse current->plug again? After checkpoint
> being done, we can use the plug in __f2fs_write_data_pages. Are there some
> numbers to show the benefit?
> 

I don't have a number on this, but I think that reusing current->plug 
can help maintain the original intention of wb_writeback(). 
Nevertheless, it can be a viable alternative to use the plug in 
__f2fs_write_data_pages().

Thanks.
>>
>> Thanks,
>>
>>> +		blk_flush_plug(current->plug, false);
>>>    		goto skip_write;
>>>    	}
>>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>>> index ee2e1dd64f25..c4b5717a8c1a 100644
>>> --- a/fs/f2fs/node.c
>>> +++ b/fs/f2fs/node.c
>>> @@ -2126,8 +2126,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
>>>    		atomic_inc(&sbi->wb_sync_req[NODE]);
>>>    	else if (atomic_read(&sbi->wb_sync_req[NODE])) {
>>>    		/* to avoid potential deadlock */
>>> -		if (current->plug)
>>> -			blk_finish_plug(current->plug);
>>> +		blk_flush_plug(current->plug, false);
>>>    		goto skip_write;
>>>    	}


_______________________________________________
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] 6+ messages in thread

* Re: [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug()
  2023-09-05 13:42     ` Chunhai Guo via Linux-f2fs-devel
@ 2023-09-06 13:31       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2023-09-06 13:31 UTC (permalink / raw)
  To: Jaegeuk Kim, Chunhai Guo; +Cc: linux-f2fs-devel@lists.sourceforge.net

On 2023/9/5 21:42, Chunhai Guo wrote:
> 
> 
> On 2023/9/5 0:40, Jaegeuk Kim wrote:
>> On 09/04, Chao Yu wrote:
>>> On 2023/8/31 15:10, Chunhai Guo wrote:
>>>> The commit 344150999b7f ("f2fs: fix to avoid potential deadlock") only
>>>> requires unplugging current->plug. Using blk_finish_plug() is unnecessary
>>>> as it sets current->plug as NULL and prevents wb_writeback() from using
>>>> plug in subsequent loops. Instead, use blk_flush_plug() as a replacement.
>>>>
>>>> Signed-off-by: Chunhai Guo <guochunhai@vivo.com>
>>>> ---
>>>>     fs/f2fs/data.c | 3 +--
>>>>     fs/f2fs/node.c | 3 +--
>>>>     2 files changed, 2 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
>>>> index 916e317ac925..77b4a55d6d94 100644
>>>> --- a/fs/f2fs/data.c
>>>> +++ b/fs/f2fs/data.c
>>>> @@ -3346,8 +3346,7 @@ static int __f2fs_write_data_pages(struct address_space *mapping,
>>>>     		atomic_inc(&sbi->wb_sync_req[DATA]);
>>>>     	else if (atomic_read(&sbi->wb_sync_req[DATA])) {
>>>>     		/* to avoid potential deadlock */
>>>> -		if (current->plug)
>>>> -			blk_finish_plug(current->plug);
>>>
>>> What about?
>>>
>>> if (current->plug) {
>>> 	struct blk_plug *plug = current->plug;
>>>
>>> 	blk_finish_plug(plug);
>>> 	blk_start_plug(plug);
>>> }
>>>
>>> Jaegeuk, thoughts?
>>
>> By the way, do we really need to reuse current->plug again? After checkpoint
>> being done, we can use the plug in __f2fs_write_data_pages. Are there some
>> numbers to show the benefit?
>>
> 
> I don't have a number on this, but I think that reusing current->plug
> can help maintain the original intention of wb_writeback().
> Nevertheless, it can be a viable alternative to use the plug in
> __f2fs_write_data_pages().

I don't have numbers as well, but it can avoid break the intention of
per-writeback-work plug, which tries to merge IOs from all dirty inode.

Thanks,

> 
> Thanks.
>>>
>>> Thanks,
>>>
>>>> +		blk_flush_plug(current->plug, false);
>>>>     		goto skip_write;
>>>>     	}
>>>> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
>>>> index ee2e1dd64f25..c4b5717a8c1a 100644
>>>> --- a/fs/f2fs/node.c
>>>> +++ b/fs/f2fs/node.c
>>>> @@ -2126,8 +2126,7 @@ static int f2fs_write_node_pages(struct address_space *mapping,
>>>>     		atomic_inc(&sbi->wb_sync_req[NODE]);
>>>>     	else if (atomic_read(&sbi->wb_sync_req[NODE])) {
>>>>     		/* to avoid potential deadlock */
>>>> -		if (current->plug)
>>>> -			blk_finish_plug(current->plug);
>>>> +		blk_flush_plug(current->plug, false);
>>>>     		goto skip_write;
>>>>     	}


_______________________________________________
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] 6+ messages in thread

end of thread, other threads:[~2023-09-06 18:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31  7:10 [f2fs-dev] [PATCH v2] f2fs: replace blk_finish_plug() with blk_flush_plug() Chunhai Guo via Linux-f2fs-devel
2023-08-31  7:43 ` Chao Yu
2023-09-04  8:21 ` Chao Yu
2023-09-04 16:40   ` Jaegeuk Kim
2023-09-05 13:42     ` Chunhai Guo via Linux-f2fs-devel
2023-09-06 13:31       ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).