[RHEL7] ploop: zero-out block device statistics at ploop_stop

Submitted by Valeriy Vdovin on Sept. 22, 2020, 3:57 p.m.

Details

Message ID 1600790258-829817-1-git-send-email-valeriy.vdovin@virtuozzo.com
State New
Series "ploop: zero-out block device statistics at ploop_stop"
Headers show

Commit Message

Valeriy Vdovin Sept. 22, 2020, 3:57 p.m.
ploop block device is represented by a block device file in /dev, but
it's lifecycle is separated from the file itself by PLOOP_IOC_START and
PLOOP_IOC_STOP ioctls. This way ploop file in /dev can be an empty
placeholder after PLOOP_IOC_STOP ioctl and reinitialized later by a
PLOOP_IOC_START. Because of that some of the important data structures
stay allocated after stop and maintain old values until and after restart.
This situation is also true for block device statistics that remain unchanged
after end of ploop device lifecycle. Fresh-started ploop device is considered
a new entity with stats equal to zero. For that we zero out stats at ploop_stop.

https://jira.sw.ru/browse/PSBM-95605

Signed-off-by: Valeriy.Vdovin <valeriy.vdovin@virtuozzo.com>
---
 drivers/block/ploop/dev.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index ac4d142..c54ff90 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4373,6 +4373,9 @@  static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
 
 	clear_bit(PLOOP_S_RUNNING, &plo->state);
 
+	part_stat_set_all(&plo->disk->part0, 0);
+	memset(&plo->st, 0, sizeof(plo->st));
+
 	del_timer_sync(&plo->mitigation_timer);
 	del_timer_sync(&plo->freeze_timer);
 

Comments

Kirill Tkhai Sept. 22, 2020, 3:58 p.m.
On 22.09.2020 18:57, Valeriy Vdovin wrote:
> ploop block device is represented by a block device file in /dev, but
> it's lifecycle is separated from the file itself by PLOOP_IOC_START and
> PLOOP_IOC_STOP ioctls. This way ploop file in /dev can be an empty
> placeholder after PLOOP_IOC_STOP ioctl and reinitialized later by a
> PLOOP_IOC_START. Because of that some of the important data structures
> stay allocated after stop and maintain old values until and after restart.
> This situation is also true for block device statistics that remain unchanged
> after end of ploop device lifecycle. Fresh-started ploop device is considered
> a new entity with stats equal to zero. For that we zero out stats at ploop_stop.
> 
> https://jira.sw.ru/browse/PSBM-95605
> 
> Signed-off-by: Valeriy.Vdovin <valeriy.vdovin@virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>

> ---
>  drivers/block/ploop/dev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
> index ac4d142..c54ff90 100644
> --- a/drivers/block/ploop/dev.c
> +++ b/drivers/block/ploop/dev.c
> @@ -4373,6 +4373,9 @@ static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
>  
>  	clear_bit(PLOOP_S_RUNNING, &plo->state);
>  
> +	part_stat_set_all(&plo->disk->part0, 0);
> +	memset(&plo->st, 0, sizeof(plo->st));
> +
>  	del_timer_sync(&plo->mitigation_timer);
>  	del_timer_sync(&plo->freeze_timer);
>  
>