Condividi tramite


Routine ReleaseQueue del driver della classe di archiviazione

Unless a storage class driver ORs the SrbFlags for a given request with SRB_FLAGS_NO_QUEUE_FREEZE, the system port driver freezes a queue for a given logical unit after any of the following:

  • Si è verificato un ripristino del bus durante l'esecuzione di una richiesta da parte dell'unità logica.

  • The logical unit returned SCSISTAT_CHECK_CONDITION or SCSISTAT_COMMAND_TERMINATED, which the class driver can find in the SRB's ScsiStatus member.

  • Timeout di una richiesta.

  • Una richiesta è stata terminata da un comando di messaggio del bus, ad esempio SCSIMESS_ABORT.

The port driver indicates that an LU-specific queue has been frozen by returning a request with SRB_STATUS_QUEUE_FROZEN in the SrbStatus member. È possibile inserire nuove richieste dal driver di classe nella coda, ma solo le richieste autosense vengono inviate all'unità logica purché la coda sia bloccata.

Il blocco della coda in queste condizioni offre a ogni driver della classe di archiviazione l'opportunità di analizzare un errore prima dell'esecuzione di altri processi in coda. Ad esempio, potrebbe essere necessario annullare i processi in coda se il supporto è stato modificato. To flush the queue, the driver can send a request with the SrbFlags ORed with SRB_FLAGS_BYPASS_FROZEN_QUEUE.

A ReleaseQueue routine allocates and sets up an IRP and an SRB to either release or flush a frozen queue. The Function member of the SRB must be set to SRB_FUNCTION_RELEASE_QUEUE or SRB_FUNCTION_FLUSH_QUEUE, which both releases a frozen queue and cancels all currently queued requests for the target logical unit. The port driver completes all requests in a flushed queue with their SrbStatus members set to SRB_STATUS_REQUEST_FLUSHED.

Failing to release a frozen queue makes the device inaccessible, so a driver's ReleaseQueue routine should be designed to succeed even in low memory conditions. A ReleaseQueue routine should first attempt to allocate memory for an SRB by calling ExAllocatePool with the NonPagedPool memory type and, if that allocation fails, use an SRB that was preallocated during driver initialization. Se il driver alloca un SRB da riservare quando inizializza l'estensione del dispositivo, come descritto in Configurazione dell'estensione del dispositivo di un driver di classe di archiviazione, releaseQueue può usare tale SRB se il pool di memoria è basso, con un meccanismo di sincronizzazione appropriato nel caso in cui potrebbero essere necessarie più operazioni di rilascio simultanee.

Note that a class driver's ReleaseQueue routine is called asynchronously, generally from its IoCompletion routine. A class driver's IoCompletion routine cannot call ReleaseQueue to flush a queue that is not frozen. However, it can call ReleaseQueue to release an unfrozen queue, and the port driver simply ignores such a request.