Skip to content

Commit 0f34c83

Browse files
author
root
committed
add logs for resize
1 parent 2b2925a commit 0f34c83

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

lib/nvmf/subsystem.c

+25-3
Original file line numberDiff line numberDiff line change
@@ -1664,14 +1664,35 @@ nvmf_subsystem_update_ns(struct spdk_nvmf_subsystem *subsystem,
16641664
return 0;
16651665
}
16661666

1667+
struct subsystem_ns_change_ctx_v2 {
1668+
// struct spdk_nvmf_subsystem *subsystem;
1669+
uint32_t nsid;
1670+
struct spdk_nvmf_ctrlr *ctrlr;
1671+
// spdk_nvmf_subsystem_state_change_done cb_fn;
1672+
// uint32_t nsid;
1673+
};
1674+
1675+
1676+
static void
1677+
nvmf_subsystem_ns_changed_v2(void *cb_arg)
1678+
{
1679+
struct subsystem_ns_change_ctx_v2 *ctx = cb_arg;
1680+
nvmf_ctrlr_ns_changed(ctx->ctrlr, ctx->nsid);
1681+
free(ctx);
1682+
}
1683+
16671684
static void
16681685
nvmf_subsystem_ns_changed(struct spdk_nvmf_subsystem *subsystem, uint32_t nsid)
16691686
{
16701687
struct spdk_nvmf_ctrlr *ctrlr;
1671-
1688+
struct subsystem_ns_change_ctx_v2 *ctx;
1689+
ctx = calloc(1, sizeof(struct subsystem_ns_change_ctx_v2));
16721690
TAILQ_FOREACH(ctrlr, &subsystem->ctrlrs, link) {
16731691
if (nvmf_ctrlr_ns_is_visible(ctrlr, nsid)) {
1674-
nvmf_ctrlr_ns_changed(ctrlr, nsid);
1692+
ctx->nsid = nsid;
1693+
ctx->ctrlr = ctrlr;
1694+
spdk_thread_send_msg(ctrlr->thread, nvmf_subsystem_ns_changed_v2, ctx);
1695+
// nvmf_ctrlr_ns_changed(ctrlr, nsid);
16751696
}
16761697
}
16771698
}
@@ -1822,8 +1843,9 @@ static void
18221843
_nvmf_ns_resize(struct spdk_nvmf_subsystem *subsystem, void *cb_arg, int status)
18231844
{
18241845
struct subsystem_ns_change_ctx *ctx = cb_arg;
1825-
1846+
SPDK_NOTICELOG("starting to change the ns list.\n");
18261847
nvmf_subsystem_ns_changed(subsystem, ctx->nsid);
1848+
SPDK_NOTICELOG("ns list changed and resume the subsystem.\n");
18271849
if (spdk_nvmf_subsystem_resume(subsystem, NULL, NULL) != 0) {
18281850
SPDK_ERRLOG("Failed to resume NVME-oF subsystem with id: %u\n", subsystem->id);
18291851
}

lib/nvmf/tcp.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ struct spdk_nvmf_tcp_req {
240240
* h2c_offset is used when we receive the h2c_data PDU.
241241
*/
242242
uint32_t h2c_offset;
243+
uint64_t time;
244+
bool loged;
243245

244246
STAILQ_ENTRY(spdk_nvmf_tcp_req) link;
245247
TAILQ_ENTRY(spdk_nvmf_tcp_req) state_link;
@@ -2859,6 +2861,16 @@ nvmf_tcp_check_fused_ordering(struct spdk_nvmf_tcp_transport *ttransport,
28592861
}
28602862
}
28612863

2864+
static void check_time(struct spdk_nvmf_tcp_req *tcp_req) {
2865+
if (!tcp_req->loged && tcp_req->time) {
2866+
if (spdk_get_ticks() - tcp_req->time > spdk_get_ticks_hz() * 2){
2867+
SPDK_NOTICELOG("tcp_req ttag %d, tcp_req \n", tcp_req->ttag);
2868+
tcp_req->loged = false;
2869+
}
2870+
}
2871+
}
2872+
2873+
28622874
static bool
28632875
nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
28642876
struct spdk_nvmf_tcp_req *tcp_req)
@@ -2899,6 +2911,7 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
28992911
case TCP_REQUEST_STATE_NEW:
29002912
spdk_trace_record(TRACE_TCP_REQUEST_STATE_NEW, tqpair->qpair.trace_id, 0, (uintptr_t)tcp_req,
29012913
tqpair->qpair.queue_depth);
2914+
tcp_req->time = spdk_get_ticks();
29022915

29032916
/* copy the cmd from the receive pdu */
29042917
tcp_req->cmd = tqpair->pdu_in_progress->hdr.capsule_cmd.ccsqe;
@@ -2947,6 +2960,7 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
29472960
case TCP_REQUEST_STATE_NEED_BUFFER:
29482961
spdk_trace_record(TRACE_TCP_REQUEST_STATE_NEED_BUFFER, tqpair->qpair.trace_id, 0,
29492962
(uintptr_t)tcp_req);
2963+
check_time(tcp_req);
29502964

29512965
assert(tcp_req->req.xfer != SPDK_NVME_DATA_NONE);
29522966

@@ -3013,10 +3027,12 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
30133027
(uintptr_t)tcp_req);
30143028
/* Some external code must kick a request into TCP_REQUEST_STATE_ZCOPY_START_COMPLETED
30153029
* to escape this state. */
3030+
check_time(tcp_req);
30163031
break;
30173032
case TCP_REQUEST_STATE_ZCOPY_START_COMPLETED:
30183033
spdk_trace_record(TRACE_TCP_REQUEST_STATE_ZCOPY_START_COMPLETED, tqpair->qpair.trace_id, 0,
30193034
(uintptr_t)tcp_req);
3035+
check_time(tcp_req);
30203036
if (spdk_unlikely(spdk_nvme_cpl_is_error(&tcp_req->req.rsp->nvme_cpl))) {
30213037
SPDK_DEBUGLOG(nvmf_tcp, "Zero-copy start failed for tcp_req(%p) on tqpair=%p\n",
30223038
tcp_req, tqpair);
@@ -3033,6 +3049,7 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
30333049
case TCP_REQUEST_STATE_AWAITING_R2T_ACK:
30343050
spdk_trace_record(TRACE_TCP_REQUEST_STATE_AWAIT_R2T_ACK, tqpair->qpair.trace_id, 0,
30353051
(uintptr_t)tcp_req);
3052+
check_time(tcp_req);
30363053
/* The R2T completion or the h2c data incoming will kick it out of this state. */
30373054
break;
30383055
case TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER:
@@ -3041,10 +3058,12 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
30413058
0, (uintptr_t)tcp_req);
30423059
/* Some external code must kick a request into TCP_REQUEST_STATE_READY_TO_EXECUTE
30433060
* to escape this state. */
3061+
check_time(tcp_req);
30443062
break;
30453063
case TCP_REQUEST_STATE_READY_TO_EXECUTE:
30463064
spdk_trace_record(TRACE_TCP_REQUEST_STATE_READY_TO_EXECUTE, tqpair->qpair.trace_id, 0,
30473065
(uintptr_t)tcp_req);
3066+
check_time(tcp_req);
30483067

30493068
if (spdk_unlikely(tcp_req->req.dif_enabled)) {
30503069
assert(tcp_req->req.dif.elba_length >= tcp_req->req.length);
@@ -3112,25 +3131,29 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
31123131
spdk_trace_record(TRACE_TCP_REQUEST_STATE_EXECUTING, tqpair->qpair.trace_id, 0, (uintptr_t)tcp_req);
31133132
/* Some external code must kick a request into TCP_REQUEST_STATE_EXECUTED
31143133
* to escape this state. */
3134+
check_time(tcp_req);
31153135
break;
31163136
case TCP_REQUEST_STATE_AWAITING_ZCOPY_COMMIT:
31173137
spdk_trace_record(TRACE_TCP_REQUEST_STATE_AWAIT_ZCOPY_COMMIT, tqpair->qpair.trace_id, 0,
31183138
(uintptr_t)tcp_req);
31193139
/* Some external code must kick a request into TCP_REQUEST_STATE_EXECUTED
31203140
* to escape this state. */
3141+
check_time(tcp_req);
31213142
break;
31223143
case TCP_REQUEST_STATE_EXECUTED:
31233144
spdk_trace_record(TRACE_TCP_REQUEST_STATE_EXECUTED, tqpair->qpair.trace_id, 0, (uintptr_t)tcp_req);
31243145

31253146
if (spdk_unlikely(tcp_req->req.dif_enabled)) {
31263147
tcp_req->req.length = tcp_req->req.dif.orig_length;
31273148
}
3128-
3149+
check_time(tcp_req);
31293150
nvmf_tcp_req_set_state(tcp_req, TCP_REQUEST_STATE_READY_TO_COMPLETE);
31303151
break;
31313152
case TCP_REQUEST_STATE_READY_TO_COMPLETE:
31323153
spdk_trace_record(TRACE_TCP_REQUEST_STATE_READY_TO_COMPLETE, tqpair->qpair.trace_id, 0,
31333154
(uintptr_t)tcp_req);
3155+
check_time(tcp_req);
3156+
tcp_req->time = 0;
31343157
if (request_transfer_out(&tcp_req->req) != 0) {
31353158
assert(0); /* No good way to handle this currently */
31363159
}
@@ -3140,19 +3163,22 @@ nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
31403163
0, (uintptr_t)tcp_req);
31413164
/* Some external code must kick a request into TCP_REQUEST_STATE_COMPLETED
31423165
* to escape this state. */
3166+
check_time(tcp_req);
31433167
break;
31443168
case TCP_REQUEST_STATE_AWAITING_ZCOPY_RELEASE:
31453169
spdk_trace_record(TRACE_TCP_REQUEST_STATE_AWAIT_ZCOPY_RELEASE, tqpair->qpair.trace_id, 0,
31463170
(uintptr_t)tcp_req);
31473171
/* Some external code must kick a request into TCP_REQUEST_STATE_COMPLETED
31483172
* to escape this state. */
3173+
check_time(tcp_req);
31493174
break;
31503175
case TCP_REQUEST_STATE_COMPLETED:
31513176
spdk_trace_record(TRACE_TCP_REQUEST_STATE_COMPLETED, tqpair->qpair.trace_id, 0, (uintptr_t)tcp_req,
31523177
tqpair->qpair.queue_depth);
31533178
/* If there's an outstanding PDU sent to the host, the request is completed
31543179
* due to the qpair being disconnected. We must delay the completion until
31553180
* that write is done to avoid freeing the request twice. */
3181+
check_time(tcp_req);
31563182
if (spdk_unlikely(tcp_req->pdu_in_use)) {
31573183
SPDK_DEBUGLOG(nvmf_tcp, "Delaying completion due to outstanding "
31583184
"write on req=%p\n", tcp_req);

0 commit comments

Comments
 (0)