public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Salyzyn, Mark" <mark_salyzyn@adaptec.com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH] aacraid: add SCSI SYNCHONIZE_CACHE range checking (take 2)
Date: Wed, 20 Jun 2007 11:30:43 -0400	[thread overview]
Message-ID: <AE4F746F2AECFC4DA4AADD66A1DFEF01B22F75@otce2k301.adaptec.com> (raw)
In-Reply-To: <AE4F746F2AECFC4DA4AADD66A1DFEF01A55E7E@otce2k301.adaptec.com>

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

There was some overlap with another patch (?) this one has not shown in
scsi-pending-2.6. Modernized to apply cleanly and did some extra
cleanup.

This attached patch is against current scsi-misc-2.6

ObligatoryDisclaimer: Please accept my condolences regarding Outlook's
handling of patch attachments.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>

 drivers/scsi/aacraid/aachba.c |   63
++++++++++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 8 deletions(-)

Sincerely -- Mark Salyzyn

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org 
> [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Salyzyn, Mark
> Sent: Thursday, June 07, 2007 1:21 PM
> To: linux-scsi@vger.kernel.org
> Subject: [PATCH] aacraid: add SCSI SYNCHONIZE_CACHE range checking. 
> 
> 
> Customer running an application that issues SYNCHRONIZE_CACHE calls
> directly noticed the broad stroke of the current implementation in the
> aacraid driver resulting in multiple applications feeding I/O to the
> storage causing the issuing application to stall for long periods of
> time. By only waiting for the current WRITE commands, rather than all
> commands, to complete; and those that are in range of the
> SYNCHRONIZE_CACHE call that would associate more tightly with the
> issuing application before telling the Firmware to flush it's dirty
> cache, we managed to reduce the stalling. The Firmware itself still
> flushes all the dirty cache associated with the array ignoring the
> range, it just does so in a more timely manner.
> 
> This attached patch is against current scsi-misc-2.6
> 
> ObligatoryDisclaimer: Please accept my condolences regarding Outlook's
> handling of patch attachments.
> 
> Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
> 
> Sincerely -- Mark Salyzyn
> 

[-- Attachment #2: aacraid_synch_range2.patch --]
[-- Type: application/octet-stream, Size: 3893 bytes --]

diff -ru a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
--- a/drivers/scsi/aacraid/aachba.c	2007-06-20 11:05:47.673609233 -0400
+++ b/drivers/scsi/aacraid/aachba.c	2007-06-20 11:21:33.655053285 -0400
@@ -1595,23 +1595,23 @@
 	if (!aac_valid_context(cmd, fibptr))
 		return;
 
-	dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n", 
+	dprintk((KERN_DEBUG "synchronize_callback[cpu %d]: t = %ld.\n",
 				smp_processor_id(), jiffies));
 	BUG_ON(fibptr == NULL);
 
 
 	synchronizereply = fib_data(fibptr);
 	if (le32_to_cpu(synchronizereply->status) == CT_OK)
-		cmd->result = DID_OK << 16 | 
+		cmd->result = DID_OK << 16 |
 			COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
 	else {
 		struct scsi_device *sdev = cmd->device;
 		struct aac_dev *dev = fibptr->dev;
 		u32 cid = sdev_id(sdev);
-		printk(KERN_WARNING 
+		printk(KERN_WARNING
 		     "synchronize_callback: synchronize failed, status = %d\n",
 		     le32_to_cpu(synchronizereply->status));
-		cmd->result = DID_OK << 16 | 
+		cmd->result = DID_OK << 16 |
 			COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
 		set_sense((u8 *)&dev->fsa_dev[cid].sense_data,
 				    HARDWARE_ERROR,
@@ -1619,7 +1619,7 @@
 				    ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
 				    0, 0);
 		memcpy(cmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
-		  min(sizeof(dev->fsa_dev[cid].sense_data), 
+		  min(sizeof(dev->fsa_dev[cid].sense_data),
 			  sizeof(cmd->sense_buffer)));
 	}
 
@@ -1637,6 +1637,9 @@
 	struct scsi_device *sdev = scsicmd->device;
 	int active = 0;
 	struct aac_dev *aac;
+	u64 lba = ((u64)scsicmd->cmnd[2] << 24) | (scsicmd->cmnd[3] << 16) |
+		(scsicmd->cmnd[4] << 8) | scsicmd->cmnd[5];
+	u32 count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
 	unsigned long flags;
 
 	/*
@@ -1645,7 +1648,51 @@
 	 */
 	spin_lock_irqsave(&sdev->list_lock, flags);
 	list_for_each_entry(cmd, &sdev->cmd_list, list)
-		if (cmd != scsicmd && cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
+		if (cmd->SCp.phase == AAC_OWNER_FIRMWARE) {
+			u64 cmnd_lba;
+			u32 cmnd_count;
+
+			if (cmd->cmnd[0] == WRITE_6) {
+				cmnd_lba = ((cmd->cmnd[1] & 0x1F) << 16) |
+					(cmd->cmnd[2] << 8) |
+					cmd->cmnd[3];
+				cmnd_count = cmd->cmnd[4];
+				if (cmnd_count == 0)
+					cmnd_count = 256;
+			} else if (cmd->cmnd[0] == WRITE_16) {
+				cmnd_lba = ((u64)cmd->cmnd[2] << 56) |
+					((u64)cmd->cmnd[3] << 48) |
+					((u64)cmd->cmnd[4] << 40) |
+					((u64)cmd->cmnd[5] << 32) |
+					((u64)cmd->cmnd[6] << 24) |
+					(cmd->cmnd[7] << 16) |
+					(cmd->cmnd[8] << 8) |
+					cmd->cmnd[9];
+				cmnd_count = (cmd->cmnd[10] << 24) |
+					(cmd->cmnd[11] << 16) |
+					(cmd->cmnd[12] << 8) |
+					cmd->cmnd[13];
+			} else if (cmd->cmnd[0] == WRITE_12) {
+				cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
+					(cmd->cmnd[3] << 16) |
+					(cmd->cmnd[4] << 8) |
+					cmd->cmnd[5];
+				cmnd_count = (cmd->cmnd[6] << 24) |
+					(cmd->cmnd[7] << 16) |
+					(cmd->cmnd[8] << 8) |
+					cmd->cmnd[9];
+			} else if (cmd->cmnd[0] == WRITE_10) {
+				cmnd_lba = ((u64)cmd->cmnd[2] << 24) |
+					(cmd->cmnd[3] << 16) |
+					(cmd->cmnd[4] << 8) |
+					cmd->cmnd[5];
+				cmnd_count = (cmd->cmnd[7] << 8) |
+					cmd->cmnd[8];
+			} else
+				continue;
+			if (((cmnd_lba + cmnd_count) < lba) ||
+			  (count && ((lba + count) < cmnd_lba)))
+				continue;
 			++active;
 			break;
 		}
@@ -1674,7 +1721,7 @@
 	synchronizecmd->command = cpu_to_le32(VM_ContainerConfig);
 	synchronizecmd->type = cpu_to_le32(CT_FLUSH_CACHE);
 	synchronizecmd->cid = cpu_to_le32(scmd_id(scsicmd));
-	synchronizecmd->count = 
+	synchronizecmd->count =
 	     cpu_to_le32(sizeof(((struct aac_synchronize_reply *)NULL)->data));
 
 	/*
@@ -1696,7 +1743,7 @@
 		return 0;
 	}
 
-	printk(KERN_WARNING 
+	printk(KERN_WARNING
 		"aac_synchronize: aac_fib_send failed with status: %d.\n", status);
 	aac_fib_complete(cmd_fibcontext);
 	aac_fib_free(cmd_fibcontext);

  parent reply	other threads:[~2007-06-20 15:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <86802c440705291859y39a4ca27uf5ddb84810f33510@mail.gmail.com>
2007-05-30  2:13 ` kexec and aacraid broken Andrew Morton
2007-05-30 11:44   ` Salyzyn, Mark
2007-05-30 13:24     ` Vivek Goyal
2007-05-30 13:57       ` Salyzyn, Mark
2007-05-30 14:17         ` Vivek Goyal
2007-05-30 14:30           ` Salyzyn, Mark
2007-05-30 15:59             ` [PATCH] aacraid: fix shutdown handler to also disable interrupts Salyzyn, Mark
2007-05-30 17:36               ` Yinghai Lu
2007-06-01 11:08               ` Vivek Goyal
2007-06-01 17:07                 ` Yinghai Lu
2007-06-01 17:34                   ` Salyzyn, Mark
2007-06-07 17:21               ` [PATCH] aacraid: add SCSI SYNCHONIZE_CACHE range checking Salyzyn, Mark
2007-06-11 20:17                 ` [PATCH] aacraid: probe related code cleanup Salyzyn, Mark
2007-06-20 15:30                 ` Salyzyn, Mark [this message]
2007-07-09 13:57                   ` [PATCH] aacraid: add 51245, 51645 and 52245 adapters to documentation Salyzyn, Mark
2007-07-23 14:13                     ` [PATCH] aacraid: sysfs adapter reset/status format change Salyzyn, Mark
2007-07-26 18:20                       ` [PATCH 1/1] aacraid: draw line in sand, sundry cleanup and version update Salyzyn, Mark
2007-07-27 14:29                         ` [PATCH 1/1] aacraid: fix Sunrise Lake reset handling Salyzyn, Mark
2007-08-02 19:38                           ` [PATCH 1/1] aacraid: prevent panic on adapter resource failure Salyzyn, Mark
2007-08-07 19:36                             ` [PATCH 1/1] aacraid: default timeout for arrays too short Salyzyn, Mark
2007-09-04 16:55                               ` [PATCH 1/1] aacraid: Add documentation for new Adaptec, SMC and SUN cards Salyzyn, Mark
2007-05-30 21:19             ` kexec and aacraid broken Yinghai Lu
2007-05-30 21:22     ` Yinghai Lu
2007-05-30 21:49       ` Salyzyn, Mark
2007-05-30 22:11         ` Yinghai Lu
2007-05-31 12:37           ` Salyzyn, Mark
2007-05-31 19:59             ` Yinghai Lu
2007-05-31 20:45               ` Salyzyn, Mark
2007-07-27 13:48 [PATCH] aacraid: add SCSI SYNCHONIZE_CACHE range checking (take 2) Salyzyn, Mark

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=AE4F746F2AECFC4DA4AADD66A1DFEF01B22F75@otce2k301.adaptec.com \
    --to=mark_salyzyn@adaptec.com \
    --cc=linux-scsi@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