* [PATCH] bcache: move calc_cached_dev_sectors to proper place on backing device detach
@ 2021-10-15 10:16 Lin Feng
2021-10-18 14:38 ` Coly Li
0 siblings, 1 reply; 2+ messages in thread
From: Lin Feng @ 2021-10-15 10:16 UTC (permalink / raw)
To: colyli, kent.overstreet; +Cc: linux-bcache, linux-kernel, linf
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>
---
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);
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] bcache: move calc_cached_dev_sectors to proper place on backing device detach
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
0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2021-10-18 14:38 UTC (permalink / raw)
To: Lin Feng; +Cc: linux-bcache, linux-kernel, kent.overstreet
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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-18 14:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).