ceph: avoid counting the same request twice or more
authorXiubo Li <xiubli@redhat.com>
Mon, 22 Mar 2021 12:28:51 +0000 (20:28 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 27 Apr 2021 21:52:23 +0000 (23:52 +0200)
If the request will retry, skip updating the latency metric.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/file.c

index a27aabc..31542ea 100644 (file)
@@ -1037,16 +1037,6 @@ static void ceph_aio_complete_req(struct ceph_osd_request *req)
        dout("ceph_aio_complete_req %p rc %d bytes %u\n",
             inode, rc, osd_data->bvec_pos.iter.bi_size);
 
-       /* r_start_latency == 0 means the request was not submitted */
-       if (req->r_start_latency) {
-               if (aio_req->write)
-                       ceph_update_write_metrics(metric, req->r_start_latency,
-                                                 req->r_end_latency, rc);
-               else
-                       ceph_update_read_metrics(metric, req->r_start_latency,
-                                                req->r_end_latency, rc);
-       }
-
        if (rc == -EOLDSNAPC) {
                struct ceph_aio_work *aio_work;
                BUG_ON(!aio_req->write);
@@ -1089,6 +1079,16 @@ static void ceph_aio_complete_req(struct ceph_osd_request *req)
                }
        }
 
+       /* r_start_latency == 0 means the request was not submitted */
+       if (req->r_start_latency) {
+               if (aio_req->write)
+                       ceph_update_write_metrics(metric, req->r_start_latency,
+                                                 req->r_end_latency, rc);
+               else
+                       ceph_update_read_metrics(metric, req->r_start_latency,
+                                                req->r_end_latency, rc);
+       }
+
        put_bvecs(osd_data->bvec_pos.bvecs, osd_data->num_bvecs,
                  aio_req->should_dirty);
        ceph_osdc_put_request(req);