public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Anastasia Kovaleva <a.kovaleva@yadro.com>
To: <martin.petersen@oracle.com>, <bootc@bootc.net>,
	<bostroesser@gmail.com>, <michael.christie@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <target-devel@vger.kernel.org>,
	<linux@yadro.com>
Subject: [PATCH 01/10] target: core: Improve SCSI target logs
Date: Fri, 29 Nov 2024 18:30:47 +0300	[thread overview]
Message-ID: <20241129153056.6985-2-a.kovaleva@yadro.com> (raw)
In-Reply-To: <20241129153056.6985-1-a.kovaleva@yadro.com>

Introduce a new logging wrapper.

Reviewed-by: Dmitriy Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Anastasia Kovaleva <a.kovaleva@yadro.com>
---
 include/target/target_core_base.h | 92 +++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 97099a5e3f6c..da4c09d3698b 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -11,6 +11,98 @@
 
 #define TARGET_CORE_VERSION		"v5.0"
 
+/*
+ * Unified target core logs
+ */
+#define target_sess_log(LVL, SESS, FMT, ...) \
+	pr_##LVL("target " TARGET_PREFIX " (%s -> %d): " FMT, \
+		(SESS)->se_node_acl->initiatorname, \
+		(SESS)->se_tpg->tpg_rtpi, ##__VA_ARGS__)
+
+#define target_cmd_log(LVL, CMD, FMT, ...) \
+	pr_##LVL("target " TARGET_PREFIX " (%s -> %d/%lld): " FMT, \
+		(CMD)->se_sess->se_node_acl->initiatorname, \
+		(CMD)->se_sess->se_tpg->tpg_rtpi, \
+		(CMD)->orig_fe_lun, ##__VA_ARGS__)
+
+#define target_lun_log(LVL, LUN, FMT, ...) \
+	pr_##LVL("target " TARGET_PREFIX " %s_tpg[%hu](%d/%llu): " FMT, \
+		(LUN)->lun_tpg->se_tpg_tfo->fabric_name, \
+		(LUN)->lun_tpg->se_tpg_tfo->tpg_get_tag(LUN->lun_tpg), \
+		(LUN)->lun_tpg->tpg_rtpi, \
+		(LUN)->unpacked_lun, ##__VA_ARGS__)
+
+#define target_log(LVL, FMT, ...) \
+	pr_##LVL("target " TARGET_PREFIX ": " FMT, ##__VA_ARGS__)
+
+#define target_sess_debug(SESS, FMT, ...)  target_sess_log(debug, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_info(SESS, FMT, ...)   target_sess_log(info, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_notice(SESS, FMT, ...) target_sess_log(notice, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_warn(SESS, FMT, ...)   target_sess_log(warn, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_err(SESS, FMT, ...)    target_sess_log(err, SESS, FMT, ##__VA_ARGS__)
+
+#define target_cmd_debug(CMD, FMT, ...)  target_cmd_log(debug, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_info(CMD, FMT, ...)   target_cmd_log(info, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_notice(CMD, FMT, ...) target_cmd_log(notice, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_warn(CMD, FMT, ...)   target_cmd_log(warn, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_err(CMD, FMT, ...)    target_cmd_log(err, CMD, FMT, ##__VA_ARGS__)
+
+#define target_lun_debug(LUN, FMT, ...)  target_lun_log(debug, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_info(LUN, FMT, ...)   target_lun_log(info, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_notice(LUN, FMT, ...) target_lun_log(notice, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_warn(LUN, FMT, ...)   target_lun_log(warn, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_err(LUN, FMT, ...)    target_lun_log(err, LUN, FMT, ##__VA_ARGS__)
+
+#define target_debug(FMT, ...)  target_log(debug, FMT, ##__VA_ARGS__)
+#define target_info(FMT, ...)   target_log(info, FMT, ##__VA_ARGS__)
+#define target_notice(FMT, ...) target_log(notice, FMT, ##__VA_ARGS__)
+#define target_warn(FMT, ...)   target_log(warn, FMT, ##__VA_ARGS__)
+#define target_err(FMT, ...)    target_log(err, FMT, ##__VA_ARGS__)
+
+#define target_sess_debug_ratelimited(SESS, FMT, ...) \
+	target_sess_log(debug_ratelimited, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_info_ratelimited(SESS, FMT, ...) \
+	target_sess_log(info_ratelimited, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_notice_ratelimited(SESS, FMT, ...) \
+	target_sess_log(notice_ratelimited, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_warn_ratelimited(SESS, FMT, ...) \
+	target_sess_log(warn_ratelimited, SESS, FMT, ##__VA_ARGS__)
+#define target_sess_err_ratelimited(SESS, FMT, ...) \
+	target_sess_log(err_ratelimited, SESS, FMT, ##__VA_ARGS__)
+
+#define target_cmd_debug_ratelimited(CMD, FMT, ...) \
+	target_cmd_log(debug_ratelimited, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_info_ratelimited(CMD, FMT, ...) \
+	target_cmd_log(info_ratelimited, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_notice_ratelimited(CMD, FMT, ...) \
+	target_cmd_log(notice_ratelimited, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_warn_ratelimited(CMD, FMT, ...) \
+	target_cmd_log(warn_ratelimited, CMD, FMT, ##__VA_ARGS__)
+#define target_cmd_err_ratelimited(CMD, FMT, ...) \
+	target_cmd_log(err_ratelimited, CMD, FMT, ##__VA_ARGS__)
+
+#define target_lun_debug_ratelimited(LUN, FMT, ...) \
+	target_lun_log(debug_ratelimited, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_info_ratelimited(LUN, FMT, ...) \
+	target_lun_log(info_ratelimited, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_notice_ratelimited(LUN, FMT, ...) \
+	target_lun_log(notice_ratelimited, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_warn_ratelimited(LUN, FMT, ...) \
+	target_lun_log(warn_ratelimited, LUN, FMT, ##__VA_ARGS__)
+#define target_lun_err_ratelimited(LUN, FMT, ...) \
+	target_lun_log(err_ratelimited, LUN, FMT, ##__VA_ARGS__)
+
+#define target_debug_ratelimited(FMT, ...) \
+	target_log(debug_ratelimited, FMT, ##__VA_ARGS__)
+#define target_info_ratelimited(FMT, ...) \
+	target_log(info_ratelimited, FMT, ##__VA_ARGS__)
+#define target_notice_ratelimited(FMT, ...) \
+	target_log(notice_ratelimited, FMT, ##__VA_ARGS__)
+#define target_warn_ratelimited(FMT, ...) \
+	target_log(warn_ratelimited, FMT, ##__VA_ARGS__)
+#define target_err_ratelimited(FMT, ...) \
+	target_log(err_ratelimited, FMT, ##__VA_ARGS__)
+
 /*
  * Maximum size of a CDB that can be stored in se_cmd without allocating
  * memory dynamically for the CDB.
-- 
2.40.3


  reply	other threads:[~2024-11-29 15:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 15:30 [PATCH 00/10] Improve SCSI target logs Anastasia Kovaleva
2024-11-29 15:30 ` Anastasia Kovaleva [this message]
2024-11-29 15:30 ` [PATCH 02/10] target: Use new log wrappers Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 03/10] target: Fix quoted strings splitting Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 04/10] target: Fix some obvious style problems Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 05/10] target: Add log prefix to all tcm files Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 06/10] target: Remove old prefixes from log messages Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 07/10] target: core: Extend CaW logging Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 08/10] target: core: Use extended logs where possible Anastasia Kovaleva
2024-11-29 21:05   ` kernel test robot
2024-11-29 22:08   ` kernel test robot
2024-11-29 15:30 ` [PATCH 09/10] target: Use __func__ in logs Anastasia Kovaleva
2024-11-29 15:30 ` [PATCH 10/10] target: iscsi: Improve a log message Anastasia Kovaleva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241129153056.6985-2-a.kovaleva@yadro.com \
    --to=a.kovaleva@yadro.com \
    --cc=bootc@bootc.net \
    --cc=bostroesser@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux@yadro.com \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox