mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Dennis Zhou <dennis@kernel.org>
Cc: David Sterba <dsterba@suse.com>,
	Josef Bacik <josef@toxicpanda.com>, Chris Mason <clm@fb.com>,
	Omar Sandoval <osandov@osandov.com>,
	Nick Terrell <terrelln@fb.com>,
	Nikolay Borisov <nborisov@suse.com>,
	kernel-team@fb.com, linux-btrfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: zstd ensure reclaim timer is properly cleaned up
Date: Wed, 27 Feb 2019 17:44:41 +0100	[thread overview]
Message-ID: <20190227164441.GY24609@twin.jikos.cz> (raw)
In-Reply-To: <20190222195348.2728-1-dennis@kernel.org>

On Fri, Feb 22, 2019 at 02:53:48PM -0500, Dennis Zhou wrote:
> The timer function, zstd_reclaim_timer_fn(), reschedules itself under
> certain conditions. When cleaning up, take the lock and remove all
> workspaces. This prevents the timer from rearming itself. Lastly, switch
> to del_timer_sync() to ensure that the timer function can't trigger as
> we're unloading.
> 
> Signed-off-by: Dennis Zhou <dennis@kernel.org>

Reviewed-by: David Sterba <dsterba@suse.com>

> ---
> v2:
> - cleanup workspaces and then disable the timer
> 
>  fs/btrfs/zstd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c
> index 3e418a3aeb11..6b9e29d050f3 100644
> --- a/fs/btrfs/zstd.c
> +++ b/fs/btrfs/zstd.c
> @@ -195,8 +195,7 @@ static void zstd_cleanup_workspace_manager(void)
>  	struct workspace *workspace;
>  	int i;
>  
> -	del_timer(&wsm.timer);
> -
> +	spin_lock(&wsm.lock);
>  	for (i = 0; i < ZSTD_BTRFS_MAX_LEVEL; i++) {
>  		while (!list_empty(&wsm.idle_ws[i])) {
>  			workspace = container_of(wsm.idle_ws[i].next,
> @@ -206,6 +205,9 @@ static void zstd_cleanup_workspace_manager(void)
>  			wsm.ops->free_workspace(&workspace->list);

I've noticed while reading the code, why do you use the indirect call
here? The wsm.ops points to btrfs_zstd_compress so free_workspace is
always zstd_free_workspace.

The compiler is usually smart to replace such things by direct call if
the type has not escaped, but this is not true for btrfs_compress_op so
the indirect function call must be preserved.

  reply	other threads:[~2019-02-27 16:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 19:53 Dennis Zhou
2019-02-27 16:44 ` David Sterba [this message]
2019-02-27 18:29   ` Dennis Zhou
2019-02-27 18:36     ` David Sterba
2019-02-27 21:24       ` Dennis Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190227164441.GY24609@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dennis@kernel.org \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=osandov@osandov.com \
    --cc=terrelln@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®