提交 be34c62d 编写于 作者: B Bart Van Assche 提交者: Doug Ledford

scsi_transport_srp: Introduce srp_wait_for_queuecommand()

Introduce the helper function srp_wait_for_queuecommand().
Move the definition of scsi_request_fn_active(). Add a comment
above srp_wait_for_queuecommand() that support for scsi-mq needs
to be added.

This patch does not change any functionality. A second call to
srp_wait_for_queuecommand() will be introduced in the next patch.
Signed-off-by: NBart Van Assche <bart.vanassche@sandisk.com>
Cc: James Bottomley <JBottomley@Odin.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Sebastian Parschauer <sebastian.riemer@profitbricks.com>
Cc: <stable@vger.kernel.org> #v3.13
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 e2608180
...@@ -396,6 +396,36 @@ static void srp_reconnect_work(struct work_struct *work) ...@@ -396,6 +396,36 @@ static void srp_reconnect_work(struct work_struct *work)
} }
} }
/**
* scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
* @shost: SCSI host for which to count the number of scsi_request_fn() callers.
*
* To do: add support for scsi-mq in this function.
*/
static int scsi_request_fn_active(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
struct request_queue *q;
int request_fn_active = 0;
shost_for_each_device(sdev, shost) {
q = sdev->request_queue;
spin_lock_irq(q->queue_lock);
request_fn_active += q->request_fn_active;
spin_unlock_irq(q->queue_lock);
}
return request_fn_active;
}
/* Wait until ongoing shost->hostt->queuecommand() calls have finished. */
static void srp_wait_for_queuecommand(struct Scsi_Host *shost)
{
while (scsi_request_fn_active(shost))
msleep(20);
}
static void __rport_fail_io_fast(struct srp_rport *rport) static void __rport_fail_io_fast(struct srp_rport *rport)
{ {
struct Scsi_Host *shost = rport_to_shost(rport); struct Scsi_Host *shost = rport_to_shost(rport);
...@@ -503,27 +533,6 @@ void srp_start_tl_fail_timers(struct srp_rport *rport) ...@@ -503,27 +533,6 @@ void srp_start_tl_fail_timers(struct srp_rport *rport)
} }
EXPORT_SYMBOL(srp_start_tl_fail_timers); EXPORT_SYMBOL(srp_start_tl_fail_timers);
/**
* scsi_request_fn_active() - number of kernel threads inside scsi_request_fn()
* @shost: SCSI host for which to count the number of scsi_request_fn() callers.
*/
static int scsi_request_fn_active(struct Scsi_Host *shost)
{
struct scsi_device *sdev;
struct request_queue *q;
int request_fn_active = 0;
shost_for_each_device(sdev, shost) {
q = sdev->request_queue;
spin_lock_irq(q->queue_lock);
request_fn_active += q->request_fn_active;
spin_unlock_irq(q->queue_lock);
}
return request_fn_active;
}
/** /**
* srp_reconnect_rport() - reconnect to an SRP target port * srp_reconnect_rport() - reconnect to an SRP target port
* @rport: SRP target port. * @rport: SRP target port.
...@@ -559,8 +568,7 @@ int srp_reconnect_rport(struct srp_rport *rport) ...@@ -559,8 +568,7 @@ int srp_reconnect_rport(struct srp_rport *rport)
if (res) if (res)
goto out; goto out;
scsi_target_block(&shost->shost_gendev); scsi_target_block(&shost->shost_gendev);
while (scsi_request_fn_active(shost)) srp_wait_for_queuecommand(shost);
msleep(20);
res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV; res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
pr_debug("%s (state %d): transport.reconnect() returned %d\n", pr_debug("%s (state %d): transport.reconnect() returned %d\n",
dev_name(&shost->shost_gendev), rport->state, res); dev_name(&shost->shost_gendev), rport->state, res);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册