>> I use interlock to list the pending io. And when the second event
> occurs,I create a system thread to process the io in the list
I don’t know if you mean this literally - but if you are really creating
the thread to service each request - you should consider a thread pool
(or maybe just a single thread if you are really serializing). Spinning
up a thread is a somewhat expensive operation and will most definitely
hurt your throughput.
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Tuesday, December 30, 2003 3:26 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Pending specified file io makes system slow
Yes, you should set cancel routines whenever you pend IO operations.
Based on your description you should use cancel safe queue routines
provided in the kernel. Look at IoCsqInitializeEx() in the latest
IfsKit documentation to see how to use them. If you decide to do your
own cancel processing (which I would not recommend) be sure and read the
section on “Canceling IRPs” in the IFSkit documentation because a lot of
people don’t do it correctly.
It is not safe to pend paging IOs, this will cause deadlocks.
Looking at your code, it is fine to check Irp->Cancel but there is no
reason to call IoSetCancelRoutine() and set a NULL value. You will
never be given an IRP that has a non-null cancel routine. Cancel
routines can only be set while a driver “owns” the IRP. The cancel
routine MUST be removed before passing the IRP to another driver or
completing the IRP. Adding an ASSERT to verify that the field is NULL
would be a reasonable thing to do.
The performance impact of what you are doing is going to be based on
what percentage of IOs you pend and how long you pend them for.
Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ming
Sent: Monday, December 29, 2003 7:29 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] Pending specified file io makes system slow
Thank u.
All my want to do is :
1.When a specified event occurs, I pend CREATE/READ/WRITE io of some
defined
files/folder.
2.When another event occurs, process the pending io.
I use interlock to list the pending io. And when the second event
occurs,I
create a system thread
to process the io in the list. Use this api:ExInterlockedRemoveHeadList
to
get the irp, and call
the corresponding irp dispatch routine which is defined in DriverEntry.
Yes, I am serializing all read and write io of the list.
And there is a question: Must a set a cancel routine for the irp?
Here is some pieces of code :(referenced from ddk sample of FloopyDisk
Driver)
Queuing Irp:
//
// Check if the irp was already canceled
//
if ( (Irp->Cancel ) &&
(IoSetCancelRoutine(Irp, NULL)))
{
//
// Already canceled
//
Irp->IoStatus.Status = STATUS_CANCELLED;
Irp->IoStatus.Information = 0;
KeReleaseSpinLock(&CancelQueueSpinLock,oldIrql);
IoCompleteRequest( Irp, IO_NO_INCREMENT );
Status = STATUS_CANCELLED;
} else {
//
// Queue the Irp
//
Irp->IoStatus.Status = STATUS_PENDING;
IoMarkIrpPending(Irp);
ExInterlockedInsertTailList( &RequestQueue,
&Irp->Tail.Overlay.ListEntry,
&RequestQueueSpinLock);
KeReleaseSpinLock(&CancelQueueSpinLock,oldIrql);
Status = STATUS_PENDING;
}
//////////////////////////////////////////////////////
Processing the Queued Irps:
…
…
while(
(
headOfList =
ExInterlockedRemoveHeadList(&RequestQueue,&RequestQueueSpinLock)
)
!= NULL)
{
currentIrp = CONTAINING_RECORD( headOfList,
IRP,
Tail.Overlay.ListEntry);
if (IoSetCancelRoutine( currentIrp, NULL)) {
irpSp = IoGetCurrentIrpStackLocation( currentIrp );
} else {
//
// Cancel routine is already running for this IRP.
// Set the IRP field so that it won’t be removed
// in the cancel routine again.
//
currentIrp->Tail.Overlay.ListEntry.Flink = NULL;
currentIrp = NULL;
}
KeReleaseSpinLock(&CancelQueueSpinLock,
oldIrql);
}
if (currentIrp) {
switch ( irpSp->MajorFunction ) {
case IRP_MJ_READ:
(VOID)MyRead(irpSp->DeviceObject,currentIrp);
break;
case IRP_MJ_WRITE:
(VOID)MyWrite(irpSp->DeviceObject,currentIrp);
break;
case IRP_MJ_CREATE:
(VOID)MyCreate(irpSp->DeviceObject,currentIrp);
break;
case IRP_MJ_SET_INFORMATION:
(VOID)MySetInformation(irpSp->DeviceObject,currentIrp);
break;
case IRP_MJ_DEVICE_CONTROL:
(VOID)DevIoCtrl(irpSp->DeviceObject,currentIrp);
break;
case IRP_MJ_FILE_SYSTEM_CONTROL:
(VOID)SfFsControl(irpSp->DeviceObject,currentIrp);
default:
currentIrp->IoStatus.Information = 0;
currentIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
IoCompleteRequest (currentIrp, IO_NO_INCREMENT);
}
}
KeAcquireSpinLock(&CancelQueueSpinLock,
&oldIrql);
}
“Neal Christiansen” Wrote
news:xxxxx@ntfsd…
It sounds to me like you are serializing all read and write operations
in the system. This is a very bad idea and will degrade system
performance. I recommend that you describe what you are trying to
accomplish so that we can suggest a more efficient way of doing it.
Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ming
Sent: Monday, December 29, 2003 3:52 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Pending specified file io makes system slow
I’ve implenmented pending the io of files those are in a specified
folder.
When pending, the whole system runs slow.
I pend MJ_CREATE/READ/WRITE. put the io into a list(provided by system).
Is there any way makes better performance?
–
No one knows what tomorrow would be,
but I’ll do my best.
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
—
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@exagrid.com
To unsubscribe send a blank email to xxxxx@lists.osr.com