diff --git a/ZFSin/driver.c b/ZFSin/driver.c index dfc740ee..153cf197 100644 --- a/ZFSin/driver.c +++ b/ZFSin/driver.c @@ -5,6 +5,7 @@ #include //#include +#include #include #include "Trace.h" @@ -95,7 +96,6 @@ NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING pRe } //extern unsigned long spl_hostid; -extern int random_get_bytes(void *ptr, unsigned long len); void spl_create_hostid(HANDLE h, PUNICODE_STRING pRegistryPath) { diff --git a/ZFSin/zfs/include/sys/wzvol.h b/ZFSin/zfs/include/sys/wzvol.h index a45ae827..4cfa318b 100644 --- a/ZFSin/zfs/include/sys/wzvol.h +++ b/ZFSin/zfs/include/sys/wzvol.h @@ -216,6 +216,7 @@ typedef struct _MP_WorkRtnParms { PEPROCESS pReqProcess; MpWkRtnAction Action; ULONG SecondsToDelay; + taskq_ent_t ent; CHAR pQueueWorkItem[1]; // IO_WORKITEM structure: keep at the end of this block (dynamically allocated). } MP_WorkRtnParms, *pMP_WorkRtnParms; diff --git a/ZFSin/zfs/module/zfs/zfs_windows_zvol.c b/ZFSin/zfs/module/zfs/zfs_windows_zvol.c index 74508b9d..1e8f6588 100644 --- a/ZFSin/zfs/module/zfs/zfs_windows_zvol.c +++ b/ZFSin/zfs/module/zfs/zfs_windows_zvol.c @@ -28,6 +28,7 @@ #include #include #include +#include #include extern PDRIVER_OBJECT WIN_DriverObject; diff --git a/ZFSin/zfs/module/zfs/zfs_windows_zvol_scsi.c b/ZFSin/zfs/module/zfs/zfs_windows_zvol_scsi.c index b7f0d41b..0bf8df99 100644 --- a/ZFSin/zfs/module/zfs/zfs_windows_zvol_scsi.c +++ b/ZFSin/zfs/module/zfs/zfs_windows_zvol_scsi.c @@ -45,6 +45,7 @@ //#include //#include //#include +#include #include //#include @@ -93,6 +94,7 @@ * when the refcnt reaches 0 it is safe to free the remove lock cb. */ extern wzvolDriverInfo STOR_wzvolDriverInfo; +extern taskq_t *storport_taskq; inline int resolveArrayIndex(int t, int l, int nbL) { return (t * nbL) + l; } static inline void wzvol_decref_target(wzvolContext* zvc) @@ -669,6 +671,21 @@ ScsiOpWrite( return status; } // End ScsiOpWrite. +VOID +wzvol_TaskQueuingWkRtn( + __in PVOID pDummy, // Not used. + __in PVOID pWkParms // Parm list pointer. +) +{ + pMP_WorkRtnParms pWkRtnParms = (pMP_WorkRtnParms)pWkParms; + + UNREFERENCED_PARAMETER(pDummy); + IoUninitializeWorkItem((PIO_WORKITEM)pWkRtnParms->pQueueWorkItem); + + taskq_init_ent(&pWkRtnParms->ent); + taskq_dispatch_ent(storport_taskq, wzvol_WkRtn, pWkRtnParms, 0, &pWkRtnParms->ent); +} + /**************************************************************************************************/ /* */ /* This routine does the setup for reading or writing. The reading/writing could be effected */ @@ -714,7 +731,7 @@ ScsiReadWriteSetup( // Queue work item, which will run in the System process. - IoQueueWorkItem((PIO_WORKITEM)pWkRtnParms->pQueueWorkItem, wzvol_GeneralWkRtn, DelayedWorkQueue, pWkRtnParms); + IoQueueWorkItem((PIO_WORKITEM)pWkRtnParms->pQueueWorkItem, wzvol_TaskQueuingWkRtn, DelayedWorkQueue, pWkRtnParms); *pResult = ResultQueued; // Indicate queuing. diff --git a/ZFSin/zfs/module/zfs/zfs_windows_zvol_wmi.c b/ZFSin/zfs/module/zfs/zfs_windows_zvol_wmi.c index ee3d1f52..0c0547b4 100644 --- a/ZFSin/zfs/module/zfs/zfs_windows_zvol_wmi.c +++ b/ZFSin/zfs/module/zfs/zfs_windows_zvol_wmi.c @@ -22,6 +22,7 @@ * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. \***************************************************************************/ +#include #include #include #include diff --git a/ZFSin/zfs/module/zfs/zvol.c b/ZFSin/zfs/module/zfs/zvol.c index 076b5c38..d2f54337 100644 --- a/ZFSin/zfs/module/zfs/zvol.c +++ b/ZFSin/zfs/module/zfs/zvol.c @@ -90,9 +90,11 @@ #include "zfs_namecheck.h" +unsigned int zvol_threads = 32; uint64_t zvol_inhibit_dev = 0; dev_info_t zfs_dip_real = { 0 }; dev_info_t *zfs_dip = &zfs_dip_real; +taskq_t *storport_taskq; extern int zfs_major; extern int zfs_bmajor; @@ -2840,7 +2842,13 @@ zvol_busy(void) int zvol_init(void) { + int threads = MIN(MAX(zvol_threads, 1), 1024); + dprintf("zvol_init\n"); + storport_taskq = taskq_create(ZVOL_DRIVER, threads, maxclsyspri, + threads * 2, INT_MAX, 0); + if (storport_taskq == NULL) + return (-ENOMEM); VERIFY(ddi_soft_state_init(&zfsdev_state, sizeof (zfs_soft_state_t), 1) == 0); #ifdef illumos @@ -2858,4 +2866,5 @@ zvol_fini(void) mutex_destroy(&zfsdev_state_lock); #endif ddi_soft_state_fini(&zfsdev_state); + taskq_destroy(storport_taskq); }