From: Jens Axboe <axboe@fb.com>
To: <axboe@kernel.dk>, <linux-kernel@vger.kernel.org>,
<linux-scsi@vger.kernel.org>
Cc: <hch@lst.de>, Jens Axboe <axboe@fb.com>
Subject: [PATCH 4/7] scsi: add scsi-mq helper for iterating over busy commands
Date: Fri, 3 Apr 2015 09:58:20 -0600 [thread overview]
Message-ID: <1428076703-31014-5-git-send-email-axboe@fb.com> (raw)
In-Reply-To: <1428076703-31014-1-git-send-email-axboe@fb.com>
This is basically just a wrapper around blk_mq_queue_busy_iter(),
so that LLDs don't have to deal with or worry about blk-mq hardware
queues.
Signed-off-by: Jens Axboe <axboe@fb.com>
---
drivers/scsi/scsi_lib.c | 25 +++++++++++++++++++++++++
include/scsi/scsi_device.h | 3 +++
2 files changed, 28 insertions(+)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 54d7a6cbb98a..87a4c53c8b48 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -648,6 +648,31 @@ static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
}
}
+struct scsi_mq_iter_data {
+ scsi_scmd_iter *fn;
+ void *priv;
+};
+
+static bool scsi_mq_iter_fn(struct blk_mq_hw_ctx *hctx, struct request *rq,
+ void *priv, bool reserved)
+{
+ struct scsi_mq_iter_data *data = priv;
+ struct scsi_cmnd *scmd = rq->special;
+
+ return data->fn(scmd, data->priv);
+}
+
+void scsi_mq_scmd_busy_iter(struct scsi_device *sdev, scsi_scmd_iter *fn,
+ void *priv)
+{
+ struct scsi_mq_iter_data data;
+
+ data.fn = fn;
+ data.priv = priv;
+ blk_mq_queue_busy_iter(sdev->request_queue, scsi_mq_iter_fn, &data);
+}
+EXPORT_SYMBOL(scsi_mq_scmd_busy_iter);
+
/*
* Function: scsi_release_buffers()
*
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index a4c9336811d1..9250b03613f2 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -536,4 +536,7 @@ static inline int scsi_device_tpgs(struct scsi_device *sdev)
MODULE_ALIAS("scsi:t-" __stringify(type) "*")
#define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
+typedef bool (scsi_scmd_iter)(struct scsi_cmnd *, void *);
+void scsi_mq_scmd_busy_iter(struct scsi_device *sdev, scsi_scmd_iter *fn, void *priv);
+
#endif /* _SCSI_SCSI_DEVICE_H */
--
1.9.1
next prev parent reply other threads:[~2015-04-03 16:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 15:58 [PATCH RFC] mpt2/mpt3sas lock reduction for scsi-mq Jens Axboe
2015-04-03 15:58 ` [PATCH 1/7] blk-mq: allow the callback to blk_mq_tag_busy_iter() to stop looping Jens Axboe
2015-04-03 15:58 ` [PATCH 2/7] blk-mq: add helper to iterate all busy tags on all hardware queues Jens Axboe
2015-04-03 15:58 ` [PATCH 3/7] scsi: add scsi-mq helpers to retrieve pdu and check started state Jens Axboe
2015-04-05 15:39 ` Christoph Hellwig
2015-04-03 15:58 ` Jens Axboe [this message]
2015-04-05 15:40 ` [PATCH 4/7] scsi: add scsi-mq helper for iterating over busy commands Christoph Hellwig
2015-04-03 15:58 ` [PATCH 5/7] scsi: add host template init/exit_command hooks Jens Axboe
2015-04-05 15:40 ` Christoph Hellwig
2015-04-03 15:58 ` [PATCH 6/7] mpt2sas: store scsi io tracker data in the scsi command / request Jens Axboe
2015-04-05 16:03 ` Christoph Hellwig
2015-04-07 16:13 ` Jens Axboe
2015-04-07 16:18 ` Christoph Hellwig
2015-04-07 19:22 ` Jens Axboe
2015-04-03 15:58 ` [PATCH 7/7] mpt3sas: " Jens Axboe
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=1428076703-31014-5-git-send-email-axboe@fb.com \
--to=axboe@fb.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@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;
as well as URLs for NNTP newsgroup(s).