RFC: libsas queuecommand fixups
Subsystems (2)
cover RFC: libsas queuecommand fixups
Fix up some lose ends in sas_queuecommand that I noticed during the isci review. The first two are pretty straight forward, but the third is a bit more nasty and needs some serious review and testing. Note that I could only compile-test the bunch as I don't actually have a SAS controller using libsas.
PATCH 1/3 libsas: sas_queuecommand doesnt need host_lock
drivers/scsi/libsas/sas_scsi_host.c +3 -22
@@ -182,27 +182,12 @@ int sas_queue_up(struct sas_task *task)return 0 ; } -/** -* sas_queuecommand -- Enqueue a command for processing -* @parameters: See SCSI Core documentation -* -* Note: XXX: Remove the host unlock/lock pair when SCSI Core can -* call us without holding an IRQ spinlock... -*/ -static int sas_queuecommand_lck (struct scsi_cmnd *cmd, -void (*scsi_done)(struct scsi_cmnd *)) - __releases(host->host_lock) - __acquires(dev->sata_dev.ap->lock) - __releases(dev->sata_dev.ap->lock) - __acquires(host->host_lock) +int sas_queuecommand (struct Scsi_Host *host,struct scsi_cmnd *cmd) {int res =0 ;struct domain_device *dev =cmd_to_domain_dev (cmd); -struct Scsi_Host *host = cmd->device->host;struct sas_internal *i =to_sas_internal (host->transportt); -spin_unlock_irq (host->host_lock); - {struct sas_ha_struct *sas_ha = dev->port->ha;struct sas_task *task;
@@ -210,7 +195,7 @@ static int sas_queuecommand_lck(struct s/* If the device fell off, no sense in issuing commands */ if (dev->gone) { cmd->result =DID_BAD_TARGET <<16 ; -scsi_done (cmd); + cmd->scsi_done (cmd); goto out; }
@@ -228,7 +213,6 @@ static int sas_queuecommand_lck(struct sif (!task) goto out; - cmd->scsi_done = scsi_done;/* Queue up, Direct Mode or Task Collector Mode. */ if (sas_ha->lldd_max_execute_num <2 ) res = i->dft->lldd_execute_task (task,1 ,GFP_ATOMIC );
@@ -243,18 +227,15 @@ static int sas_queuecommand_lck(struct sif (res == -SAS_QUEUE_FULL ) { cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ res =0 ; -scsi_done (cmd); + cmd->scsi_done (cmd); } goto out; } } out: -spin_lock_irq (host->host_lock);return res; } -DEF_SCSI_QCMD (sas_queuecommand) -static void sas_eh_finish_cmd (struct scsi_cmnd *cmd) {struct sas_task *task =TO_SAS_TASK (cmd);
Re: [PATCH 1/3] libsas: sas_queuecommand doesnt need host_lock
Quoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Dave can add his Tested-by, but looks like a nice bump in iops.
--
Dan
Jiang, Dave
Tested-byRE: [PATCH 1/3] libsas: sas_queuecommand doesnt need host_lock
Quoted 12 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Dan Williams
Sent: Monday, July 18, 2011 4:40 PM
To: Christoph Hellwig
Cc: [email protected]; [email protected]; Jiang, Dave
Subject: Re: [PATCH 1/3] libsas:sas_queuecommanddoesnt needhost_lockQuoted 1 line · Christoph Hellwig
Quoted 8 lines
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>Acked-by Dan Williams <[email protected]>Dave can add his Tested-by, but looks like a nice bump in iops.
--
Dan
RE: [PATCH 1/3] libsas: sas_queuecommand doesnt need host_lock
In reply to Dan WilliamsQuoted 2 lines
On Mon, Jul 11, 2011 at 11:49 AM, Christoph Hellwig <[email protected]>
Quoted 6 lines · wrote:
Quoted 2 lines
Signed-off-by Christoph Hellwig <[email protected]>Acked-by Dan Williams <[email protected]>Dave can add his Tested-by, but looks like a nice bump in iops.
[Jack Wang]
I test it with pm8001, using 512b read with 12 6G sas disks bumps ~460K iops from 340K iops, but using 512b write performance drops from 340K to 240K.
Dan and Dave , could you share your number?
Quoted 7 lines
--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/3] libsas: sas_queuecommand doesnt need host_lock
Quoted 3 lines · Jack Wang
[Jack Wang]
I test it with pm8001, using 512b read with 12 6G sas disks bumps ~460K iops from 340K iops, but using 512b write performance drops from 340K to 240K.
Very strange. Is this repeatable, and did you test with just patch 1, or the whole series?
PATCH 2/3 libsas: reindent sas_queuecommand
In reply to Christoph HellwigSwitch sas_queuecommand to a normal indentation and goto based error handling.
drivers/scsi/libsas/sas_scsi_host.c +42 -47
@@ -184,56 +184,51 @@ int sas_queue_up(struct sas_task *task)int sas_queuecommand (struct Scsi_Host *host,struct scsi_cmnd *cmd) { -int res =0 ; -struct domain_device *dev =cmd_to_domain_dev (cmd);struct sas_internal *i =to_sas_internal (host->transportt); +struct domain_device *dev =cmd_to_domain_dev (cmd); +struct sas_ha_struct *sas_ha = dev->port->ha; +struct sas_task *task; +int res =0 ; - { -struct sas_ha_struct *sas_ha = dev->port->ha; -struct sas_task *task; - -/* If the device fell off, no sense in issuing commands */ -if (dev->gone) { - cmd->result =DID_BAD_TARGET <<16 ; - cmd->scsi_done (cmd); - goto out; - } - -if (dev_is_sata (dev)) { -unsigned long flags; - -spin_lock_irqsave (dev->sata_dev.ap->lock, flags); - res =ata_sas_queuecmd (cmd, dev->sata_dev.ap); -spin_unlock_irqrestore (dev->sata_dev.ap->lock, flags); - goto out; - } - - res = -ENOMEM ; - task =sas_create_task (cmd, dev,GFP_ATOMIC ); -if (!task) - goto out; - -/* Queue up, Direct Mode or Task Collector Mode. */ -if (sas_ha->lldd_max_execute_num <2 ) - res = i->dft->lldd_execute_task (task,1 ,GFP_ATOMIC ); -else - res =sas_queue_up (task); - -/* Examine */ -if (res) { -SAS_DPRINTK ("lldd_execute_task returned: %d\n" , res); -ASSIGN_SAS_TASK (cmd,NULL ); -sas_free_task (task); -if (res == -SAS_QUEUE_FULL ) { - cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ - res =0 ; - cmd->scsi_done (cmd); - } - goto out; - } +/* If the device fell off, no sense in issuing commands */ +if (dev->gone) { + cmd->result =DID_BAD_TARGET <<16 ; + goto out_done; } -out: -return res; + +if (dev_is_sata (dev)) { +unsigned long flags; + +spin_lock_irqsave (dev->sata_dev.ap->lock, flags); + res =ata_sas_queuecmd (cmd, dev->sata_dev.ap); +spin_unlock_irqrestore (dev->sata_dev.ap->lock, flags); +return res; + } + + task =sas_create_task (cmd, dev,GFP_ATOMIC ); +if (!task) +return -ENOMEM ; + +/* Queue up, Direct Mode or Task Collector Mode. */ +if (sas_ha->lldd_max_execute_num <2 ) + res = i->dft->lldd_execute_task (task,1 ,GFP_ATOMIC ); +else + res =sas_queue_up (task); + +if (res) + goto out_free_task; +return 0 ; + +out_free_task: +SAS_DPRINTK ("lldd_execute_task returned: %d\n" , res); +ASSIGN_SAS_TASK (cmd,NULL ); +sas_free_task (task); +if (res != -SAS_QUEUE_FULL ) +return res; + cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +out_done: + cmd->scsi_done (cmd); +return 0 ; }static void sas_eh_finish_cmd (struct scsi_cmnd *cmd)
PATCH 3/3 libsas: fix sas_queuecommand return values
In reply to Christoph Hellwig->queuecommand must return either 0, or one of the SCSI_MLQUEUE_* return values. Non-transient errors are indicated by setting cmd->result before calling ->scsi_done and returning 0. Fix libsas to adhere to this calling convention. Note that the DID_ERROR for returns from the low-level driver might not be correct for all cases, but it's the best we can do with the current layering in libsas. I also suspect that the pre-existing handling of -SAS_QUEUE_FULL should really be SCSI_MLQUEUE_HOST_BUSY, but I'll leave that for a separate change.
drivers/scsi/libsas/sas_scsi_host.c +5 -4
@@ -207,7 +207,7 @@ int sas_queuecommand(struct Scsi_Host *h task =sas_create_task (cmd, dev,GFP_ATOMIC );if (!task) -return -ENOMEM ; +return SCSI_MLQUEUE_HOST_BUSY ;/* Queue up, Direct Mode or Task Collector Mode. */ if (sas_ha->lldd_max_execute_num <2 )
@@ -223,9 +223,10 @@ out_free_task:SAS_DPRINTK ("lldd_execute_task returned: %d\n" , res);ASSIGN_SAS_TASK (cmd,NULL );sas_free_task (task); -if (res != -SAS_QUEUE_FULL ) -return res; - cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +if (res = -SAS_QUEUE_FULL ) + cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +else + cmd->result =DID_ERROR <<16 ; out_done: cmd->scsi_done (cmd);return 0 ;
RE: [PATCH 3/3] libsas: fix sas_queuecommand return values
Quoted 27 lines
->queuecommand must return either 0, or one of the SCSI_MLQUEUE_* return values. Non-transient errors are indicated by setting
cmd->resultbefore calling ->scsi_done and returning 0. Fix libsas to adhere to this calling convention. Note that theDID_ERRORfor returns from the low-level driver might not be correct for all cases, but it's the best we can do with the current layering in libsas. I also suspect that the pre-existing handling of -SAS_QUEUE_FULL should really beSCSI_MLQUEUE_HOST_BUSY, but I'll leave that for a separate change.Signed-off-by Christoph Hellwig <[email protected]>Index:
linux-2.6/drivers/scsi/libsas/sas_scsi_host.c
===================================================================
---linux-2.6.orig/drivers/scsi/libsas/sas_scsi_host.c2011-07-11
20:25:25.529428978 +0200
+++linux-2.6/drivers/scsi/libsas/sas_scsi_host.c2011-07-11
20:29:22.321479498 +0200drivers/scsi/libsas/sas_scsi_host.c +1
-1@@ -207,7 +207,7 @@ int sas_queuecommand(struct Scsi_Host *h task =sas_create_task (cmd, dev,GFP_ATOMIC );if (!task) -return -ENOMEM ; +return SCSI_MLQUEUE_HOST_BUSY ;/* Queue up, Direct Mode or Task Collector Mode. */ if (sas_ha->lldd_max_execute_num <2 )
drivers/scsi/libsas/sas_scsi_host.c out_free_task: · line 226
Quoted 7 lines
drivers/scsi/libsas/sas_scsi_host.c +1
-3@@ -223,9 +223,10 @@ out_free_task:SAS_DPRINTK ("lldd_execute_task returned: %d\n" , res);ASSIGN_SAS_TASK (cmd,NULL );sas_free_task (task); -if (res != -SAS_QUEUE_FULL ) -return res; - cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +if (res = -SAS_QUEUE_FULL )
[Jack Wang] Seems you should use res == -SAS_QUEUE_FULL ? I will test the patchset and report result later.
Quoted 7 lines
drivers/scsi/libsas/sas_scsi_host.c +3
-0+ cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ + else + cmd->result = DID_ERROR << 16; out_done: cmd->scsi_done (cmd);return 0 ;
PATCH v2 3/3 libsas: fix sas_queuecommand return values
In reply to Christoph Hellwig->queuecommand must return either 0, or one of the SCSI_MLQUEUE_* return values. Non-transient errors are indicated by setting cmd->result before calling ->scsi_done and returning 0. Fix libsas to adhere to this calling convention. Note that the DID_ERROR for returns from the low-level driver might not be correct for all cases, but it's the best we can do with the current layering in libsas. I also suspect that the pre-existing handling of -SAS_QUEUE_FULL should really be SCSI_MLQUEUE_HOST_BUSY, but I'll leave that for a separate change.
drivers/scsi/libsas/sas_scsi_host.c +5 -4
@@ -207,7 +207,7 @@ int sas_queuecommand(struct Scsi_Host *h task =sas_create_task (cmd, dev,GFP_ATOMIC );if (!task) -return -ENOMEM ; +return SCSI_MLQUEUE_HOST_BUSY ;/* Queue up, Direct Mode or Task Collector Mode. */ if (sas_ha->lldd_max_execute_num <2 )
@@ -223,9 +223,10 @@ out_free_task:SAS_DPRINTK ("lldd_execute_task returned: %d\n" , res);ASSIGN_SAS_TASK (cmd,NULL );sas_free_task (task); -if (res != -SAS_QUEUE_FULL ) -return res; - cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +if (res == -SAS_QUEUE_FULL ) + cmd->result =DID_SOFT_ERROR <<16 ;/* retry */ +else + cmd->result =DID_ERROR <<16 ; out_done: cmd->scsi_done (cmd);return 0 ;
I ran some simple tests (see the recent pm8001 e-mail for specifics) -- fio on each of the patches applied incrementally to libsas. This is only a simple "smoke test" really.
Things seemed to work fine with the patches.
If someone wants some more specific testing, I'm open to running it if you give me the details.
Quoted 10 lines · Christoph Hellwig
Fix up some lose ends in
sas_queuecommandthat I noticed during the isci review. The first two are pretty straight forward, but the third is a bit more nasty and needs some serious review and testing. Note that I could only compile-test the bunch as I don't actually have a SAS controller using libsas.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
ping?
Quoted 9 lines · Christoph Hellwig
Fix up some lose ends in
sas_queuecommandthat I noticed during the isci review. The first two are pretty straight forward, but the third is a bit more nasty and needs some serious review and testing. Note that I could only compile-test the bunch as I don't actually have a SAS controller using libsas.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
---end quoted text---
James Bottomley
maintainerQuoted 1 line · Christoph Hellwig
ping?
It seems to work for me too. I'll put them in scsi misc and see if anyone complains.
James
Christoph, if you want anything more than the basic testing I did, just let me know what you would like done.
David
Quoted 6 lines · James Bottomley
Quoted 1 line · Christoph Hellwig
ping?
It seems to work for me too. I'll put them in scsi misc and see if anyone complains.
Quoted 8 lines
James
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html