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

Kirill Tkhai ktkhai at virtuozzo.com
Tue Sep 22 18:58:46 MSK 2020


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 at virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai at 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);
>  
> 



More information about the Devel mailing list