All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Coly Li <colyli@suse.de>, linux-bcache@vger.kernel.org, axboe@kernel.dk
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH 5/6] bcache: set dc->io_disable to true in conditional_stop_bcache_device()
Date: Thu, 3 May 2018 07:55:37 +0200	[thread overview]
Message-ID: <0c17c570-ad0b-9366-bc48-6938d4c75392@suse.de> (raw)
In-Reply-To: <20180502144659.118628-6-colyli@suse.de>

On 05/02/2018 04:46 PM, Coly Li wrote:
> Commit 7e027ca4b534b ("bcache: add stop_when_cache_set_failed option to
> backing device") adds stop_when_cache_set_failed option and stops bcache
> device if stop_when_cache_set_failed is auto and there is dirty data on
> broken cache device. There might exists a small time gap that the cache
> set is released and set to NULL but bcache device is not released yet
> (because they are released in parallel). During this time gap, dc->c is
> NULL so CACHE_SET_IO_DISABLE won't be checked, and dc->io_disable is still
> false, so new coming I/O requests will be accepted and directly go into
> backing device as no cache set attached to. If there is dirty data on
> cache device, this behavior may introduce potential inconsistent data.
> 
> This patch sets dc->io_disable to true before calling bcache_device_stop()
> to make sure the backing device will reject new coming I/O request as
> well, so even in the small time gap no I/O will directly go into backing
> device to corrupt data consistency.
> 
> Fixes: 7e027ca4b534b ("bcache: add stop_when_cache_set_failed option to backing device")
> Signed-off-by: Coly Li <colyli@suse.de>
> ---
>   drivers/md/bcache/super.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index a0d5a3ccc7d0..507755fcac5a 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1556,6 +1556,20 @@ static void conditional_stop_bcache_device(struct cache_set *c,
>   		 */
>   		pr_warn("stop_when_cache_set_failed of %s is \"auto\" and cache is dirty, stop it to avoid potential data corruption.",
>   			d->disk->disk_name);
> +			/*
> +			 * There might be a small time gap that cache set is
> +			 * released but bcache device is not. Inside this time
> +			 * gap, regular I/O requests will directly go into
> +			 * backing device as no cache set attached to. This
> +			 * behavior may also introduce potential inconsistence
> +			 * data in writeback mode while cache is dirty.
> +			 * Therefore before calling bcache_device_stop() due
> +			 * to a broken cache device, dc->io_disable should be
> +			 * explicitly set to true.
> +			 */
> +			dc->io_disable = true;
> +			/* make others know io_disable is true earlier */
> +			smp_mb();
>   			bcache_device_stop(d);
>   	} else {
>   		/*
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes

  reply	other threads:[~2018-05-03  5:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 14:46 [PATCH v2 0/6] bcache device failure handling fixes for 4.17-rc4 Coly Li
2018-05-02 14:46 ` [PATCH 1/6] bcache: store disk name in struct cache and struct cached_dev Coly Li
2018-05-03  5:51   ` Hannes Reinecke
2018-05-02 14:46 ` [PATCH 2/6] bcache: set CACHE_SET_IO_DISABLE in bch_cached_dev_error() Coly Li
2018-05-03  5:53   ` Hannes Reinecke
2018-05-02 14:46 ` [PATCH 3/6] bcache: count backing device I/O error for writeback I/O Coly Li
2018-05-03  5:53   ` Hannes Reinecke
2018-05-02 14:46 ` [PATCH 4/6] bcache: add wait_for_kthread_stop() in bch_allocator_thread() Coly Li
2018-05-03  5:54   ` Hannes Reinecke
2018-05-02 14:46 ` [PATCH 5/6] bcache: set dc->io_disable to true in conditional_stop_bcache_device() Coly Li
2018-05-03  5:55   ` Hannes Reinecke [this message]
2018-05-02 14:46 ` [PATCH 6/6] bcache: use pr_info() to inform duplicated CACHE_SET_IO_DISABLE set Coly Li
2018-05-02 15:01   ` Coly Li
2018-05-03  5:56   ` Hannes Reinecke
  -- strict thread matches above, loose matches on Subject: below --
2018-04-24 12:14 [PATCH 0/6] bcache fixes for device failure handling Coly Li
2018-04-24 12:14 ` [PATCH 5/6] bcache: set dc->io_disable to true in conditional_stop_bcache_device() Coly Li

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=0c17c570-ad0b-9366-bc48-6938d4c75392@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --cc=colyli@suse.de \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-block@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.