linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Lin Feng <linf@wangsu.com>
Cc: linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	kent.overstreet@gmail.com
Subject: Re: [PATCH] bcache: move calc_cached_dev_sectors to proper place on backing device detach
Date: Mon, 18 Oct 2021 22:38:37 +0800	[thread overview]
Message-ID: <fcae5dd6-ddd7-d402-fed2-a42a473cf823@suse.de> (raw)
In-Reply-To: <20211015101600.91109-1-linf@wangsu.com>

On 10/15/21 6:16 PM, Lin Feng wrote:
> Calculation of cache_set's cached sectors is done by travelling
> cached_devs list as shown below:
>
> static void calc_cached_dev_sectors(struct cache_set *c)
> {
> ...
>          list_for_each_entry(dc, &c->cached_devs, list)
>                  sectors += bdev_sectors(dc->bdev);
>
>          c->cached_dev_sectors = sectors;
> }
>
> But cached_dev won't be unlinked from c->cached_devs list until we call
> following list_move(&dc->list, &uncached_devices),
> so previous fix in 'commit 46010141da6677b81cc77f9b47f8ac62bd1cbfd3
> ("bcache: recal cached_dev_sectors on detach")' is wrong, now we move
> it to its right palce.
>
> Signed-off-by: Lin Feng <linf@wangsu.com>

Nice catch! I added it in my testing series. Thanks.

Coly Li

> ---
>   drivers/md/bcache/super.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index f2874c77ff79..8543e6997770 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1154,9 +1154,9 @@ static void cached_dev_detach_finish(struct work_struct *w)
>   
>   	mutex_lock(&bch_register_lock);
>   
> -	calc_cached_dev_sectors(dc->disk.c);
>   	bcache_device_detach(&dc->disk);
>   	list_move(&dc->list, &uncached_devices);
> +	calc_cached_dev_sectors(dc->disk.c);
>   
>   	clear_bit(BCACHE_DEV_DETACHING, &dc->disk.flags);
>   	clear_bit(BCACHE_DEV_UNLINK_DONE, &dc->disk.flags);


      reply	other threads:[~2021-10-18 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15 10:16 [PATCH] bcache: move calc_cached_dev_sectors to proper place on backing device detach Lin Feng
2021-10-18 14:38 ` Coly Li [this message]

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=fcae5dd6-ddd7-d402-fed2-a42a473cf823@suse.de \
    --to=colyli@suse.de \
    --cc=kent.overstreet@gmail.com \
    --cc=linf@wangsu.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@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 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).