All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: core: Fix "scsi: core: add scsi_host_(block,unblock) helper function"
@ 2020-07-17  9:09 Ye Bin
  2020-07-17  9:09 ` [PATCH] scsi: Delete unnecessary allocate buffer for every loop when print command Ye Bin
  0 siblings, 1 reply; 3+ messages in thread
From: Ye Bin @ 2020-07-17  9:09 UTC (permalink / raw)
  To: linux-scsi, martin.petersen; +Cc: bvanassche, sashal, Ye Bin

In commit 4dea170f4fb2 ("scsi: core: Fix incorrect usage of shost_for_each_device")
fix usage of shost_for_each_device in function scsi_host_block.

Fix: 2bb955840c1d("scsi: core: add scsi_host_(block,unblock) helper function")
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/scsi/scsi_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index f3bf2648105c..65fde27b8b08 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2811,8 +2811,10 @@ scsi_host_block(struct Scsi_Host *shost)
 		mutex_lock(&sdev->state_mutex);
 		ret = scsi_internal_device_block_nowait(sdev);
 		mutex_unlock(&sdev->state_mutex);
-		if (ret)
+		if (ret) {
+			scsi_device_put(sdev);
 			break;
+		}
 	}
 
 	/*
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] scsi: Delete unnecessary allocate buffer for every loop when print command
  2020-07-17  9:09 [PATCH] scsi: core: Fix "scsi: core: add scsi_host_(block,unblock) helper function" Ye Bin
@ 2020-07-17  9:09 ` Ye Bin
  2020-07-25  2:50   ` Martin K. Petersen
  0 siblings, 1 reply; 3+ messages in thread
From: Ye Bin @ 2020-07-17  9:09 UTC (permalink / raw)
  To: linux-scsi, martin.petersen; +Cc: bvanassche, sashal, Ye Bin

We can allocate buffer once, and reuse it. There is unnecessary allocate
 buffer for every loop.

Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 drivers/scsi/scsi_logging.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index c91fa3feb930..8ea44c6595ef 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -205,13 +205,9 @@ void scsi_print_command(struct scsi_cmnd *cmd)
 		/* Print opcode in one line and use separate lines for CDB */
 		off += scnprintf(logbuf + off, logbuf_len - off, "\n");
 		dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
-		scsi_log_release_buffer(logbuf);
 		for (k = 0; k < cmd->cmd_len; k += 16) {
 			size_t linelen = min(cmd->cmd_len - k, 16);
 
-			logbuf = scsi_log_reserve_buffer(&logbuf_len);
-			if (!logbuf)
-				break;
 			off = sdev_format_header(logbuf, logbuf_len,
 						 scmd_name(cmd),
 						 cmd->request->tag);
@@ -224,9 +220,8 @@ void scsi_print_command(struct scsi_cmnd *cmd)
 			}
 			dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s",
 				   logbuf);
-			scsi_log_release_buffer(logbuf);
 		}
-		return;
+		goto out;
 	}
 	if (!WARN_ON(off > logbuf_len - 49)) {
 		off += scnprintf(logbuf + off, logbuf_len - off, " ");
@@ -236,6 +231,7 @@ void scsi_print_command(struct scsi_cmnd *cmd)
 	}
 out_printk:
 	dev_printk(KERN_INFO, &cmd->device->sdev_gendev, "%s", logbuf);
+out:
 	scsi_log_release_buffer(logbuf);
 }
 EXPORT_SYMBOL(scsi_print_command);
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: Delete unnecessary allocate buffer for every loop when print command
  2020-07-17  9:09 ` [PATCH] scsi: Delete unnecessary allocate buffer for every loop when print command Ye Bin
@ 2020-07-25  2:50   ` Martin K. Petersen
  0 siblings, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-07-25  2:50 UTC (permalink / raw)
  To: linux-scsi, Ye Bin; +Cc: Martin K . Petersen, sashal, bvanassche

On Fri, 17 Jul 2020 17:09:21 +0800, Ye Bin wrote:

> We can allocate buffer once, and reuse it. There is unnecessary allocate
>  buffer for every loop.

Applied to 5.9/scsi-queue, thanks!

[1/1] scsi: core: Delete unnecessary buffer allocation for every loop iteration
      https://git.kernel.org/mkp/scsi/c/811f39479c0c

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-25  2:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17  9:09 [PATCH] scsi: core: Fix "scsi: core: add scsi_host_(block,unblock) helper function" Ye Bin
2020-07-17  9:09 ` [PATCH] scsi: Delete unnecessary allocate buffer for every loop when print command Ye Bin
2020-07-25  2:50   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.