linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mchristi@redhat.com
To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
	target-devel@vger.kernel.org
Cc: Mike Christie <mchristi@redhat.com>
Subject: [PATCH 3/5] target: call queue reset if supported
Date: Wed, 25 May 2016 02:55:01 -0500	[thread overview]
Message-ID: <1464162903-14735-4-git-send-email-mchristi@redhat.com> (raw)
In-Reply-To: <1464162903-14735-1-git-send-email-mchristi@redhat.com>

From: Mike Christie <mchristi@redhat.com>

Instead of waiting for commands, map the lun reset operation
to a queue reset.

We do not check the result of blk_reset_queue because if
it works then we need to wait for the bio/request completions
and if it failed we might as wait and hope like we did before.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 drivers/target/target_core_file.c    | 12 ++++++++++++
 drivers/target/target_core_iblock.c  |  8 ++++++++
 drivers/target/target_core_pscsi.c   |  8 ++++++++
 drivers/target/target_core_tmr.c     |  3 +++
 include/target/target_core_backend.h |  1 +
 5 files changed, 32 insertions(+)

diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 75f0f08..d6af1f2 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -97,6 +97,17 @@ static struct se_device *fd_alloc_device(struct se_hba *hba, const char *name)
 	return &fd_dev->dev;
 }
 
+static int fd_reset_device(struct se_device *dev)
+{
+	struct fd_dev *fd_dev = FD_DEV(dev);
+	struct inode *inode;
+
+	inode = fd_dev->fd_file->f_mapping->host;
+	if (!S_ISBLK(inode->i_mode))
+		return -EOPNOTSUPP;
+	return blk_reset_queue(bdev_get_queue(inode->i_bdev));
+}
+
 static int fd_configure_device(struct se_device *dev)
 {
 	struct fd_dev *fd_dev = FD_DEV(dev);
@@ -813,6 +824,7 @@ static const struct target_backend_ops fileio_ops = {
 	.attach_hba		= fd_attach_hba,
 	.detach_hba		= fd_detach_hba,
 	.alloc_device		= fd_alloc_device,
+	.reset_device		= fd_reset_device,
 	.configure_device	= fd_configure_device,
 	.free_device		= fd_free_device,
 	.parse_cdb		= fd_parse_cdb,
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 7c4efb4..0a7dd59 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -79,6 +79,13 @@ static struct se_device *iblock_alloc_device(struct se_hba *hba, const char *nam
 	return &ib_dev->dev;
 }
 
+static int iblock_reset_device(struct se_device *dev)
+{
+	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
+
+	return blk_reset_queue(bdev_get_queue(ib_dev->ibd_bd));
+}
+
 static int iblock_configure_device(struct se_device *dev)
 {
 	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
@@ -848,6 +855,7 @@ static const struct target_backend_ops iblock_ops = {
 	.detach_hba		= iblock_detach_hba,
 	.alloc_device		= iblock_alloc_device,
 	.configure_device	= iblock_configure_device,
+	.reset_device		= iblock_reset_device,
 	.free_device		= iblock_free_device,
 	.parse_cdb		= iblock_parse_cdb,
 	.set_configfs_dev_params = iblock_set_configfs_dev_params,
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index de18790..fa0505b 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -455,6 +455,13 @@ static int pscsi_create_type_other(struct se_device *dev,
 	return 0;
 }
 
+static int pscsi_reset_device(struct se_device *dev)
+{
+	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
+
+	return blk_reset_queue(pdv->pdv_sd->request_queue);
+}
+
 static int pscsi_configure_device(struct se_device *dev)
 {
 	struct se_hba *hba = dev->se_hba;
@@ -1131,6 +1138,7 @@ static const struct target_backend_ops pscsi_ops = {
 	.detach_hba		= pscsi_detach_hba,
 	.pmode_enable_hba	= pscsi_pmode_enable_hba,
 	.alloc_device		= pscsi_alloc_device,
+	.reset_device		= pscsi_reset_device,
 	.configure_device	= pscsi_configure_device,
 	.free_device		= pscsi_free_device,
 	.transport_complete	= pscsi_transport_complete,
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 4f229e7..609ec53 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -431,6 +431,9 @@ int core_tmr_lun_reset(
 		(preempt_and_abort_list) ? "Preempt" : "TMR",
 		dev->transport->name, tas);
 
+	if (dev->transport->reset_device(dev))
+		dev->transport->reset_device(dev);
+
 	core_tmr_drain_tmr_list(dev, tmr, preempt_and_abort_list);
 	core_tmr_drain_state_list(dev, prout_cmd, tmr_sess, tas,
 				preempt_and_abort_list);
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index 28ee5c2..a055e4f 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -17,6 +17,7 @@ struct target_backend_ops {
 
 	struct se_device *(*alloc_device)(struct se_hba *, const char *);
 	int (*configure_device)(struct se_device *);
+	int (*reset_device)(struct se_device *);
 	void (*free_device)(struct se_device *device);
 
 	ssize_t (*set_configfs_dev_params)(struct se_device *,
-- 
2.7.2


  parent reply	other threads:[~2016-05-25  7:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25  7:54 [PATCH 0/5] block/target queue/LUN reset support mchristi
2016-05-25  7:54 ` [PATCH 1/5] blk mq: take ref to q when running it mchristi
2016-05-25 15:53   ` Bart Van Assche
2016-05-25 19:15     ` Mike Christie
2016-05-25 19:20       ` Mike Christie
2016-05-25  7:55 ` [PATCH 2/5] block: add queue reset support mchristi
2016-05-25 16:13   ` Bart Van Assche
2016-05-25 19:16     ` Mike Christie
2016-05-25  7:55 ` mchristi [this message]
2016-05-27  8:22   ` [PATCH 3/5] target: call queue reset if supported Christoph Hellwig
2016-05-25  7:55 ` [PATCH 4/5] scsi: add new async device reset support mchristi
2016-05-27  8:23   ` Christoph Hellwig
2016-05-27  9:16     ` Hannes Reinecke
2016-05-30  6:27   ` Hannes Reinecke
2016-05-31 19:38     ` Mike Christie
2016-05-31 19:59       ` Mike Christie
2016-05-31 20:34       ` Mike Christie
2016-05-25  7:55 ` [PATCH 5/5] iscsi initiator: support eh_async_device_reset_handler mchristi
2016-05-30  6:37 ` [PATCH 0/5] block/target queue/LUN reset support Hannes Reinecke
2016-05-31 19:56   ` Mike Christie
2016-06-01  6:05     ` Hannes Reinecke

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=1464162903-14735-4-git-send-email-mchristi@redhat.com \
    --to=mchristi@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).