bcache: simplify the calculation of the total amount of flash dirty data
Currently we calculate the total amount of flash only devices dirty data by adding the dirty data of each flash only device under registering locker. It is very inefficient. In this patch, we add a member flash_dev_dirty_sectors in struct cache_set to record the total amount of flash only devices dirty data in real time, so we didn't need to calculate the total amount of dirty data any more. Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn> Signed-off-by: Coly Li <colyli@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
@@ -27,7 +27,7 @@ static uint64_t __calc_target_rate(struct cached_dev *dc)
|
||||
* flash-only devices
|
||||
*/
|
||||
uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size -
|
||||
bcache_flash_devs_sectors_dirty(c);
|
||||
atomic_long_read(&c->flash_dev_dirty_sectors);
|
||||
|
||||
/*
|
||||
* Unfortunately there is no control of global dirty data. If the
|
||||
@@ -476,6 +476,9 @@ void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
if (UUID_FLASH_ONLY(&c->uuids[inode]))
|
||||
atomic_long_add(nr_sectors, &c->flash_dev_dirty_sectors);
|
||||
|
||||
stripe = offset_to_stripe(d, offset);
|
||||
stripe_offset = offset & (d->stripe_size - 1);
|
||||
|
||||
|
Reference in New Issue
Block a user