X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fldlm%2Fldlm_lib.c;h=9b5c4254d416ff5b604221bd92ae497ebe92f5b0;hp=5e8a03f4654621ad3898fb1ec1a12dd38e0aab83;hb=3f65f631c74ddf648ae8522f887da9e4edbf4c7d;hpb=3cbe63e72c83ba50c3553d28e2fe6bc9d18c347a diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 5e8a03f..9b5c425 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -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 #include #include #include @@ -390,12 +391,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; @@ -404,7 +408,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); @@ -412,7 +416,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. */ @@ -787,7 +791,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 +1084,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) && @@ -1155,6 +1161,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; @@ -1196,18 +1203,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); @@ -1243,7 +1251,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 */ @@ -1253,16 +1263,24 @@ 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 -= ktime_get_seconds(); + t = jiffies_to_msecs(target->obd_recovery_timer.expires); + t /= MSEC_PER_SEC; + 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: @@ -1966,7 +1984,18 @@ static int target_recovery_overseer(struct lu_target *lut, { struct obd_device *obd = lut->lut_obd; struct target_distribute_txn_data *tdtd; + time64_t last = 0; + time64_t now; repeat: + if (obd->obd_recovering && obd->obd_recovery_start == 0) { + now = ktime_get_seconds(); + if (now - last > 600) { + LCONSOLE_INFO("%s: in recovery but waiting for " + "the first client to connect\n", + obd->obd_name); + last = now; + } + } if (obd->obd_recovery_start != 0 && ktime_get_real_seconds() >= (obd->obd_recovery_start + obd->obd_recovery_time_hard)) { __u64 next_update_transno = 0; @@ -2591,9 +2620,9 @@ void target_recovery_fini(struct obd_device *obd) } EXPORT_SYMBOL(target_recovery_fini); -static void target_recovery_expired(unsigned long castmeharder) +static void target_recovery_expired(cfs_timer_cb_arg_t data) { - struct obd_device *obd = (struct obd_device *)castmeharder; + struct obd_device *obd = cfs_from_timer(obd, data, obd_recovery_timer); CDEBUG(D_HA, "%s: recovery timed out; %d clients are still in recovery" " after %llus (%d clients connected)\n", obd->obd_name, atomic_read(&obd->obd_lock_replay_clients), @@ -2625,8 +2654,8 @@ void target_recovery_init(struct lu_target *lut, svc_handler_t handler) obd->obd_recovery_start = 0; obd->obd_recovery_end = 0; - setup_timer(&obd->obd_recovery_timer, target_recovery_expired, - (unsigned long)obd); + cfs_timer_setup(&obd->obd_recovery_timer, target_recovery_expired, + (unsigned long)obd, 0); target_start_recovery_thread(lut, handler); } EXPORT_SYMBOL(target_recovery_init); @@ -2682,6 +2711,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); @@ -3195,7 +3235,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;