From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
Hannes Reinecke <hare@suse.de>,
John Garry <john.garry@huawei.com>,
Mike Christie <michael.christie@oracle.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Subject: [PATCH v7 5/8] scsi: core: Rework scsi_single_lun_run()
Date: Fri, 14 Oct 2022 17:24:15 -0700 [thread overview]
Message-ID: <20221015002418.30955-6-bvanassche@acm.org> (raw)
In-Reply-To: <20221015002418.30955-1-bvanassche@acm.org>
Use __starget_for_each_device() instead of open-coding
starget_for_each_device(). Run the queues asynchronously instead of
synchronously.
This patch removes code that calls scsi_device_put() from atomic context.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: John Garry <john.garry@huawei.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_lib.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8b89fab7c420..fa96d3cfdfa3 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -307,6 +307,18 @@ static void scsi_kick_queue(struct request_queue *q)
blk_mq_run_hw_queues(q, false);
}
+/*
+ * Kick the queue of SCSI device @sdev if @sdev != current_sdev. Called with
+ * interrupts disabled.
+ */
+static void scsi_kick_sdev_queue(struct scsi_device *sdev, void *data)
+{
+ struct scsi_device *current_sdev = data;
+
+ if (sdev != current_sdev)
+ blk_mq_run_hw_queues(sdev->request_queue, true);
+}
+
/*
* Called for single_lun devices on IO completion. Clear starget_sdev_user,
* and call blk_run_queue for all the scsi_devices on the target -
@@ -317,7 +329,6 @@ static void scsi_kick_queue(struct request_queue *q)
static void scsi_single_lun_run(struct scsi_device *current_sdev)
{
struct Scsi_Host *shost = current_sdev->host;
- struct scsi_device *sdev, *tmp;
struct scsi_target *starget = scsi_target(current_sdev);
unsigned long flags;
@@ -334,22 +345,9 @@ static void scsi_single_lun_run(struct scsi_device *current_sdev)
scsi_kick_queue(current_sdev->request_queue);
spin_lock_irqsave(shost->host_lock, flags);
- if (starget->starget_sdev_user)
- goto out;
- list_for_each_entry_safe(sdev, tmp, &starget->devices,
- same_target_siblings) {
- if (sdev == current_sdev)
- continue;
- if (scsi_device_get(sdev))
- continue;
-
- spin_unlock_irqrestore(shost->host_lock, flags);
- scsi_kick_queue(sdev->request_queue);
- spin_lock_irqsave(shost->host_lock, flags);
-
- scsi_device_put(sdev);
- }
- out:
+ if (!starget->starget_sdev_user)
+ __starget_for_each_device(starget, current_sdev,
+ scsi_kick_sdev_queue);
spin_unlock_irqrestore(shost->host_lock, flags);
}
next prev parent reply other threads:[~2022-10-15 0:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-15 0:24 [PATCH v7 0/8] Prepare for constifying SCSI host templates Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 1/8] scsi: esas2r: Initialize two host template members implicitly Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 2/8] scsi: esas2r: Introduce scsi_template_proc_dir() Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 3/8] scsi: core: Fail host creation if creating the proc directory fails Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 4/8] scsi: core: Introduce a new list for SCSI proc directory entries Bart Van Assche
2022-10-15 0:24 ` Bart Van Assche [this message]
2022-10-15 0:24 ` [PATCH v7 6/8] scsi: ufs: Simplify ufshcd_set_dev_pwr_mode() Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 7/8] scsi: core: Remove the put_device() call from scsi_device_get() Bart Van Assche
2022-10-15 0:24 ` [PATCH v7 8/8] scsi: core: Release SCSI devices synchronously Bart Van Assche
2022-10-18 3:21 ` [PATCH v7 0/8] Prepare for constifying SCSI host templates Martin K. Petersen
2022-10-22 3:52 ` Martin K. Petersen
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=20221015002418.30955-6-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=john.garry@huawei.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.com \
--cc=ming.lei@redhat.com \
/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