From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
James Bottomley <james.bottomley@hansenpartnership.com>,
linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Hannes Reinecke <hare@suse.com>
Subject: [PATCH 06/11] bfa: Do not use scsi command to signal TMF status
Date: Mon, 2 May 2022 23:54:11 +0200 [thread overview]
Message-ID: <20220502215416.5351-7-hare@suse.de> (raw)
In-Reply-To: <20220502215416.5351-1-hare@suse.de>
The bfa driver hijacks the scsi command to signal the TMF status,
which will no longer work if the TMF handler will be converted.
So rework TMF handling to not use a scsi command but rather add
new TMF fields to the per-device structure.
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/scsi/bfa/bfad_im.c | 112 ++++++++++++++++++++-----------------
drivers/scsi/bfa/bfad_im.h | 2 +
2 files changed, 63 insertions(+), 51 deletions(-)
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 8419a1a89485..a446aa2d6b9a 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -147,13 +147,13 @@ void
bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
enum bfi_tskim_status tsk_status)
{
- struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk;
+ struct bfad_itnim_data_s *itnim_data =
+ (struct bfad_itnim_data_s *)dtsk;
wait_queue_head_t *wq;
- bfad_priv(cmnd)->status |= tsk_status << 1;
- set_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status);
- wq = bfad_priv(cmnd)->wq;
- bfad_priv(cmnd)->wq = NULL;
+ itnim_data->tmf_status |= tsk_status << 1;
+ set_bit(IO_DONE_BIT, &itnim_data->tmf_status);
+ wq = itnim_data->tmf_wq;
if (wq)
wake_up(wq);
@@ -238,15 +238,16 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd)
}
static bfa_status_t
-bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
- struct bfad_itnim_s *itnim)
+bfad_im_target_reset_send(struct bfad_s *bfad,
+ struct bfad_itnim_data_s *itnim_data)
{
+ struct bfad_itnim_s *itnim = itnim_data->itnim;
struct bfa_tskim_s *tskim;
struct bfa_itnim_s *bfa_itnim;
bfa_status_t rc = BFA_STATUS_OK;
struct scsi_lun scsilun;
- tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
+ tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data);
if (!tskim) {
BFA_LOG(KERN_ERR, bfad, bfa_log_level,
"target reset, fail to allocate tskim\n");
@@ -254,12 +255,6 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
goto out;
}
- /*
- * Set host_scribble to NULL to avoid aborting a task command if
- * happens.
- */
- cmnd->host_scribble = NULL;
- bfad_priv(cmnd)->status = 0;
bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
/*
* bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -290,10 +285,11 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
static int
bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
{
- struct Scsi_Host *shost = cmnd->device->host;
+ struct scsi_device *sdev = cmnd->device;
+ struct Scsi_Host *shost = sdev->host;
struct bfad_im_port_s *im_port =
(struct bfad_im_port_s *) shost->hostdata[0];
- struct bfad_itnim_data_s *itnim_data = cmnd->device->hostdata;
+ struct bfad_itnim_data_s *itnim_data = sdev->hostdata;
struct bfad_s *bfad = im_port->bfad;
struct bfa_tskim_s *tskim;
struct bfad_itnim_s *itnim;
@@ -305,14 +301,20 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
struct scsi_lun scsilun;
spin_lock_irqsave(&bfad->bfad_lock, flags);
+ if (itnim_data->tmf_wq) {
+ BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+ "LUN reset, TMF already active");
+ spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+ rc = FAILED;
+ goto out;
+ }
itnim = itnim_data->itnim;
if (!itnim) {
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
rc = FAILED;
goto out;
}
-
- tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
+ tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data);
if (!tskim) {
BFA_LOG(KERN_ERR, bfad, bfa_log_level,
"LUN reset, fail to allocate tskim");
@@ -321,13 +323,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
goto out;
}
- /*
- * Set host_scribble to NULL to avoid aborting a task command
- * if happens.
- */
- cmnd->host_scribble = NULL;
- bfad_priv(cmnd)->wq = &wq;
- bfad_priv(cmnd)->status = 0;
+ itnim_data->tmf_wq = &wq;
+ itnim_data->tmf_status = 0;
bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
/*
* bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -342,14 +339,15 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
rc = FAILED;
goto out;
}
- int_to_scsilun(cmnd->device->lun, &scsilun);
+ int_to_scsilun(sdev->lun, &scsilun);
bfa_tskim_start(tskim, bfa_itnim, scsilun,
FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO);
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
- wait_event(wq, test_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status));
+ wait_event(wq, test_bit(IO_DONE_BIT, &itnim_data->tmf_status));
- task_status = bfad_priv(cmnd)->status >> 1;
+ itnim_data->tmf_wq = NULL;
+ task_status = itnim_data->tmf_status >> 1;
if (task_status != BFI_TSKIM_STS_OK) {
BFA_LOG(KERN_ERR, bfad, bfa_log_level,
"LUN reset failure, status: %d\n", task_status);
@@ -368,35 +366,47 @@ bfad_im_reset_target_handler(struct scsi_cmnd *cmnd)
{
struct Scsi_Host *shost = cmnd->device->host;
struct scsi_target *starget = scsi_target(cmnd->device);
+ struct fc_rport *rport = starget_to_rport(starget);
struct bfad_im_port_s *im_port =
(struct bfad_im_port_s *) shost->hostdata[0];
- struct bfad_s *bfad = im_port->bfad;
- struct bfad_itnim_s *itnim;
- unsigned long flags;
- u32 rc, rtn = FAILED;
+ struct bfad_s *bfad = im_port->bfad;
+ struct bfad_itnim_data_s *itnim_data;
+ struct bfad_itnim_s *itnim;
+ unsigned long flags;
+ u32 rc, rtn = FAILED;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
enum bfi_tskim_status task_status;
spin_lock_irqsave(&bfad->bfad_lock, flags);
- itnim = bfad_get_itnim(im_port, starget->id);
- if (itnim) {
- bfad_priv(cmnd)->wq = &wq;
- rc = bfad_im_target_reset_send(bfad, cmnd, itnim);
- if (rc == BFA_STATUS_OK) {
- /* wait target reset to complete */
- spin_unlock_irqrestore(&bfad->bfad_lock, flags);
- wait_event(wq, test_bit(IO_DONE_BIT,
- &bfad_priv(cmnd)->status));
- spin_lock_irqsave(&bfad->bfad_lock, flags);
-
- task_status = bfad_priv(cmnd)->status >> 1;
- if (task_status != BFI_TSKIM_STS_OK)
- BFA_LOG(KERN_ERR, bfad, bfa_log_level,
- "target reset failure,"
- " status: %d\n", task_status);
- else
- rtn = SUCCESS;
- }
+ if (!rport->dd_data) {
+ spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+ return rtn;
+ }
+ itnim_data = rport->dd_data;
+ if (itnim_data->tmf_wq) {
+ BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+ "target reset failed, TMF already active");
+ spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+ return rtn;
+ }
+ itnim = itnim_data->itnim;
+ itnim_data->tmf_wq = &wq;
+ itnim_data->tmf_status = 0;
+ rc = bfad_im_target_reset_send(bfad, itnim_data);
+ if (rc == BFA_STATUS_OK) {
+ /* wait target reset to complete */
+ spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+ wait_event(wq, test_bit(IO_DONE_BIT,
+ &itnim_data->tmf_status));
+ spin_lock_irqsave(&bfad->bfad_lock, flags);
+
+ task_status = itnim_data->tmf_status >> 1;
+ if (task_status != BFI_TSKIM_STS_OK)
+ BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+ "target reset failure,"
+ " status: %d\n", task_status);
+ else
+ rtn = SUCCESS;
}
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h
index c03b225ea1ba..c9ead4217a7d 100644
--- a/drivers/scsi/bfa/bfad_im.h
+++ b/drivers/scsi/bfa/bfad_im.h
@@ -61,6 +61,8 @@ static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd)
struct bfad_itnim_data_s {
struct bfad_itnim_s *itnim;
+ wait_queue_head_t *tmf_wq;
+ unsigned long tmf_status;
};
struct bfad_im_port_s {
--
2.29.2
next prev parent reply other threads:[~2022-05-02 21:54 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 21:54 [PATCH 00/11] scsi: EH rework prep patches, part 2 Hannes Reinecke
2022-05-02 21:54 ` [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
2022-05-03 14:25 ` Christoph Hellwig
2022-05-03 16:23 ` Bart Van Assche
2022-05-03 18:33 ` Hannes Reinecke
2022-05-02 21:54 ` [PATCH 02/11] sym53c8xx_2: rework reset handling Hannes Reinecke
2022-05-03 14:25 ` Christoph Hellwig
2022-05-02 21:54 ` [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
2022-05-03 14:25 ` Christoph Hellwig
2022-05-02 21:54 ` [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
2022-05-03 14:26 ` Christoph Hellwig
2022-05-02 21:54 ` [PATCH 05/11] pmcraid: select first available device for target reset Hannes Reinecke
2022-05-03 14:26 ` Christoph Hellwig
2022-05-03 16:24 ` Bart Van Assche
2022-05-03 18:36 ` Hannes Reinecke
2022-05-02 21:54 ` Hannes Reinecke [this message]
2022-05-03 14:27 ` [PATCH 06/11] bfa: Do not use scsi command to signal TMF status Christoph Hellwig
2022-05-03 14:32 ` Hannes Reinecke
2022-05-02 21:54 ` [PATCH 07/11] aha152x: look for stuck command when resetting device Hannes Reinecke
2022-05-02 21:54 ` [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
2022-05-02 21:54 ` [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
2022-05-03 14:29 ` Christoph Hellwig
2022-05-02 21:54 ` [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
2022-05-03 14:33 ` Christoph Hellwig
2022-05-02 21:54 ` [PATCH 11/11] csiostor: use separate TMF command Hannes Reinecke
2022-05-03 14:33 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
2022-05-02 21:59 ` [PATCH 06/11] bfa: Do not use scsi command to signal TMF status 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=20220502215416.5351-7-hare@suse.de \
--to=hare@suse.de \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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