Whamcloud - gitweb
use special macro for print time_t, cleanup in includes.
[fs/lustre-release.git] / lustre / ptlrpc / client.c
index 6e13803..b536445 100644 (file)
@@ -663,26 +663,34 @@ static int ptlrpc_import_delay_req(struct obd_import *imp,
         } else if (req->rq_send_state == LUSTRE_IMP_CONNECTING &&
                    imp->imp_state == LUSTRE_IMP_CONNECTING) {
                 /* allow CONNECT even if import is invalid */ ;
-        } else if (imp->imp_invalid && (!imp->imp_recon_bk ||
-                                        imp->imp_obd->obd_no_recov)) {
+                if (atomic_read(&imp->imp_inval_count) != 0) {
+                        DEBUG_REQ(D_ERROR, req, "invalidate in flight");
+                        *status = -EIO;
+                }
+
+        } else if ((imp->imp_invalid && (!imp->imp_recon_bk)) ||
+                                         imp->imp_obd->obd_no_recov) {
                 /* If the import has been invalidated (such as by an OST
-                 * failure), and if the import(MGC) tried all of its connection  
-                 * list (Bug 13464), the request must fail with -ESHUTDOWN.  
+                 * failure), and if the import(MGC) tried all of its connection
+                 * list (Bug 13464), the request must fail with -ESHUTDOWN.
                  * This indicates the requests should be discarded; an -EIO
-                 * may result in a resend of the request. */              
+                 * may result in a resend of the request. */
                 if (!imp->imp_deactive)
-                          DEBUG_REQ(D_ERROR, req, "IMP_INVALID");       
+                          DEBUG_REQ(D_ERROR, req, "IMP_INVALID");
                 *status = -ESHUTDOWN; /* bz 12940 */
         } else if (req->rq_import_generation != imp->imp_generation) {
                 DEBUG_REQ(D_ERROR, req, "req wrong generation:");
                 *status = -EIO;
         } else if (req->rq_send_state != imp->imp_state) {
-                if (imp->imp_obd->obd_no_recov)
-                        *status = -ESHUTDOWN;
-                else if (imp->imp_dlm_fake || req->rq_no_delay) 
+                /* invalidate in progress - any requests should be drop */
+                if (atomic_read(&imp->imp_inval_count) != 0) {
+                        DEBUG_REQ(D_ERROR, req, "invalidate in flight");
+                        *status = -EIO;
+                } else if (imp->imp_dlm_fake || req->rq_no_delay) {
                         *status = -EWOULDBLOCK;
-                else
+                } else {
                         delay = 1;
+                }
         }
 
         RETURN(delay);
@@ -865,7 +873,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
         ENTRY;
 
         LASSERT(req->rq_phase == RQ_PHASE_NEW);
-        if (req->rq_sent && (req->rq_sent > CURRENT_SECONDS))
+        if (req->rq_sent && (req->rq_sent > cfs_time_current_sec()))
                 RETURN (0);
         
         req->rq_phase = RQ_PHASE_RPC;
@@ -913,7 +921,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
                         RETURN(1);
                 } else {
                         /* here begins timeout counting */
-                        req->rq_sent = CURRENT_SECONDS;
+                        req->rq_sent = cfs_time_current_sec();
                         req->rq_wait_ctx = 1;
                         RETURN(0);
                 }
@@ -1073,7 +1081,7 @@ check_ctx:
                                         }
                                         if (!req->rq_wait_ctx) {
                                                 /* begins timeout counting */
-                                                req->rq_sent = CURRENT_SECONDS;
+                                                req->rq_sent = cfs_time_current_sec();
                                                 req->rq_wait_ctx = 1;
                                         }
                                         continue;
@@ -1168,9 +1176,8 @@ check_ctx:
                        libcfs_nid2str(imp->imp_connection->c_peer.nid),
                        lustre_msg_get_opc(req->rq_reqmsg));
 
-                set->set_remaining--;
-
                 atomic_dec(&imp->imp_inflight);
+                set->set_remaining--;
                 cfs_waitq_signal(&imp->imp_recovery_waitq);
         }
 
@@ -1184,9 +1191,9 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req)
         int rc = 0;
         ENTRY;
 
-        DEBUG_REQ(D_ERROR|D_NETERROR, req, "%s (sent at %lu, %lus ago)",
+        DEBUG_REQ(D_ERROR|D_NETERROR, req, "%s (sent at %lu, "CFS_DURATION_T"s ago)",
                   req->rq_net_err ? "network error" : "timeout",
-                  (long)req->rq_sent, CURRENT_SECONDS - req->rq_sent);
+                  (long)req->rq_sent, cfs_time_current_sec() - req->rq_sent);
 
         if (imp != NULL && obd_debug_peer_on_timeout)
                 LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer);
@@ -1240,7 +1247,7 @@ int ptlrpc_expired_set(void *data)
 {
         struct ptlrpc_request_set *set = data;
         struct list_head          *tmp;
-        time_t                     now = CURRENT_SECONDS;
+        time_t                     now = cfs_time_current_sec();
         ENTRY;
 
         LASSERT(set != NULL);
@@ -1300,7 +1307,7 @@ void ptlrpc_interrupted_set(void *data)
 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set)
 {
         struct list_head      *tmp;
-        time_t                 now = CURRENT_SECONDS;
+        time_t                 now = cfs_time_current_sec();
         time_t                 deadline;
         int                    timeout = 0;
         struct ptlrpc_request *req;
@@ -1758,8 +1765,8 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
         req->rq_phase = RQ_PHASE_RPC;
 
         spin_lock(&imp->imp_lock);
-restart:
         req->rq_import_generation = imp->imp_generation;
+restart:
         if (ptlrpc_import_delay_req(imp, req, &rc)) {
                 list_del(&req->rq_list);