Commit 1a884e94 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

lib/log: do not use spdk_log_get_flag() in macro for log flags



Especially SPDK_INFOLOG() should not call spdk_log_get_flag() function,
instead rely on the log flag structure.

This caused performance degradation in places that used SPDK_INFOLOG
too extensively.

Due to nature of the macros, in the meantime new debug log in
iscsi was improperly named. This wasn't caught because of the
macros reliance on spdk_log_get_flag(), where if name wasn't
registered - no log was printed and no compilation occurred.
Going back to using the structures, gives immediate feedback
that there is no SPDK_LOG_ISCSI log flag.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I262eadb5aee29caa2a5cd719c82ca4963ea24576
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4712


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 186c834f
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -134,7 +134,8 @@ enum spdk_log_level spdk_log_get_print_level(void);
	spdk_log(SPDK_LOG_NOTICE, NULL, -1, NULL, __VA_ARGS__)
#define SPDK_INFOLOG(FLAG, ...)									\
	do {											\
		if (spdk_log_get_flag(#FLAG)) {							\
		extern struct spdk_log_flag SPDK_LOG_##FLAG;					\
		if (SPDK_LOG_##FLAG.enabled) {							\
			spdk_log(SPDK_LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__);	\
		}										\
	} while (0)
@@ -142,14 +143,16 @@ enum spdk_log_level spdk_log_get_print_level(void);
#ifdef DEBUG
#define SPDK_DEBUGLOG(FLAG, ...)								\
	do {											\
		if (SPDK_DEBUGLOG_FLAG_ENABLED(#FLAG)) {					\
		extern struct spdk_log_flag SPDK_LOG_##FLAG;					\
		if (SPDK_LOG_##FLAG.enabled) {							\
			spdk_log(SPDK_LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__);	\
		}										\
	} while (0)

#define SPDK_LOGDUMP(FLAG, LABEL, BUF, LEN)				\
	do {								\
		if (SPDK_DEBUGLOG_FLAG_ENABLED(#FLAG)) {		\
		extern struct spdk_log_flag SPDK_LOG_##FLAG;		\
		if (SPDK_LOG_##FLAG.enabled) {				\
			spdk_log_dump(stderr, (LABEL), (BUF), (LEN));	\
		}							\
	} while (0)
+1 −1
Original line number Diff line number Diff line
@@ -4598,7 +4598,7 @@ iscsi_read_pdu(struct spdk_iscsi_conn *conn)
			/* AHS */
			ahs_len = pdu->bhs.total_ahs_len * 4;
			if (ahs_len > ISCSI_AHS_LEN) {
				SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "pdu ahs length %d is invalid\n", ahs_len);
				SPDK_DEBUGLOG(iscsi, "pdu ahs length %d is invalid\n", ahs_len);
				conn->pdu_recv_state = ISCSI_PDU_RECV_STATE_ERROR;
				break;
			}