linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: zstd ensure reclaim timer is properly cleaned up
@ 2019-02-21 20:25 Dennis Zhou
  2019-02-22 12:17 ` Nikolay Borisov
  0 siblings, 1 reply; 3+ messages in thread
From: Dennis Zhou @ 2019-02-21 20:25 UTC (permalink / raw)
  To: David Sterba, Josef Bacik, Chris Mason, Omar Sandoval,
	Nick Terrell, Nikolay Borisov
  Cc: kernel-team, linux-btrfs, linux-kernel, Dennis Zhou

The timer function, zstd_reclaim_timer_fn(), reschedules itself under
certain conditions. Switch to del_timer_sync() to ensure that the timer
function hasn't rescheduled itself.

Signed-off-by: Dennis Zhou <dennis@kernel.org>
---
 fs/btrfs/zstd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
index 3e418a3aeb11..62de9a211321 100644
--- a/fs/btrfs/zstd.c
+++ b/fs/btrfs/zstd.c
@@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
 	struct workspace *workspace;
 	int i;
 
-	del_timer(&wsm.timer);
+	del_timer_sync(&wsm.timer);
 
 	for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
 		while (!list_empty(&wsm.idle_ws[i])) {
-- 
2.17.1


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

* Re: [PATCH] btrfs: zstd ensure reclaim timer is properly cleaned up
  2019-02-21 20:25 [PATCH] btrfs: zstd ensure reclaim timer is properly cleaned up Dennis Zhou
@ 2019-02-22 12:17 ` Nikolay Borisov
  2019-02-22 16:53   ` Dennis Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2019-02-22 12:17 UTC (permalink / raw)
  To: Dennis Zhou, David Sterba, Josef Bacik, Chris Mason,
	Omar Sandoval, Nick Terrell
  Cc: kernel-team, linux-btrfs, linux-kernel



On 21.02.19 г. 22:25 ч., Dennis Zhou wrote:
> The timer function, zstd_reclaim_timer_fn(), reschedules itself under
> certain conditions. Switch to del_timer_sync() to ensure that the timer
> function hasn't rescheduled itself.

According to del_timer_sync it just waits for any concurrent invocation
to finish. But it's responsibility of the caller to ensure the timer
cannot really be restarted. It's not obvious how
zstd_cleanup_workspace_manager ensures that the timer won't be restared.
Looking at the timer function for it to not restart wsm.lru_list has to
be empty. And seeing that workspace->lru_list is deleted afterwards I'm
not sure this invariant holds.

> 
> Signed-off-by: Dennis Zhou <dennis@kernel.org>
> ---
>  fs/btrfs/zstd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
> index 3e418a3aeb11..62de9a211321 100644
> --- a/fs/btrfs/zstd.c
> +++ b/fs/btrfs/zstd.c
> @@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
>  	struct workspace *workspace;
>  	int i;
>  
> -	del_timer(&wsm.timer);
> +	del_timer_sync(&wsm.timer);
>  
>  	for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
>  		while (!list_empty(&wsm.idle_ws[i])) {
> 

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

* Re: [PATCH] btrfs: zstd ensure reclaim timer is properly cleaned up
  2019-02-22 12:17 ` Nikolay Borisov
@ 2019-02-22 16:53   ` Dennis Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Dennis Zhou @ 2019-02-22 16:53 UTC (permalink / raw)
  To: Nikolay Borisov
  Cc: Dennis Zhou, David Sterba, Josef Bacik, Chris Mason,
	Omar Sandoval, Nick Terrell, kernel-team, linux-btrfs,
	linux-kernel

On Fri, Feb 22, 2019 at 02:17:41PM +0200, Nikolay Borisov wrote:
> 
> 
> On 21.02.19 г. 22:25 ч., Dennis Zhou wrote:
> > The timer function, zstd_reclaim_timer_fn(), reschedules itself under
> > certain conditions. Switch to del_timer_sync() to ensure that the timer
> > function hasn't rescheduled itself.
> 
> According to del_timer_sync it just waits for any concurrent invocation
> to finish. But it's responsibility of the caller to ensure the timer
> cannot really be restarted. It's not obvious how
> zstd_cleanup_workspace_manager ensures that the timer won't be restared.
> Looking at the timer function for it to not restart wsm.lru_list has to
> be empty. And seeing that workspace->lru_list is deleted afterwards I'm
> not sure this invariant holds.
> 

Hmmm, I see. I misunderstood the invariant. I'll spin v2 and handle it
another way.

Thanks,
Dennis

> > 
> > Signed-off-by: Dennis Zhou <dennis@kernel.org>
> > ---
> >  fs/btrfs/zstd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
> > index 3e418a3aeb11..62de9a211321 100644
> > --- a/fs/btrfs/zstd.c
> > +++ b/fs/btrfs/zstd.c
> > @@ -195,7 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
> >  	struct workspace *workspace;
> >  	int i;
> >  
> > -	del_timer(&wsm.timer);
> > +	del_timer_sync(&wsm.timer);
> >  
> >  	for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
> >  		while (!list_empty(&wsm.idle_ws[i])) {
> > 

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

end of thread, other threads:[~2019-02-22 16:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-21 20:25 [PATCH] btrfs: zstd ensure reclaim timer is properly cleaned up Dennis Zhou
2019-02-22 12:17 ` Nikolay Borisov
2019-02-22 16:53   ` Dennis Zhou

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).