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 07/10] target: core: Extend CaW logging
Date: Fri, 29 Nov 2024 18:30:53 +0300	[thread overview]
Message-ID: <20241129153056.6985-8-a.kovaleva@yadro.com> (raw)
In-Reply-To: <20241129153056.6985-1-a.kovaleva@yadro.com>

Pass se_cmd to the compare_and_write_do_cmp() for extended logging.

Reviewed-by: Dmitriy Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Anastasia Kovaleva <a.kovaleva@yadro.com>
---
 drivers/target/target_core_sbc.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 86b9a0bc6e90..22b705bc7f91 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -375,10 +375,12 @@ static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success,
  * @miscmp_off and return TCM_MISCOMPARE_VERIFY.
  */
 static sense_reason_t
-compare_and_write_do_cmp(struct scatterlist *read_sgl, unsigned int read_nents,
-			 struct scatterlist *cmp_sgl, unsigned int cmp_nents,
-			 unsigned int cmp_len, unsigned int *miscmp_off)
+compare_and_write_do_cmp(struct se_cmd *cmd, unsigned int cmp_len, unsigned int *miscmp_off)
 {
+	struct scatterlist *read_sgl = cmd->t_bidi_data_sg;
+	struct scatterlist *cmp_sgl = cmd->t_data_sg;
+	unsigned int read_nents = cmd->t_bidi_data_nents;
+	unsigned int cmp_nents = cmd->t_data_nents;
 	unsigned char *buf = NULL;
 	struct scatterlist *sg;
 	sense_reason_t ret;
@@ -394,7 +396,7 @@ compare_and_write_do_cmp(struct scatterlist *read_sgl, unsigned int read_nents,
 
 	rc = sg_copy_to_buffer(cmp_sgl, cmp_nents, buf, cmp_len);
 	if (!rc) {
-		target_err("sg_copy_to_buffer() failed for compare_and_write\n");
+		target_cmd_err(cmd, "sg_copy_to_buffer() failed for compare_and_write\n");
 		ret = TCM_OUT_OF_RESOURCES;
 		goto out;
 	}
@@ -413,7 +415,7 @@ compare_and_write_do_cmp(struct scatterlist *read_sgl, unsigned int read_nents,
 			for (i = 0; i < len && addr[i] == buf[offset + i]; i++)
 				;
 			*miscmp_off = offset + i;
-			target_warn("Detected MISCOMPARE at offset %u\n", *miscmp_off);
+			target_cmd_warn(cmd, "Detected MISCOMPARE at offset %u\n", *miscmp_off);
 			ret = TCM_MISCOMPARE_VERIFY;
 		}
 		kunmap_atomic(addr);
@@ -425,7 +427,7 @@ compare_and_write_do_cmp(struct scatterlist *read_sgl, unsigned int read_nents,
 		if (!cmp_len)
 			break;
 	}
-	target_debug("COMPARE AND WRITE read data matches compare data\n");
+	target_cmd_debug(cmd, "COMPARE AND WRITE read data matches compare data\n");
 out:
 	kfree(buf);
 	return ret;
@@ -479,12 +481,7 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd, bool succes
 		goto out;
 	}
 
-	ret = compare_and_write_do_cmp(cmd->t_bidi_data_sg,
-				       cmd->t_bidi_data_nents,
-				       cmd->t_data_sg,
-				       cmd->t_data_nents,
-				       compare_len,
-				       &miscmp_off);
+	ret = compare_and_write_do_cmp(cmd, compare_len, &miscmp_off);
 	if (ret == TCM_MISCOMPARE_VERIFY) {
 		/*
 		 * SBC-4 r15: 5.3 COMPARE AND WRITE command
-- 
2.40.3


  parent reply	other threads:[~2024-11-29 15:32 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 ` [PATCH 01/10] target: core: " Anastasia Kovaleva
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 ` Anastasia Kovaleva [this message]
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-8-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