LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control
@ 2021-08-11 13:18 Yangtao Li
  2021-08-11 13:18 ` [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard Yangtao Li
  2021-08-11 13:36 ` [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control Chao Yu
  0 siblings, 2 replies; 4+ messages in thread
From: Yangtao Li @ 2021-08-11 13:18 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Yangtao Li

Release f2fs_issue_discard every time it is destroyed,
otherwise it will cause memory leaks when remounting.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/segment.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index afe20c5c3c08..363779a4402d 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1741,6 +1741,7 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
 
 		dcc->f2fs_issue_discard = NULL;
 		kthread_stop(discard_thread);
+		put_task_struct(discard_thread);
 	}
 }
 
@@ -2168,6 +2169,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
 		SM_I(sbi)->dcc_info = NULL;
 		return err;
 	}
+	get_task_struct(dcc->f2fs_issue_discard);
 
 	return err;
 }
-- 
2.32.0


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

* [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard
  2021-08-11 13:18 [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control Yangtao Li
@ 2021-08-11 13:18 ` Yangtao Li
  2021-08-11 13:44   ` Chao Yu
  2021-08-11 13:36 ` [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control Chao Yu
  1 sibling, 1 reply; 4+ messages in thread
From: Yangtao Li @ 2021-08-11 13:18 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, Fengnan Chang, Yangtao Li

From: Fengnan Chang <changfengnan@vivo.com>

Don't create discard thread when device not support realtime discard.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/segment.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 363779a4402d..bc4ac46f3041 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2161,6 +2161,8 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
 	init_waitqueue_head(&dcc->discard_wait_queue);
 	SM_I(sbi)->dcc_info = dcc;
 init_thread:
+	if (!f2fs_realtime_discard_enable(sbi))
+		return err;
 	dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
 				"f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
 	if (IS_ERR(dcc->f2fs_issue_discard)) {
-- 
2.32.0


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

* Re: [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control
  2021-08-11 13:18 [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control Yangtao Li
  2021-08-11 13:18 ` [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard Yangtao Li
@ 2021-08-11 13:36 ` Chao Yu
  1 sibling, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-08-11 13:36 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel

On 2021/8/11 21:18, Yangtao Li wrote:
> Release f2fs_issue_discard every time it is destroyed,
> otherwise it will cause memory leaks when remounting.

I didn't get the problem here, could you please explain a bit more about
details?

Thanks,

> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/segment.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index afe20c5c3c08..363779a4402d 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1741,6 +1741,7 @@ void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
>   
>   		dcc->f2fs_issue_discard = NULL;
>   		kthread_stop(discard_thread);
> +		put_task_struct(discard_thread);
>   	}
>   }
>   
> @@ -2168,6 +2169,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
>   		SM_I(sbi)->dcc_info = NULL;
>   		return err;
>   	}
> +	get_task_struct(dcc->f2fs_issue_discard);
>   
>   	return err;
>   }
> 

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

* Re: [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard
  2021-08-11 13:18 ` [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard Yangtao Li
@ 2021-08-11 13:44   ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2021-08-11 13:44 UTC (permalink / raw)
  To: Yangtao Li, jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, Fengnan Chang

On 2021/8/11 21:18, Yangtao Li wrote:
> From: Fengnan Chang <changfengnan@vivo.com>
> 
> Don't create discard thread when device not support realtime discard.
> 
> Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   fs/f2fs/segment.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 363779a4402d..bc4ac46f3041 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -2161,6 +2161,8 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
>   	init_waitqueue_head(&dcc->discard_wait_queue);
>   	SM_I(sbi)->dcc_info = dcc;
>   init_thread:
> +	if (!f2fs_realtime_discard_enable(sbi))

How about below case:
- mount -o nodiscard <dev> <mp>
- mount -o remount,discard <dev> <mp>

Thanks,

> +		return err;
>   	dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
>   				"f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
>   	if (IS_ERR(dcc->f2fs_issue_discard)) {
> 

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

end of thread, other threads:[~2021-08-11 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 13:18 [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control Yangtao Li
2021-08-11 13:18 ` [PATCH 2/2] fs: Don't create discard thread when device not support realtime discard Yangtao Li
2021-08-11 13:44   ` Chao Yu
2021-08-11 13:36 ` [PATCH 1/2] f2fs: fix potential memory leaks in create_discard_cmd_control 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).