[RHEL7,COMMIT] fs/fuse kio: calculate network latency properly

Submitted by Vasily Averin on Aug. 6, 2020, 6:49 a.m.

Details

Message ID 202008060649.0766nrod004791@vz7build.vvs.sw.ru
State New
Series "fs/fuse kio: calculate network latency properly"
Headers show

Commit Message

Vasily Averin Aug. 6, 2020, 6:49 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.158.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.158.4
------>
commit 2f2214db166266b307afa607d50cb70b8c51e2d5
Author: Ildar Ismagilov <Ildar.Ismagilov@acronis.com>
Date:   Thu Aug 6 09:49:53 2020 +0300

    fs/fuse kio: calculate network latency properly
    
    Fix incorrect calculation of network latency in case of more than
    one replica.
    
    For example, in case of 3 replicas the network latency should be
    calculated like this:
    net_lat = lat - max(CS[0].ts_net, CS[0].ts_io) +
              CS[0].ts_net - max(CS[1].ts_net, CS[1].ts_io) +
              CS[1].ts_net - max(CS[2].ts_net, CS[2].ts_io);
    
    Signed-off-by: Ildar Ismagilov <Ildar.Ismagilov@acronis.com>
    Acked-by: Alexey Kuznetsov <Alexey.Kuznetsov@acronis.com>
    Acked-by: Andrey Zaitsev <azaitsev@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_map.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_map.c b/fs/fuse/kio/pcs/pcs_map.c
index 89caac4..502e1b1 100644
--- a/fs/fuse/kio/pcs/pcs_map.c
+++ b/fs/fuse/kio/pcs/pcs_map.c
@@ -2684,8 +2684,12 @@  static int commit_sync_info(struct pcs_int_request *req,
 	struct pcs_cs_iohdr *h = (struct pcs_cs_iohdr *)resp->_inline_buffer;
 	int err = 0;
 	unsigned int max_iolat, lat = calc_latency(req->ts_sent);
+	unsigned int net_lat;
+	u32 max_lat;
 
 	err |= commit_one_record(m, resp->rpc->peer_id, &h->sync, lat, h->hdr.type);
+	max_lat = max_t(u32, h->sync.ts_net, h->sync.ts_io);
+	net_lat = lat < max_lat ? 0 : lat - max_lat;
 
 	/* Network latency is updated only for the first CS in chain.
 	 * The results for anothers are ignored, which looks sad, because we lose
@@ -2707,12 +2711,14 @@  static int commit_sync_info(struct pcs_int_request *req,
 		     (void*)(srec + 1) <= (void*)h + h->hdr.len;
 		     srec++) {
 			err |= commit_one_record(m, srec->cs_id, &srec->sync, lat, h->hdr.type);
+			max_lat = max_t(u32, srec->sync.ts_net, srec->sync.ts_io);
+			net_lat += lat < max_lat ? 0 : lat - max_lat;
 			lat  = srec->sync.ts_net;
 			if (max_iolat < srec->sync.ts_io)
 				max_iolat = srec->sync.ts_io;
 		}
 	}
-	pcs_fuse_stat_io_count(req, resp, max_iolat, lat - max_iolat);
+	pcs_fuse_stat_io_count(req, resp, max_iolat, net_lat);
 	cs_log_io_times(req, resp, max_iolat);
 
 	evaluate_dirty_status(m);