Whamcloud - gitweb
LU-9019 obd: express timeouts in timeout_t
[fs/lustre-release.git] / lustre / include / lustre_net.h
index a7c196a..b77a794 100644 (file)
@@ -778,8 +778,10 @@ struct ptlrpc_hpreq_ops {
 struct ptlrpc_cli_req {
        /** For bulk requests on client only: bulk descriptor */
        struct ptlrpc_bulk_desc         *cr_bulk;
-       /** optional time limit for send attempts */
-       time64_t                         cr_delay_limit;
+       /** optional time limit for send attempts. This is a timeout
+        *  not a timestamp so timeout_t (s32) is used instead of time64_t
+        */
+       timeout_t                        cr_delay_limit;
        /** time request was first queued */
        time64_t                         cr_queued_time;
        /** request sent in nanoseconds */
@@ -2559,6 +2561,30 @@ ptlrpc_server_get_timeout(struct ptlrpc_service_part *svcpt)
               max_t(int, at, obd_timeout);
 }
 
+/**
+ * Calculate the amount of time for lock prolongation.
+ *
+ * This is helper function to get the timeout extra time.
+ *
+ * @req                current request
+ *
+ * Return:     amount of time to extend the timeout with
+ */
+static inline timeout_t prolong_timeout(struct ptlrpc_request *req)
+{
+       struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt;
+       timeout_t req_timeout = 0;
+
+       if (AT_OFF)
+               return obd_timeout / 2;
+
+       if (req->rq_deadline > req->rq_arrival_time.tv_sec)
+               req_timeout = req->rq_deadline - req->rq_arrival_time.tv_sec;
+
+       return max(req_timeout,
+                  at_est2timeout(at_get(&svcpt->scp_at_estimate)));
+}
+
 static inline struct ptlrpc_service *
 ptlrpc_req2svc(struct ptlrpc_request *req)
 {