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

Submitted by Vasily Averin on Sept. 23, 2020, 12:57 p.m.

Details

Message ID 202009231257.08NCvBZ2014993@vz7build.vvs.sw.ru
State New
Series "ploop: zero-out block device statistics at ploop_stop"
Headers show

Commit Message

Vasily Averin Sept. 23, 2020, 12:57 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.28
------>
commit 1a3cd07a8bcd508ee6c02450bfcde8780d99b7e8
Author: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
Date:   Wed Sep 23 15:57:10 2020 +0300

    ploop: zero-out block device statistics at ploop_stop
    
    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(+)

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);