mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
- Allocate for each srb its one sense info buffer.
- Reinitialize the transfer size if a retry is necessary in ScsiClassSendSrbSynchronous. svn path=/trunk/; revision=9650
This commit is contained in:
parent
c3e66860e4
commit
b5273a652c
1 changed files with 30 additions and 22 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: class2.c,v 1.53 2004/05/10 18:02:20 gvg Exp $
|
||||
/* $Id: class2.c,v 1.54 2004/06/10 07:56:42 hbirr Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -46,6 +46,11 @@
|
|||
|
||||
#define INQUIRY_DATA_SIZE 2048
|
||||
#define START_UNIT_TIMEOUT 30
|
||||
/*
|
||||
* FIXME:
|
||||
* Create a macro, which rounds up a size value to the next multiple of two.
|
||||
*/
|
||||
#define SENSEINFO_ALIGNMENT 32
|
||||
|
||||
static NTSTATUS STDCALL
|
||||
ScsiClassCreateClose(IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -205,7 +210,7 @@ ScsiClassBuildRequest(IN PDEVICE_OBJECT DeviceObject,
|
|||
Srb->QueueAction = SRB_SIMPLE_TAG_REQUEST;
|
||||
Srb->QueueSortKey = LogicalBlockAddress;
|
||||
|
||||
Srb->SenseInfoBuffer = DeviceExtension->SenseData;
|
||||
Srb->SenseInfoBuffer = (SENSE_DATA*)ROUND_UP((ULONG_PTR)(Srb + 1), SENSEINFO_ALIGNMENT);
|
||||
Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
|
||||
|
||||
Srb->TimeOutValue =
|
||||
|
@ -558,9 +563,9 @@ ScsiClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
Irp));
|
||||
}
|
||||
|
||||
/* Allocate an SRB */
|
||||
Srb = ExAllocatePool (NonPagedPool,
|
||||
sizeof(SCSI_REQUEST_BLOCK));
|
||||
/* Allocate and initialize an SRB */
|
||||
Srb = ExAllocateFromNPagedLookasideList(&DeviceExtension->SrbLookasideListHead);
|
||||
|
||||
if (Srb == NULL)
|
||||
{
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
@ -588,7 +593,9 @@ ScsiClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
DPRINT ("ScsiClassDeviceControl: IOCTL_DISK_CHECK_VERIFY SMALL\n");
|
||||
Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
|
||||
Irp->IoStatus.Information = 0;
|
||||
ExFreePool (Srb);
|
||||
/* Free the SRB */
|
||||
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||
Srb);
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
|
@ -599,10 +606,12 @@ ScsiClassDeviceControl(IN PDEVICE_OBJECT DeviceObject,
|
|||
FALSE);
|
||||
if (SubIrp == NULL)
|
||||
{
|
||||
DPRINT ("ScsiClassDeviceControl: IOCTL_DISK_CHECK_VERIFY NotEnuf\n");
|
||||
DPRINT ("ScsiClassDeviceControl: IOCTL_DISK_CHECK_VERIFY NotEnuf\n");
|
||||
Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
Irp->IoStatus.Information = 0;
|
||||
ExFreePool (Srb);
|
||||
/* Free the SRB */
|
||||
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||
Srb);
|
||||
IoCompleteRequest (Irp,
|
||||
IO_NO_INCREMENT);
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -650,8 +659,9 @@ DPRINT ("ScsiClassDeviceControl: IOCTL_DISK_CHECK_VERIFY SrbAsync\n");
|
|||
default:
|
||||
DPRINT("Unknown device io control code %lx\n",
|
||||
ModifiedControlCode);
|
||||
ExFreePool(Srb);
|
||||
|
||||
/* Free the SRB */
|
||||
ExFreeToNPagedLookasideList(&DeviceExtension->SrbLookasideListHead,
|
||||
Srb);
|
||||
/* Pass the IOCTL down to the port driver */
|
||||
NextStack = IoGetNextIrpStackLocation(Irp);
|
||||
NextStack->Parameters = Stack->Parameters;
|
||||
|
@ -993,7 +1003,7 @@ ScsiClassInitializeSrbLookasideList(IN PDEVICE_EXTENSION DeviceExtension,
|
|||
NULL,
|
||||
NULL,
|
||||
NonPagedPool,
|
||||
sizeof(SCSI_REQUEST_BLOCK),
|
||||
sizeof(SCSI_REQUEST_BLOCK) + sizeof(SENSE_DATA) + SENSEINFO_ALIGNMENT - 1,
|
||||
TAG_SRBT,
|
||||
(USHORT)NumberElements);
|
||||
}
|
||||
|
@ -1720,7 +1730,7 @@ ScsiClassReadDriveCapacity(IN PDEVICE_OBJECT DeviceObject)
|
|||
|
||||
DeviceExtension = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
CapacityBuffer = ExAllocatePool(NonPagedPool,
|
||||
CapacityBuffer = ExAllocatePool(NonPagedPoolCacheAligned,
|
||||
sizeof(READ_CAPACITY_DATA));
|
||||
if (CapacityBuffer == NULL)
|
||||
{
|
||||
|
@ -1925,7 +1935,7 @@ ScsiClassSendSrbAsynchronous(PDEVICE_OBJECT DeviceObject,
|
|||
Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
|
||||
Srb->Cdb[1] |= DeviceExtension->Lun << 5;
|
||||
|
||||
Srb->SenseInfoBuffer = DeviceExtension->SenseData;
|
||||
Srb->SenseInfoBuffer = (SENSE_DATA*)ROUND_UP((ULONG_PTR)(Srb + 1), SENSEINFO_ALIGNMENT);
|
||||
Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
|
||||
|
||||
Srb->DataBuffer = BufferAddress;
|
||||
|
@ -2002,7 +2012,7 @@ ScsiClassSendSrbSynchronous(PDEVICE_OBJECT DeviceObject,
|
|||
ULONG RequestType;
|
||||
BOOLEAN Retry;
|
||||
ULONG RetryCount;
|
||||
PKEVENT Event;
|
||||
KEVENT Event;
|
||||
PIRP Irp;
|
||||
NTSTATUS Status;
|
||||
LARGE_INTEGER RetryWait;
|
||||
|
@ -2044,13 +2054,11 @@ ScsiClassSendSrbSynchronous(PDEVICE_OBJECT DeviceObject,
|
|||
}
|
||||
}
|
||||
|
||||
Srb->DataTransferLength = BufferLength;
|
||||
Srb->DataBuffer = BufferAddress;
|
||||
|
||||
Event = ExAllocatePool(NonPagedPool,
|
||||
sizeof(KEVENT));
|
||||
TryAgain:
|
||||
KeInitializeEvent(Event,
|
||||
Srb->DataTransferLength = BufferLength;
|
||||
KeInitializeEvent(&Event,
|
||||
NotificationEvent,
|
||||
FALSE);
|
||||
|
||||
|
@ -2061,13 +2069,14 @@ TryAgain:
|
|||
BufferAddress,
|
||||
BufferLength,
|
||||
TRUE,
|
||||
Event,
|
||||
&Event,
|
||||
&IoStatusBlock);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
DPRINT("IoBuildDeviceIoControlRequest() failed\n");
|
||||
ExFreePool(Srb->SenseInfoBuffer);
|
||||
ExFreePool(Event);
|
||||
Srb->SenseInfoBuffer = NULL;
|
||||
Srb->SenseInfoBufferLength = 0;
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
|
@ -2081,7 +2090,7 @@ TryAgain:
|
|||
Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(Event,
|
||||
KeWaitForSingleObject(&Event,
|
||||
Suspended,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
|
@ -2123,7 +2132,6 @@ TryAgain:
|
|||
}
|
||||
|
||||
ExFreePool(Srb->SenseInfoBuffer);
|
||||
ExFreePool(Event);
|
||||
|
||||
DPRINT("ScsiClassSendSrbSynchronous() done\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue