From: Coly Li <colyli@suse.de>
To: mingzhe <mingzhe.zou@easystack.cn>
Cc: Eric Wheeler <bcache@lists.ewheeler.net>,
linux-bcache@vger.kernel.org, zoumingzhe@qq.com
Subject: Re: [PATCH] bcache: set io_disable to true when stop bcache device
Date: Wed, 8 Mar 2023 17:52:57 +0800 [thread overview]
Message-ID: <BB908A89-DE89-4C38-9B43-9A82520BE03D@suse.de> (raw)
In-Reply-To: <20230308092036.11024-1-mingzhe.zou@easystack.cn>
> 2023年3月8日 17:20,mingzhe <mingzhe.zou@easystack.cn> 写道:
>
> Stop is an operation that cannot be aborted. If there are still
> IO requests being processed, we can never stop the device.
> So, all new IO requests should fail when we set io_disable to true.
> However, sysfs has been unlinked at this time, user cannot modify
> io_disable via sysfs.
>
> Signed-off-by: mingzhe <mingzhe.zou@easystack.cn>
NACK. I tried this years ago, it might introduce potential risk for meta data inconsistency.
Coly Li
> ---
> drivers/md/bcache/request.c | 16 ++++++++++++++++
> drivers/md/bcache/super.c | 9 +++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
> index 67a2e29e0b40..9b85aad20022 100644
> --- a/drivers/md/bcache/request.c
> +++ b/drivers/md/bcache/request.c
> @@ -758,6 +758,15 @@ static void cached_dev_bio_complete(struct closure *cl)
> search_free(cl);
> }
>
> +static void cached_dev_bio_fail(struct closure *cl)
> +{
> + struct search *s = container_of(cl, struct search, cl);
> + struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
> +
> + s->iop.status = BLK_STS_IOERR;
> + cached_dev_bio_complete(cl);
> +}
> +
> /* Process reads */
>
> static void cached_dev_read_error_done(struct closure *cl)
> @@ -971,6 +980,9 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
> struct bkey start = KEY(dc->disk.id, bio->bi_iter.bi_sector, 0);
> struct bkey end = KEY(dc->disk.id, bio_end_sector(bio), 0);
>
> + if (unlikely((dc->io_disable)))
> + goto fail_bio;
> +
> bch_keybuf_check_overlapping(&s->iop.c->moving_gc_keys, &start, &end);
>
> down_read_non_owner(&dc->writeback_lock);
> @@ -1046,6 +1058,10 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
> insert_data:
> closure_call(&s->iop.cl, bch_data_insert, NULL, cl);
> continue_at(cl, cached_dev_write_complete, NULL);
> + return;
> +
> +fail_bio:
> + continue_at(cl, cached_dev_bio_fail, NULL);
> }
>
> static void cached_dev_nodata(struct closure *cl)
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index ba3909bb6bea..a2a82942f85b 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1389,6 +1389,15 @@ static void cached_dev_flush(struct closure *cl)
> bch_cache_accounting_destroy(&dc->accounting);
> kobject_del(&d->kobj);
>
> + /*
> + * Stop is an operation that cannot be aborted. If there are still
> + * IO requests being processed, we can never stop the device.
> + * So, all new IO requests should fail when we set io_disable to true.
> + * However, sysfs has been unlinked at this time, user cannot modify
> + * io_disable via sysfs.
> + */
> + dc->io_disable = true;
> +
> continue_at(cl, cached_dev_free, system_wq);
> }
>
> --
> 2.17.1.windows.2
>
next prev parent reply other threads:[~2023-03-08 9:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 9:20 [PATCH] bcache: set io_disable to true when stop bcache device mingzhe
2023-03-08 9:52 ` Coly Li [this message]
2023-03-08 12:16 ` kernel test robot
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=BB908A89-DE89-4C38-9B43-9A82520BE03D@suse.de \
--to=colyli@suse.de \
--cc=bcache@lists.ewheeler.net \
--cc=linux-bcache@vger.kernel.org \
--cc=mingzhe.zou@easystack.cn \
--cc=zoumingzhe@qq.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;
as well as URLs for NNTP newsgroup(s).