Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-10467 ptlrpc: convert final users of LWI_TIMEOUT_INTERVAL
[fs/lustre-release.git]
/
lustre
/
ptlrpc
/
import.c
diff --git
a/lustre/ptlrpc/import.c
b/lustre/ptlrpc/import.c
index
b7ce038
..
4b4bcab
100644
(file)
--- a/
lustre/ptlrpc/import.c
+++ b/
lustre/ptlrpc/import.c
@@
-301,7
+301,6
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
{
struct list_head *tmp, *n;
struct ptlrpc_request *req;
- struct l_wait_info lwi;
time64_t timeout;
int rc;
@@
-317,15
+316,16
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
CFS_FAIL_TIMEOUT(OBD_FAIL_MGS_CONNECT_NET, 3 * cfs_fail_val / 2);
LASSERT(imp->imp_invalid);
- /* Wait forever until inflight == 0. We really can't do it another
- * way because in some cases we need to wait for very long reply
- * unlink. We can't do anything before that because there is really
- * no guarantee that some rdma transfer is not in progress right now. */
- do {
+ /* Wait forever until inflight == 0. We really can't do it another
+ * way because in some cases we need to wait for very long reply
+ * unlink. We can't do anything before that because there is really
+ * no guarantee that some rdma transfer is not in progress right now.
+ */
+ do {
long timeout_jiffies;
-
/* Calculate max timeout for waiting on rpcs to error
-
* out. Use obd_timeout if calculated value is smaller
+ /* Calculate max timeout for waiting on rpcs to error
+ * out. Use obd_timeout if calculated value is smaller
* than it.
*/
if (!OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK)) {
@@
-347,18
+347,16
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
* have been locally cancelled by ptlrpc_abort_inflight.
*/
timeout_jiffies = max_t(long, cfs_time_seconds(timeout), 1);
- lwi = LWI_TIMEOUT_INTERVAL(timeout_jiffies,
- (timeout > 1) ? cfs_time_seconds(1) :
- cfs_time_seconds(1) / 2,
- NULL, NULL);
- rc = l_wait_event(imp->imp_recovery_waitq,
- (atomic_read(&imp->imp_inflight) == 0),
- &lwi);
- if (rc) {
+ rc = wait_event_idle_timeout(
+ imp->imp_recovery_waitq,
+ (atomic_read(&imp->imp_inflight) == 0),
+ timeout_jiffies);
+
+ if (rc == 0) {
const char *cli_tgt = obd2cli_tgt(imp->imp_obd);
- CERROR("%s:
rc = %d
waiting for callback (%d != 0)\n",
- cli_tgt,
rc,
atomic_read(&imp->imp_inflight));
+ CERROR("%s:
timeout
waiting for callback (%d != 0)\n",
+ cli_tgt, atomic_read(&imp->imp_inflight));
spin_lock(&imp->imp_lock);
if (atomic_read(&imp->imp_inflight) == 0) {
@@
-376,7
+374,7
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
/* Let's save one loop as soon as inflight have
* dropped to zero. No new inflights possible at
* this point. */
- rc =
0
;
+ rc =
1
;
} else {
list_for_each_safe(tmp, n,
&imp->imp_sending_list) {
@@
-396,13
+394,13
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
}
CERROR("%s: Unregistering RPCs found (%d). "
- "Network is sluggish? Waiting them "
+ "Network is sluggish? Waiting
for
them "
"to error out.\n", cli_tgt,
atomic_read(&imp->imp_unregistering));
}
spin_unlock(&imp->imp_lock);
}
- } while (rc
!
= 0);
+ } while (rc
=
= 0);
/*
* Let's additionally check that no new rpcs added to import in
@@
-413,7
+411,7
@@
void ptlrpc_invalidate_import(struct obd_import *imp)
sptlrpc_import_flush_all_ctx(imp);
atomic_dec(&imp->imp_inval_count);
- wake_up
_all
(&imp->imp_recovery_waitq);
+ wake_up(&imp->imp_recovery_waitq);
}
EXPORT_SYMBOL(ptlrpc_invalidate_import);
@@
-470,7
+468,6
@@
int ptlrpc_reconnect_import(struct obd_import *imp)
{
#ifdef ENABLE_PINGER
long timeout_jiffies = cfs_time_seconds(obd_timeout);
- struct l_wait_info lwi;
int rc;
ptlrpc_pinger_force(imp);
@@
-478,9
+475,13
@@
int ptlrpc_reconnect_import(struct obd_import *imp)
CDEBUG(D_HA, "%s: recovery started, waiting %u seconds\n",
obd2cli_tgt(imp->imp_obd), obd_timeout);
- lwi = LWI_TIMEOUT(timeout_jiffies, NULL, NULL);
- rc = l_wait_event(imp->imp_recovery_waitq,
- !ptlrpc_import_in_recovery(imp), &lwi);
+ rc = wait_event_idle_timeout(imp->imp_recovery_waitq,
+ !ptlrpc_import_in_recovery(imp),
+ timeout_jiffies);
+ if (rc == 0)
+ rc = -ETIMEDOUT;
+ else
+ rc = 0;
CDEBUG(D_HA, "%s: recovery finished s:%s\n", obd2cli_tgt(imp->imp_obd),
ptlrpc_import_state_name(imp->imp_state));
return rc;
@@
-492,12
+493,11
@@
int ptlrpc_reconnect_import(struct obd_import *imp)
ptlrpc_disconnect_import(imp, 1);
/* Wait for all invalidate calls to finish */
if (atomic_read(&imp->imp_inval_count) > 0) {
- struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
int rc;
- rc = l_wait_event
(imp->imp_recovery_waitq,
-
(atomic_read(&imp->imp_inval_count) == 0)
,
-
&lwi
);
+ rc = l_wait_event
_abortable(
+
imp->imp_recovery_waitq
,
+
(atomic_read(&imp->imp_inval_count) == 0)
);
if (rc)
CERROR("Interrupted, inval=%d\n",
atomic_read(&imp->imp_inval_count));
@@
-999,14
+999,14
@@
static void ptlrpc_prepare_replay(struct obd_import *imp)
* full state for normal operations of disconnect it due to an error.
*/
static int ptlrpc_connect_interpret(const struct lu_env *env,
-
struct ptlrpc_request *request,
-
void *data, int rc)
+ struct ptlrpc_request *request,
+ void *data, int rc)
{
-
struct ptlrpc_connect_async_args *aa = data;
-
struct obd_import *imp = request->rq_import;
-
struct lustre_handle old_hdl;
-
__u64 old_connect_flags;
-
int msg_flags;
+ struct ptlrpc_connect_async_args *aa = data;
+ struct obd_import *imp = request->rq_import;
+ struct lustre_handle old_hdl;
+ __u64 old_connect_flags;
+ int msg_flags;
struct obd_connect_data *ocd;
struct obd_export *exp = NULL;
int ret;
@@
-1069,10
+1069,10
@@
static int ptlrpc_connect_interpret(const struct lu_env *env,
spin_lock(&imp->imp_lock);
-
/* All imports are pingable */
-
imp->imp_pingable = 1;
-
imp->imp_force_reconnect = 0;
-
imp->imp_force_verify = 0;
+ /* All imports are pingable */
+ imp->imp_pingable = 1;
+ imp->imp_force_reconnect = 0;
+ imp->imp_force_verify = 0;
imp->imp_connect_data = *ocd;
@@
-1143,7
+1143,8
@@
static int ptlrpc_connect_interpret(const struct lu_env *env,
* because may reflect other routing, etc. */
at_reinit(&imp->imp_at.iat_net_latency, 0, 0);
ptlrpc_at_adj_net_latency(request,
- lustre_msg_get_service_time(request->rq_repmsg));
+ lustre_msg_get_service_time(
+ request->rq_repmsg));
/* Import flags should be updated before waking import at FULL state */
rc = ptlrpc_connect_set_flags(imp, ocd, old_connect_flags, exp,
@@
-1166,112
+1167,114
@@
static int ptlrpc_connect_interpret(const struct lu_env *env,
imp->imp_replayable = 0;
}
- /* if applies, adjust the imp->imp_msg_magic here
- * according to reply flags */
+ /* if applies, adjust the imp->imp_msg_magic here
+ * according to reply flags
+ */
-
imp->imp_remote_handle =
-
*lustre_msg_get_handle(request->rq_repmsg);
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
- /* Initial connects are allowed for clients with non-random
- * uuids when servers are in recovery. Simply signal the
- * servers replay is complete and wait in REPLAY_WAIT. */
- if (msg_flags & MSG_CONNECT_RECOVERING) {
- CDEBUG(D_HA, "connect to %s during recovery\n",
- obd2cli_tgt(imp->imp_obd));
+ /* Initial connects are allowed for clients with non-random
+ * uuids when servers are in recovery. Simply signal the
+ * servers replay is complete and wait in REPLAY_WAIT.
+ */
+ if (msg_flags & MSG_CONNECT_RECOVERING) {
+ CDEBUG(D_HA, "connect to %s during recovery\n",
+ obd2cli_tgt(imp->imp_obd));
import_set_state_nolock(imp, LUSTRE_IMP_REPLAY_LOCKS);
spin_unlock(&imp->imp_lock);
-
} else {
+ } else {
spin_unlock(&imp->imp_lock);
ptlrpc_activate_import(imp, true);
-
}
+ }
-
GOTO(finish, rc = 0);
-
}
+ GOTO(finish, rc = 0);
+ }
-
/* Determine what recovery state to move the import to. */
-
if (MSG_CONNECT_RECONNECT & msg_flags) {
-
memset(&old_hdl, 0, sizeof(old_hdl));
-
if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
-
sizeof
(old_hdl))) {
-
LCONSOLE_WARN("Reconnect to %s (at @%s) failed due "
+ /* Determine what recovery state to move the import to. */
+ if (MSG_CONNECT_RECONNECT & msg_flags) {
+ memset(&old_hdl, 0, sizeof(old_hdl));
+ if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
+
sizeof
(old_hdl))) {
+ LCONSOLE_WARN("Reconnect to %s (at @%s) failed due "
"bad handle %#llx\n",
-
obd2cli_tgt(imp->imp_obd),
-
imp->imp_connection->c_remote_uuid.uuid,
-
imp->imp_dlm_handle.cookie);
-
GOTO(out, rc = -ENOTCONN);
-
}
+ obd2cli_tgt(imp->imp_obd),
+ imp->imp_connection->c_remote_uuid.uuid,
+ imp->imp_dlm_handle.cookie);
+ GOTO(out, rc = -ENOTCONN);
+ }
- if (memcmp(&imp->imp_remote_handle,
- lustre_msg_get_handle(request->rq_repmsg),
- sizeof(imp->imp_remote_handle))) {
- int level = msg_flags & MSG_CONNECT_RECOVERING ?
- D_HA : D_WARNING;
-
- /* Bug 16611/14775: if server handle have changed,
- * that means some sort of disconnection happened.
- * If the server is not in recovery, that also means it
- * already erased all of our state because of previous
- * eviction. If it is in recovery - we are safe to
- * participate since we can reestablish all of our state
- * with server again */
- if ((MSG_CONNECT_RECOVERING & msg_flags)) {
- CDEBUG(level,"%s@%s changed server handle from "
+ if (memcmp(&imp->imp_remote_handle,
+ lustre_msg_get_handle(request->rq_repmsg),
+ sizeof(imp->imp_remote_handle))) {
+ int level = msg_flags & MSG_CONNECT_RECOVERING ?
+ D_HA : D_WARNING;
+
+ /* Bug 16611/14775: if server handle have changed,
+ * that means some sort of disconnection happened.
+ * If the server is not in recovery, that also means it
+ * already erased all of our state because of previous
+ * eviction. If it is in recovery - we are safe to
+ * participate since we can reestablish all of our state
+ * with server again
+ */
+ if ((MSG_CONNECT_RECOVERING & msg_flags)) {
+ CDEBUG(level,
+ "%s@%s changed server handle from "
"%#llx to %#llx"
-
" but is still in recovery\n",
-
obd2cli_tgt(imp->imp_obd),
-
imp->imp_connection->c_remote_uuid.uuid,
-
imp->imp_remote_handle.cookie,
-
lustre_msg_get_handle(
- request->rq_repmsg)->cookie);
-
} else {
-
LCONSOLE_WARN("Evicted from %s (at %s) "
-
"after server handle changed from "
+ " but is still in recovery\n",
+ obd2cli_tgt(imp->imp_obd),
+ imp->imp_connection->c_remote_uuid.uuid,
+ imp->imp_remote_handle.cookie,
+ lustre_msg_get_handle(
+
request->rq_repmsg)->cookie);
+ } else {
+ LCONSOLE_WARN("Evicted from %s (at %s) "
+ "after server handle changed from "
"%#llx to %#llx\n",
- obd2cli_tgt(imp->imp_obd),
- imp->imp_connection-> \
- c_remote_uuid.uuid,
- imp->imp_remote_handle.cookie,
- lustre_msg_get_handle(
- request->rq_repmsg)->cookie);
- }
-
+ obd2cli_tgt(imp->imp_obd),
+ imp->imp_connection->
+ c_remote_uuid.uuid,
+ imp->imp_remote_handle.cookie,
+ lustre_msg_get_handle(
+ request->rq_repmsg)->cookie);
+ }
-
imp->imp_remote_handle =
-
*lustre_msg_get_handle(request->rq_repmsg);
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
-
if (!(MSG_CONNECT_RECOVERING & msg_flags)) {
+ if (!(MSG_CONNECT_RECOVERING & msg_flags)) {
import_set_state(imp, LUSTRE_IMP_EVICTED);
- GOTO(finish, rc = 0);
- }
-
- } else {
- CDEBUG(D_HA, "reconnected to %s@%s after partition\n",
- obd2cli_tgt(imp->imp_obd),
- imp->imp_connection->c_remote_uuid.uuid);
- }
+ GOTO(finish, rc = 0);
+ }
+ } else {
+ CDEBUG(D_HA, "reconnected to %s@%s after partition\n",
+ obd2cli_tgt(imp->imp_obd),
+ imp->imp_connection->c_remote_uuid.uuid);
+ }
-
if (imp->imp_invalid) {
-
CDEBUG(D_HA, "%s: reconnected but import is invalid; "
-
"marking evicted\n", imp->imp_obd->obd_name);
+ if (imp->imp_invalid) {
+ CDEBUG(D_HA, "%s: reconnected but import is invalid; "
+ "marking evicted\n", imp->imp_obd->obd_name);
import_set_state(imp, LUSTRE_IMP_EVICTED);
-
} else if (MSG_CONNECT_RECOVERING & msg_flags) {
-
CDEBUG(D_HA, "%s: reconnected to %s during replay\n",
-
imp->imp_obd->obd_name,
-
obd2cli_tgt(imp->imp_obd));
+ } else if (MSG_CONNECT_RECOVERING & msg_flags) {
+ CDEBUG(D_HA, "%s: reconnected to %s during replay\n",
+ imp->imp_obd->obd_name,
+ obd2cli_tgt(imp->imp_obd));
spin_lock(&imp->imp_lock);
imp->imp_resend_replay = 1;
spin_unlock(&imp->imp_lock);
import_set_state(imp, imp->imp_replay_state);
-
} else {
+ } else {
import_set_state(imp, LUSTRE_IMP_RECOVER);
-
}
-
} else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
-
LASSERT(imp->imp_replayable);
-
imp->imp_remote_handle =
-
*lustre_msg_get_handle(request->rq_repmsg);
-
imp->imp_last_replay_transno = 0;
+ }
+ } else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
+ LASSERT(imp->imp_replayable);
+ imp->imp_remote_handle =
+ *lustre_msg_get_handle(request->rq_repmsg);
+ imp->imp_last_replay_transno = 0;
imp->imp_replay_cursor = &imp->imp_committed_list;
import_set_state(imp, LUSTRE_IMP_REPLAY);
} else if ((ocd->ocd_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0 &&
@@
-1304,7
+1307,7
@@
static int ptlrpc_connect_interpret(const struct lu_env *env,
/* The below message is checked in recovery-small.sh test_54 */
CERROR("%s: went back in time (transno %lld was previously committed, server now claims %lld)!\n",
-
obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed,
+ obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed,
lustre_msg_get_last_committed(request->rq_repmsg));
if (!printed) {
CERROR("For further information, see http://doc.lustre.org/lustre_manual.xhtml#went_back_in_time\n");
@@
-1366,17
+1369,17
@@
out:
if (ocd &&
(ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
(ocd->ocd_version != LUSTRE_VERSION_CODE)) {
-
LCONSOLE_ERROR_MSG(0x16a, "Server %s version "
- "(%d.%d.%d.%d)"
- " refused connection from this client "
- "with an incompatible version (%s). "
- "Client must be recompiled\n",
- obd2cli_tgt(imp->imp_obd),
- OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
- OBD_OCD_VERSION_MINOR(ocd->ocd_version),
- OBD_OCD_VERSION_PATCH(ocd->ocd_version),
- OBD_OCD_VERSION_FIX(ocd->ocd_version),
- LUSTRE_VERSION_STRING);
+ LCONSOLE_ERROR_MSG(0x16a, "Server %s version "
+
"(%d.%d.%d.%d)"
+
" refused connection from this client "
+
"with an incompatible version (%s). "
+
"Client must be recompiled\n",
+
obd2cli_tgt(imp->imp_obd),
+
OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
+
OBD_OCD_VERSION_MINOR(ocd->ocd_version),
+
OBD_OCD_VERSION_PATCH(ocd->ocd_version),
+
OBD_OCD_VERSION_FIX(ocd->ocd_version),
+
LUSTRE_VERSION_STRING);
ptlrpc_deactivate_import_nolock(imp);
import_set_state_nolock(imp, LUSTRE_IMP_CLOSED);
inact = true;
@@
-1399,7
+1402,7
@@
out:
spin_unlock(&imp->imp_lock);
}
- wake_up
_all
(&imp->imp_recovery_waitq);
+ wake_up(&imp->imp_recovery_waitq);
RETURN(rc);
}
@@
-1603,14
+1606,19
@@
int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
GOTO(out, rc);
ptlrpc_activate_import(imp, true);
- LCONSOLE_INFO("%s: Connection restored to %s (at %s)\n",
- imp->imp_obd->obd_name,
- obd_uuid2str(&conn->c_remote_uuid),
- obd_import_nid2str(imp));
+ CDEBUG_LIMIT(imp->imp_was_idle ?
+ imp->imp_idle_debug : D_CONSOLE,
+ "%s: Connection restored to %s (at %s)\n",
+ imp->imp_obd->obd_name,
+ obd_uuid2str(&conn->c_remote_uuid),
+ obd_import_nid2str(imp));
+ spin_lock(&imp->imp_lock);
+ imp->imp_was_idle = 0;
+ spin_unlock(&imp->imp_lock);
}
if (imp->imp_state == LUSTRE_IMP_FULL) {
- wake_up
_all
(&imp->imp_recovery_waitq);
+ wake_up(&imp->imp_recovery_waitq);
ptlrpc_wake_delayed(imp);
}
@@
-1646,7
+1654,7
@@
static struct ptlrpc_request *ptlrpc_disconnect_prep_req(struct obd_import *imp)
req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT,
LUSTRE_OBD_VERSION, rq_opc);
if (req == NULL)
- RETURN(
NULL
);
+ RETURN(
ERR_PTR(-ENOMEM)
);
/* We are disconnecting, do not retry a failed DISCONNECT rpc if
* it fails. We can get through the above with a down server
@@
-1681,7
+1689,6
@@
int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
spin_unlock(&imp->imp_lock);
if (ptlrpc_import_in_recovery(imp)) {
- struct l_wait_info lwi;
long timeout_jiffies;
time64_t timeout;
@@
-1697,15
+1704,16
@@
int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
req_portal = imp->imp_client->cli_request_portal;
idx = import_at_get_index(imp, req_portal);
timeout = at_get(&imp->imp_at.iat_service_estimate[idx]);
-
}
+ }
timeout_jiffies = cfs_time_seconds(timeout);
- lwi = LWI_TIMEOUT_INTR(max_t(long, timeout_jiffies, 1),
- back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL);
- rc = l_wait_event(imp->imp_recovery_waitq,
- !ptlrpc_import_in_recovery(imp), &lwi);
-
- }
+ if (wait_event_idle_timeout(imp->imp_recovery_waitq,
+ !ptlrpc_import_in_recovery(imp),
+ timeout_jiffies) == 0 &&
+ l_wait_event_abortable(imp->imp_recovery_waitq,
+ !ptlrpc_import_in_recovery(imp)) < 0)
+ rc = -EINTR;
+ }
spin_lock(&imp->imp_lock);
if (imp->imp_state != LUSTRE_IMP_FULL)
@@
-1744,7
+1752,8
@@
static void ptlrpc_reset_reqs_generation(struct obd_import *imp)
rq_list) {
spin_lock(&old->rq_lock);
if (old->rq_import_generation == imp->imp_generation - 1 &&
- !old->rq_no_resend)
+ ((imp->imp_initiated_at == imp->imp_generation) ||
+ !old->rq_no_resend))
old->rq_import_generation = imp->imp_generation;
spin_unlock(&old->rq_lock);
}
@@
-1817,6
+1826,12
@@
int ptlrpc_disconnect_and_idle_import(struct obd_import *imp)
CDEBUG_LIMIT(imp->imp_idle_debug, "%s: disconnect after %llus idle\n",
imp->imp_obd->obd_name,
ktime_get_real_seconds() - imp->imp_last_reply_time);
+
+ /* don't make noise at reconnection */
+ spin_lock(&imp->imp_lock);
+ imp->imp_was_idle = 1;
+ spin_unlock(&imp->imp_lock);
+
req->rq_interpret_reply = ptlrpc_disconnect_idle_interpret;
ptlrpcd_add_req(req);