Whamcloud - gitweb
Revert "LU-11771 ldlm: use hrtimer for recovery to fix timeout messages"
[fs/lustre-release.git] / lustre / ldlm / ldlm_lib.c
index 278e5d5..5a587c7 100644 (file)
@@ -39,6 +39,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <cl_object.h>
 #include <linux/jiffies.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
@@ -359,6 +360,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
                     sizeof(server_uuid)));
 
        cli->cl_dirty_pages = 0;
+       cli->cl_dirty_max_pages = 0;
        cli->cl_avail_grant = 0;
        /* FIXME: Should limit this for the sum of all cl_dirty_max_pages. */
        /* cl_dirty_max_pages may be changed at connect time in
@@ -391,12 +393,15 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
        spin_lock_init(&cli->cl_lru_list_lock);
        atomic_long_set(&cli->cl_unstable_count, 0);
        INIT_LIST_HEAD(&cli->cl_shrink_list);
+       INIT_LIST_HEAD(&cli->cl_grant_chain);
 
        INIT_LIST_HEAD(&cli->cl_flight_waiters);
        cli->cl_rpcs_in_flight = 0;
 
        init_waitqueue_head(&cli->cl_destroy_waitq);
        atomic_set(&cli->cl_destroy_in_flight, 0);
+
+       cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
 #ifdef ENABLE_CHECKSUM
        /* Turn on checksumming by default. */
        cli->cl_checksum = 1;
@@ -405,7 +410,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
         * Set cl_chksum* to CRC32 for now to avoid returning screwed info
         * through procfs.
         */
-       cli->cl_cksum_type = cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
+       cli->cl_cksum_type = cli->cl_supp_cksum_types;
 #endif
        atomic_set(&cli->cl_resends, OSC_DEFAULT_RESENDS);
 
@@ -413,7 +418,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg)
         * from OFD after connecting. */
        cli->cl_max_pages_per_rpc = PTLRPC_MAX_BRW_PAGES;
 
-       cli->cl_short_io_bytes = OBD_MAX_SHORT_IO_BYTES;
+       cli->cl_max_short_io_bytes = OBD_MAX_SHORT_IO_BYTES;
 
        /* set cl_chunkbits default value to PAGE_SHIFT,
         * it will be updated at OSC connection time. */
@@ -621,6 +626,19 @@ out_ldlm:
 out_sem:
        up_write(&cli->cl_sem);
 
+       if (!rc && localdata) {
+               LASSERT(cli->cl_cache == NULL); /* only once */
+               cli->cl_cache = (struct cl_client_cache *)localdata;
+               cl_cache_incref(cli->cl_cache);
+               cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
+
+               /* add this osc into entity list */
+               LASSERT(list_empty(&cli->cl_lru_osc));
+               spin_lock(&cli->cl_cache->ccc_lru_lock);
+               list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru);
+               spin_unlock(&cli->cl_cache->ccc_lru_lock);
+       }
+
        return rc;
 }
 EXPORT_SYMBOL(client_connect_import);
@@ -1158,6 +1176,7 @@ int target_handle_connect(struct ptlrpc_request *req)
                         * cause namespace inconsistency */
                        spin_lock(&export->exp_lock);
                        export->exp_connecting = 1;
+                       export->exp_conn_cnt = 0;
                        spin_unlock(&export->exp_lock);
                        conn.cookie = export->exp_handle.h_cookie;
                        rc = EALREADY;
@@ -1199,18 +1218,19 @@ no_export:
                               target->obd_name, cluuid.uuid,
                               libcfs_nid2str(req->rq_peer.nid),
                              atomic_read(&export->exp_refcount));
-                GOTO(out, rc = -EBUSY);
-        } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1) {
-                if (!strstr(cluuid.uuid, "mdt"))
-                        LCONSOLE_WARN("%s: Rejecting reconnect from the "
-                                      "known client %s (at %s) because it "
-                                      "is indicating it is a new client",
-                                      target->obd_name, cluuid.uuid,
-                                      libcfs_nid2str(req->rq_peer.nid));
-                GOTO(out, rc = -EALREADY);
-        } else {
-                OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_RECONNECT, 2 * obd_timeout);
-        }
+                       GOTO(out, rc = -EBUSY);
+       } else if (lustre_msg_get_conn_cnt(req->rq_reqmsg) == 1 &&
+                  rc != EALREADY) {
+               if (!strstr(cluuid.uuid, "mdt"))
+                       LCONSOLE_WARN("%s: Rejecting reconnect from the "
+                                     "known client %s (at %s) because it "
+                                     "is indicating it is a new client",
+                                     target->obd_name, cluuid.uuid,
+                                     libcfs_nid2str(req->rq_peer.nid));
+               GOTO(out, rc = -EALREADY);
+       } else {
+               OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_RECONNECT, 2 * obd_timeout);
+       }
 
         if (rc < 0) {
                 GOTO(out, rc);
@@ -1246,7 +1266,9 @@ no_export:
                /* allow "new" MDT to be connected during recovery, since we
                 * need retrieve recovery update records from it */
                if (target->obd_recovering && !lw_client && !mds_mds_conn) {
+                       time64_t now;
                        time64_t t;
+                       char *msg;
                        int c; /* connected */
                        int i; /* in progress */
                        int k; /* known */
@@ -1258,14 +1280,22 @@ no_export:
                        s = target->obd_stale_clients;
                        t = jiffies_to_msecs(target->obd_recovery_timer.expires);
                        t /= MSEC_PER_SEC;
-                       t -= ktime_get_seconds();
+                       now = ktime_get_seconds();
+                       if (now > t) {
+                               t = now - t;
+                               msg = "already passed deadline";
+                       } else {
+                               t -= now;
+                               msg = "to recover in";
+                       }
+
                        LCONSOLE_WARN("%s: Denying connection for new client %s"
                                      "(at %s), waiting for %d known clients "
                                      "(%d recovered, %d in progress, and %d "
-                                     "evicted) to recover in %lld:%.02lld\n",
+                                     "evicted) %s %lld:%.02lld\n",
                                      target->obd_name, cluuid.uuid,
                                      libcfs_nid2str(req->rq_peer.nid), k,
-                                     c - i, i, s, t / 60, t % 60);
+                                     c - i, i, s, msg, t / 60, t % 60);
                        rc = -EBUSY;
                } else {
 dont_check_exports:
@@ -2457,11 +2487,10 @@ static int target_recovery_thread(void *arg)
                 RETURN(rc);
         }
 
-        thread->t_env = env;
-        thread->t_id = -1; /* force filter_iobuf_get/put to use local buffers */
-        env->le_ctx.lc_thread = thread;
+       thread->t_env = env;
+       thread->t_id = -1; /* force filter_iobuf_get/put to use local buffers */
+       env->le_ctx.lc_thread = thread;
        tgt_io_thread_init(thread); /* init thread_big_cache for IO requests */
-       thread->t_watchdog = NULL;
 
        CDEBUG(D_HA, "%s: started recovery thread pid %d\n", obd->obd_name,
               current_pid());
@@ -2857,12 +2886,6 @@ added:
        RETURN(0);
 }
 
-int target_handle_ping(struct ptlrpc_request *req)
-{
-        obd_ping(req->rq_svc_thread->t_env, req->rq_export);
-        return req_capsule_server_pack(&req->rq_pill);
-}
-
 void target_committed_to_req(struct ptlrpc_request *req)
 {
         struct obd_export *exp = req->rq_export;