linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: Fix dm-multipath starvation when scsi host is busy
@ 2012-05-22  8:59 Jun'ichi Nomura
  2012-05-22  9:13 ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: Jun'ichi Nomura @ 2012-05-22  8:59 UTC (permalink / raw)
  To: linux-scsi, device-mapper development
  Cc: Bernd Schubert, James Bottomley, Mike Snitzer, Alasdair G Kergon

When a scsi host is kept busy by a dm-mpath device, other dm-mpath device
on the same host could be starved. For example:
http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html

It happens because dm-mpath delays request submission when the underlying
scsi host is busy even if sdev is not busy.

For case like this, it is better to send the request down and let scsi do
appropriate starvation control over the shared resource.

Though it might seem odd to change scsi's definition of a LLD being "busy",
it is reasonable because scsi_lld_busy (and blk_lld_busy) was introduced
to provide a hint for request-based stacking driver (i.e. dm-multipath)
and dm-multipath is the only user of this function.

Reported-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Tested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/scsi_lib.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5dfd749..0eb4602 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1378,16 +1378,13 @@ static int scsi_lld_busy(struct request_queue *q)
 {
 	struct scsi_device *sdev = q->queuedata;
 	struct Scsi_Host *shost;
-	struct scsi_target *starget;
 
 	if (!sdev)
 		return 0;
 
 	shost = sdev->host;
-	starget = scsi_target(sdev);
 
-	if (scsi_host_in_recovery(shost) || scsi_host_is_busy(shost) ||
-	    scsi_target_is_busy(starget) || scsi_device_is_busy(sdev))
+	if (scsi_host_in_recovery(shost) || scsi_device_is_busy(sdev)) 
 		return 1;
 
 	return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: Fix dm-multipath starvation when scsi host is busy
  2012-05-22  8:59 [PATCH] scsi: Fix dm-multipath starvation when scsi host is busy Jun'ichi Nomura
@ 2012-05-22  9:13 ` James Bottomley
  2012-05-22  9:57   ` [PATCH v2] " Jun'ichi Nomura
  0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2012-05-22  9:13 UTC (permalink / raw)
  To: Jun'ichi Nomura
  Cc: linux-scsi, device-mapper development, Bernd Schubert,
	Mike Snitzer, Alasdair G Kergon

On Tue, 2012-05-22 at 17:59 +0900, Jun'ichi Nomura wrote:
> When a scsi host is kept busy by a dm-mpath device, other dm-mpath device
> on the same host could be starved. For example:
> http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html
> 
> It happens because dm-mpath delays request submission when the underlying
> scsi host is busy even if sdev is not busy.
> 
> For case like this, it is better to send the request down and let scsi do
> appropriate starvation control over the shared resource.
> 
> Though it might seem odd to change scsi's definition of a LLD being "busy",
> it is reasonable because scsi_lld_busy (and blk_lld_busy) was introduced
> to provide a hint for request-based stacking driver (i.e. dm-multipath)
> and dm-multipath is the only user of this function.

This explanation is rather dense.

Isn't a more understandable explanation:

block congestion control doesn't have any concept of fairness across
multiple queues.  This means that if SCSI reports the host as busy in
the queue congestion control it can result in an unfair starvation
situation in dm-mp if there are multiple multipath devices on the same
host.  The fix for this is to report only the sdev busy state (and
ignore the host busy state) in the block congestion control call back.
The host is still congested, but the SCSI subsystem will sort out the
congestion in a fair way because it knows the relation between the
queues and the host.

And please put a comment in the code as well otherwise someone will
eventually send a "fix" for this because we're not paying attention to
host busy (and I'll have forgotten about the issue by then and might
apply it).

A final note is that this is more a band aid than a fix because this is
still a congestion situation dm-mp should be aware of.

James



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy
  2012-05-22  9:13 ` James Bottomley
@ 2012-05-22  9:57   ` Jun'ichi Nomura
  2012-05-22 12:54     ` Mike Snitzer
  0 siblings, 1 reply; 5+ messages in thread
From: Jun'ichi Nomura @ 2012-05-22  9:57 UTC (permalink / raw)
  To: James Bottomley
  Cc: linux-scsi, device-mapper development, Bernd Schubert,
	Mike Snitzer, Alasdair G Kergon

On 05/22/12 18:13, James Bottomley wrote:
> Isn't a more understandable explanation:

Thank you. That's quite elegant.
I replaced the description with it.

> And please put a comment in the code as well otherwise someone will
> eventually send a "fix" for this because we're not paying attention to
> host busy (and I'll have forgotten about the issue by then and might
> apply it).

Added the comment in code.

> A final note is that this is more a band aid than a fix because this is
> still a congestion situation dm-mp should be aware of.

Yes. To do that, we have to generalize the concept of "host"
and share it with block layer.

Attached below is the revised patch.

----------------------------------------------------------
[PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy

block congestion control doesn't have any concept of fairness across
multiple queues.  This means that if SCSI reports the host as busy in
the queue congestion control it can result in an unfair starvation
situation in dm-mp if there are multiple multipath devices on the same
host.  For example:
http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html

The fix for this is to report only the sdev busy state (and ignore the
host busy state) in the block congestion control call back.
The host is still congested, but the SCSI subsystem will sort out the
congestion in a fair way because it knows the relation between the
queues and the host.

Reported-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Tested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/scsi_lib.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 5dfd749..75dc2e6 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1378,16 +1378,19 @@ static int scsi_lld_busy(struct request_queue *q)
 {
 	struct scsi_device *sdev = q->queuedata;
 	struct Scsi_Host *shost;
-	struct scsi_target *starget;
 
 	if (!sdev)
 		return 0;
 
 	shost = sdev->host;
-	starget = scsi_target(sdev);
 
-	if (scsi_host_in_recovery(shost) || scsi_host_is_busy(shost) ||
-	    scsi_target_is_busy(starget) || scsi_device_is_busy(sdev))
+	/*
+	 * Ignore host/starget busy state.
+	 * Since block layer does not have a concept of fairness across
+	 * multiple queues, congestion of host/starget needs to be handled
+	 * in SCSI layer.
+	 */
+	if (scsi_host_in_recovery(shost) || scsi_device_is_busy(sdev)) 
 		return 1;
 
 	return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy
  2012-05-22  9:57   ` [PATCH v2] " Jun'ichi Nomura
@ 2012-05-22 12:54     ` Mike Snitzer
  2012-05-22 13:01       ` [dm-devel] " Hannes Reinecke
  0 siblings, 1 reply; 5+ messages in thread
From: Mike Snitzer @ 2012-05-22 12:54 UTC (permalink / raw)
  To: Jun'ichi Nomura
  Cc: James Bottomley, linux-scsi, device-mapper development,
	Bernd Schubert, Alasdair G Kergon

On Tue, May 22 2012 at  5:57am -0400,
Jun'ichi Nomura <j-nomura@ce.jp.nec.com> wrote:

> On 05/22/12 18:13, James Bottomley wrote:
> > Isn't a more understandable explanation:
> 
> Thank you. That's quite elegant.
> I replaced the description with it.
> 
> > And please put a comment in the code as well otherwise someone will
> > eventually send a "fix" for this because we're not paying attention to
> > host busy (and I'll have forgotten about the issue by then and might
> > apply it).
> 
> Added the comment in code.
> 
> > A final note is that this is more a band aid than a fix because this is
> > still a congestion situation dm-mp should be aware of.
> 
> Yes. To do that, we have to generalize the concept of "host"
> and share it with block layer.
> 
> Attached below is the revised patch.
> 
> ----------------------------------------------------------
> [PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy
> 
> block congestion control doesn't have any concept of fairness across
> multiple queues.  This means that if SCSI reports the host as busy in
> the queue congestion control it can result in an unfair starvation
> situation in dm-mp if there are multiple multipath devices on the same
> host.  For example:
> http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html
> 
> The fix for this is to report only the sdev busy state (and ignore the
> host busy state) in the block congestion control call back.
> The host is still congested, but the SCSI subsystem will sort out the
> congestion in a fair way because it knows the relation between the
> queues and the host.
> 
> Reported-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
> Tested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
> Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
> Cc: Mike Snitzer <snitzer@redhat.com>

Acked-by: Mike Snitzer <snitzer@redhat.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dm-devel] [PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy
  2012-05-22 12:54     ` Mike Snitzer
@ 2012-05-22 13:01       ` Hannes Reinecke
  0 siblings, 0 replies; 5+ messages in thread
From: Hannes Reinecke @ 2012-05-22 13:01 UTC (permalink / raw)
  To: device-mapper development
  Cc: Mike Snitzer, Jun'ichi Nomura, Bernd Schubert,
	Alasdair G Kergon, linux-scsi

On 05/22/2012 02:54 PM, Mike Snitzer wrote:
> On Tue, May 22 2012 at  5:57am -0400,
> Jun'ichi Nomura <j-nomura@ce.jp.nec.com> wrote:
> 
>> On 05/22/12 18:13, James Bottomley wrote:
>>> Isn't a more understandable explanation:
>>
>> Thank you. That's quite elegant.
>> I replaced the description with it.
>>
>>> And please put a comment in the code as well otherwise someone will
>>> eventually send a "fix" for this because we're not paying attention to
>>> host busy (and I'll have forgotten about the issue by then and might
>>> apply it).
>>
>> Added the comment in code.
>>
>>> A final note is that this is more a band aid than a fix because this is
>>> still a congestion situation dm-mp should be aware of.
>>
>> Yes. To do that, we have to generalize the concept of "host"
>> and share it with block layer.
>>
>> Attached below is the revised patch.
>>
>> ----------------------------------------------------------
>> [PATCH v2] scsi: Fix dm-multipath starvation when scsi host is busy
>>
>> block congestion control doesn't have any concept of fairness across
>> multiple queues.  This means that if SCSI reports the host as busy in
>> the queue congestion control it can result in an unfair starvation
>> situation in dm-mp if there are multiple multipath devices on the same
>> host.  For example:
>> http://www.redhat.com/archives/dm-devel/2012-May/msg00123.html
>>
>> The fix for this is to report only the sdev busy state (and ignore the
>> host busy state) in the block congestion control call back.
>> The host is still congested, but the SCSI subsystem will sort out the
>> congestion in a fair way because it knows the relation between the
>> queues and the host.
>>
>> Reported-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
>> Tested-by: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
>> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
>> Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
>> Cc: Mike Snitzer <snitzer@redhat.com>
> 
> Acked-by: Mike Snitzer <snitzer@redhat.com>
> 
Acked-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-22 13:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22  8:59 [PATCH] scsi: Fix dm-multipath starvation when scsi host is busy Jun'ichi Nomura
2012-05-22  9:13 ` James Bottomley
2012-05-22  9:57   ` [PATCH v2] " Jun'ichi Nomura
2012-05-22 12:54     ` Mike Snitzer
2012-05-22 13:01       ` [dm-devel] " Hannes Reinecke

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).