Skip to content

Commit 23333b6

Browse files
author
root
committed
add nvmf logs
1 parent 3d61188 commit 23333b6

File tree

3 files changed

+63
-13
lines changed

3 files changed

+63
-13
lines changed

include/spdk/nvmf_transport.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ int spdk_nvmf_request_get_buffers(struct spdk_nvmf_request *req,
517517
bool spdk_nvmf_request_get_dif_ctx(struct spdk_nvmf_request *req, struct spdk_dif_ctx *dif_ctx);
518518

519519
void spdk_nvmf_request_exec(struct spdk_nvmf_request *req);
520-
void spdk_nvmf_request_nqn(struct spdk_nvmf_request *req);
520+
char *spdk_nvmf_request_nqn(struct spdk_nvmf_request *req);
521521
void spdk_nvmf_request_exec_fabrics(struct spdk_nvmf_request *req);
522522
int spdk_nvmf_request_free(struct spdk_nvmf_request *req);
523523
int spdk_nvmf_request_complete(struct spdk_nvmf_request *req);

lib/nvmf/ctrlr.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -4713,17 +4713,18 @@ nvmf_check_qpair_active(struct spdk_nvmf_request *req)
47134713
return false;
47144714
}
47154715

4716-
void
4716+
char *
47174717
spdk_nvmf_request_nqn(struct spdk_nvmf_request *req)
47184718
{
47194719
struct spdk_nvmf_qpair *qpair = req->qpair;
47204720
struct spdk_nvmf_ctrlr *ctrlr;
47214721
if (qpair->ctrlr && qpair->qid != 0) {
47224722
ctrlr = qpair->ctrlr;
47234723
if (ctrlr->subsys) {
4724-
SPDK_NOTICELOG(" subnqn: \"%s\"\n", ctrlr->subsys->subnqn);
4724+
return &ctrlr->subsys->subnqn[67];
47254725
}
47264726
}
4727+
return NULL;
47274728
}
47284729

47294730

lib/nvmf/tcp.c

+59-10
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,31 @@ static void
526526
nvmf_tcp_dump_qpair_req_contents(struct spdk_nvmf_tcp_qpair *tqpair)
527527
{
528528
int i;
529-
struct spdk_nvmf_tcp_req *tcp_req;
529+
// struct spdk_nvmf_tcp_req *tcp_req;
530530

531-
SPDK_ERRLOG("Dumping contents of queue pair (QID %d)\n", tqpair->qpair.qid);
532-
for (i = 1; i < TCP_REQUEST_NUM_STATES; i++) {
533-
SPDK_ERRLOG("\tNum of requests in state[%d] = %u\n", i, tqpair->state_cntr[i]);
531+
// SPDK_ERRLOG("Dumping contents of queue pair (QID %d)\n", tqpair->qpair.qid);
532+
// for (i = 1; i < TCP_REQUEST_NUM_STATES; i++) {
533+
// SPDK_ERRLOG("\tNum of requests in state[%d] = %u\n", i, tqpair->state_cntr[i]);
534534
// TAILQ_FOREACH(tcp_req, &tqpair->tcp_req_working_queue, state_link) {
535535
// if ((int)tcp_req->state == i) {
536536
// SPDK_ERRLOG("\t\tRequest Data From Pool: %d\n", tcp_req->req.data_from_pool);
537537
// SPDK_ERRLOG("\t\tRequest opcode: %d\n", tcp_req->req.cmd->nvmf_cmd.opcode);
538538
// }
539539
// }
540+
// }
541+
542+
char buf[1024]; // Adjust the size as necessary
543+
int offset = 0;
544+
545+
// Build the string with all states
546+
offset += snprintf(buf + offset, sizeof(buf) - offset, "Dumping (QID %d): ", tqpair->qpair.qid);
547+
for (i = 1; i < TCP_REQUEST_NUM_STATES; i++) {
548+
offset += snprintf(buf + offset, sizeof(buf) - offset, "[%d]=%u ", i, tqpair->state_cntr[i]);
540549
}
550+
551+
// Print the entire string in one line
552+
SPDK_ERRLOG("%s \n", buf);
553+
541554
}
542555

543556
static void
@@ -2863,14 +2876,51 @@ nvmf_tcp_check_fused_ordering(struct spdk_nvmf_tcp_transport *ttransport,
28632876
}
28642877
}
28652878

2879+
static const char *
2880+
nvme_command_string(uint16_t value)
2881+
{
2882+
switch (value) {
2883+
case SPDK_NVME_OPC_WRITE:
2884+
return "WRITE";
2885+
case SPDK_NVME_OPC_READ:
2886+
return "READ";
2887+
case SPDK_NVME_OPC_WRITE_ZEROES:
2888+
return "WRITE ZEROES";
2889+
case SPDK_NVME_OPC_COMPARE:
2890+
return "COMPARE";
2891+
case SPDK_NVME_OPC_FLUSH:
2892+
return "FLUSH";
2893+
case SPDK_NVME_OPC_WRITE_UNCORRECTABLE:
2894+
return "WRITE UNCORRECTABLE";
2895+
case SPDK_NVME_OPC_DATASET_MANAGEMENT:
2896+
return "DATASET MANAGEMENT";
2897+
case SPDK_NVME_OPC_RESERVATION_REGISTER:
2898+
return "RESERVATION REGISTER";
2899+
case SPDK_NVME_OPC_RESERVATION_REPORT:
2900+
return "RESERVATION REPORT";
2901+
case SPDK_NVME_OPC_RESERVATION_RELEASE:
2902+
return "RESERVATION RELEASE";
2903+
case SPDK_NVME_OPC_RESERVATION_ACQUIRE:
2904+
return "RESERVATION ACQUIRE";
2905+
default:
2906+
return "IO COMMAND";
2907+
}
2908+
}
2909+
28662910
static void
28672911
check_time(struct spdk_nvmf_tcp_req *tcp_req, struct spdk_nvmf_tcp_qpair *tqpair) {
28682912
if (!tcp_req->loged && tcp_req->time && (tqpair->target_port <= 9099 && tqpair->target_port >= 9090)) {
2869-
if (((spdk_get_ticks() - tcp_req->time) > spdk_get_ticks_hz() * 2) && tqpair->qpair.qid) {
2870-
SPDK_NOTICELOG("tcp_req ttag %d (QID %d) cport %d sport %d\n", tcp_req->ttag, tqpair->qpair.qid, tqpair->initiator_port, tqpair->target_port);
2871-
spdk_nvmf_request_nqn(&tcp_req->req);
2872-
spdk_nvme_print_command_s(tqpair->qpair.qid, &tcp_req->cmd);
2873-
if (tqpair->qpair.qid && ((spdk_get_ticks() - tqpair->time) > spdk_get_ticks_hz() * 15)) {
2913+
if (((spdk_get_ticks() - tcp_req->time) > spdk_get_ticks_hz() * 2) && tqpair->qpair.qid) {
2914+
char *uuid = spdk_nvmf_request_nqn(&tcp_req->req);
2915+
if (!uuid) {
2916+
uuid = "";
2917+
}
2918+
SPDK_NOTICELOG("ttag %d (QID %d) cp %d sp %d, cmd %s, nqn %s\n",
2919+
tcp_req->ttag, tqpair->qpair.qid, tqpair->initiator_port,
2920+
tqpair->target_port, nvme_command_string(tcp_req->cmd.opc), uuid);
2921+
// spdk_nvmf_request_nqn(&tcp_req->req);
2922+
// spdk_nvme_print_command_s(tqpair->qpair.qid, &tcp_req->cmd);
2923+
if (tqpair->qpair.qid && ((spdk_get_ticks() - tqpair->time) > spdk_get_ticks_hz() * 15)) {
28742924
nvmf_tcp_dump_qpair_req_contents(tqpair);
28752925
tqpair->time = spdk_get_ticks();
28762926
}
@@ -2879,7 +2929,6 @@ check_time(struct spdk_nvmf_tcp_req *tcp_req, struct spdk_nvmf_tcp_qpair *tqpair
28792929
}
28802930
}
28812931

2882-
28832932
static bool
28842933
nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
28852934
struct spdk_nvmf_tcp_req *tcp_req)

0 commit comments

Comments
 (0)