Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: scrub: add assertions for worker pointers
Date: Thu, 14 Feb 2019 00:02:32 +0800
Message-ID: <9049a31d-703e-9800-8bde-6d86867e9e82@oracle.com> (raw)
In-Reply-To: <20190212171540.11518-1-dsterba@suse.com>



On 2/13/19 1:15 AM, David Sterba wrote:
> The scrub worker pointers are not NULL iff the scrub is running, so
> reset them back once the last reference is dropped. Add assertions to
> the initial phase of scrub to verify that.

makes sense.

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


Reviewed-by: Anand Jain <anand.jain@oracle.com>



> ---
>   fs/btrfs/ctree.h | 4 ++++
>   fs/btrfs/scrub.c | 7 +++++++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 7efa1edb30cd..f92f97304e69 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1075,6 +1075,10 @@ struct btrfs_fs_info {
>   	atomic_t scrubs_paused;
>   	atomic_t scrub_cancel_req;
>   	wait_queue_head_t scrub_pause_wait;
> +	/*
> +	 * The worker pointers are NULL iff the refcount is 0, ie. scrub is not
> +	 * running.
> +	 */
>   	refcount_t scrub_workers_refcnt;
>   	struct btrfs_workqueue *scrub_workers;
>   	struct btrfs_workqueue *scrub_wr_completion_workers;
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index d20150d68a90..669bedfec4a9 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -3744,17 +3744,20 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
>   	lockdep_assert_held(&fs_info->scrub_lock);
>   
>   	if (refcount_read(&fs_info->scrub_workers_refcnt) == 0) {
> +		ASSERT(fs_info->scrub_workers == NULL);
>   		fs_info->scrub_workers = btrfs_alloc_workqueue(fs_info, "scrub",
>   				flags, is_dev_replace ? 1 : max_active, 4);
>   		if (!fs_info->scrub_workers)
>   			goto fail_scrub_workers;
>   
> +		ASSERT(fs_info->scrub_wr_completion_workers == NULL);
>   		fs_info->scrub_wr_completion_workers =
>   			btrfs_alloc_workqueue(fs_info, "scrubwrc", flags,
>   					      max_active, 2);
>   		if (!fs_info->scrub_wr_completion_workers)
>   			goto fail_scrub_wr_completion_workers;
>   
> +		ASSERT(fs_info->scrub_parity_workers == NULL);
>   		fs_info->scrub_parity_workers =
>   			btrfs_alloc_workqueue(fs_info, "scrubparity", flags,
>   					      max_active, 2);
> @@ -3934,6 +3937,10 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
>   		scrub_workers = fs_info->scrub_workers;
>   		scrub_wr_comp = fs_info->scrub_wr_completion_workers;
>   		scrub_parity = fs_info->scrub_parity_workers;
> +
> +		fs_info->scrub_workers = NULL;
> +		fs_info->scrub_wr_completion_workers = NULL;
> +		fs_info->scrub_parity_workers = NULL;
>   	}
>   	mutex_unlock(&fs_info->scrub_lock);
>   
> 

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  6:44 [PATCH v4 0/3] btrfs: scrub: fix scrub_lock Anand Jain
2019-01-30  6:45 ` [PATCH v4 1/3] btrfs: scrub: fix circular locking dependency warning Anand Jain
2019-01-30 14:07   ` David Sterba
2019-01-31  6:34     ` Anand Jain
2019-02-12 15:49       ` David Sterba
2019-02-12 16:45   ` David Sterba
2019-02-13 16:02     ` Anand Jain
2019-01-30  6:45 ` [PATCH v4 2/3] btrfs: scrub: add scrub_lock lockdep check in scrub_workers_get Anand Jain
2019-01-30  6:45 ` [PATCH v4 3/3] btrfs: scrub: convert scrub_workers_refcnt to refcount_t Anand Jain
2019-02-08 17:02 ` [PATCH v4 0/3] btrfs: scrub: fix scrub_lock David Sterba
2019-02-11  8:09   ` Anand Jain
2019-02-11  8:38 ` [PATCH v5 3/3] btrfs: scrub: convert scrub_workers_refcnt to refcount_t Anand Jain
2019-02-12 17:15 ` [PATCH] btrfs: scrub: add assertions for worker pointers David Sterba
2019-02-13 16:02   ` Anand Jain [this message]
2019-02-13 17:35 ` [PATCH v4 0/3] btrfs: scrub: fix scrub_lock David Sterba

Reply instructions:

You may reply publically 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=9049a31d-703e-9800-8bde-6d86867e9e82@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox