Whamcloud - gitweb
LU-10805 ldlm: convert ACCESS_ONCE() to READ_ONCE()
[fs/lustre-release.git] / lustre / ldlm / ldlm_lib.c
index 7b40b98..27deb36 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2010, 2016, Intel Corporation.
+ * Copyright (c) 2010, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -39,6 +39,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <linux/jiffies.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <obd.h>
@@ -787,7 +788,8 @@ static int target_handle_reconnect(struct lustre_handle *conn,
        }
 
        now = ktime_get_seconds();
-       deadline = cfs_duration_sec(target->obd_recovery_timer.expires);
+       deadline = jiffies_to_msecs(target->obd_recovery_timer.expires) /
+                  MSEC_PER_SEC;
        if (now < deadline) {
                struct target_distribute_txn_data *tdtd;
                int size = 0;
@@ -1079,7 +1081,8 @@ int target_handle_connect(struct ptlrpc_request *req)
                 *
                 * Via check OBD_CONNECT_FID, we can distinguish whether
                 * the OBD_CONNECT_MDS_MDS/OBD_CONNECT_MNE_SWAB is from
-                * MGC or MDT. */
+                * MGC or MDT, since MGC does not use OBD_CONNECT_FID.
+                */
                if (!lw_client &&
                    (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS) &&
                    (data->ocd_connect_flags & OBD_CONNECT_FID) &&
@@ -1253,8 +1256,8 @@ no_export:
                        i = atomic_read(&target->obd_lock_replay_clients);
                        k = target->obd_max_recoverable_clients;
                        s = target->obd_stale_clients;
-                       t = target->obd_recovery_timer.expires;
-                       t = cfs_duration_sec(target->obd_recovery_timer.expires);
+                       t = jiffies_to_msecs(target->obd_recovery_timer.expires);
+                       t /= MSEC_PER_SEC;
                        t -= ktime_get_seconds();
                        LCONSOLE_WARN("%s: Denying connection for new client %s"
                                      "(at %s), waiting for %d known clients "
@@ -2693,6 +2696,17 @@ int target_queue_recovery_request(struct ptlrpc_request *req,
         target_process_req_flags(obd, req);
 
         if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_LOCK_REPLAY_DONE) {
+               if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_TGT_RECOVERY_REQ_RACE))) {
+                       if (cfs_fail_val == 1) {
+                               cfs_race_state = 1;
+                               cfs_fail_val = 0;
+                               wake_up(&cfs_race_waitq);
+
+                               set_current_state(TASK_INTERRUPTIBLE);
+                               schedule_timeout(cfs_time_seconds(1));
+                       }
+               }
+
                 /* client declares he's ready to complete recovery
                  * so, we put the request on th final queue */
                target_request_copy_get(req);
@@ -3206,7 +3220,7 @@ int target_bulk_io(struct obd_export *exp, struct ptlrpc_bulk_desc *desc,
                                  lwi);
                LASSERT(rc == 0 || rc == -ETIMEDOUT);
                /* Wait again if we changed rq_deadline. */
-               rq_deadline = ACCESS_ONCE(req->rq_deadline);
+               rq_deadline = READ_ONCE(req->rq_deadline);
                deadline = start + bulk_timeout;
                if (deadline > rq_deadline)
                        deadline = rq_deadline;