diff --git a/ZFSin/driver.c b/ZFSin/driver.c index 71c09fe7..dbc33254 100644 --- a/ZFSin/driver.c +++ b/ZFSin/driver.c @@ -5,6 +5,7 @@ #include //#include +#include #include DRIVER_INITIALIZE DriverEntry; @@ -91,9 +92,6 @@ NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING pRe return STATUS_SUCCESS; } -//extern unsigned long spl_hostid; -extern int random_get_bytes(void *ptr, unsigned long len); - void spl_create_hostid(HANDLE h, PUNICODE_STRING pRegistryPath) { NTSTATUS Status; diff --git a/ZFSin/spl/module/spl/spl-windows.c b/ZFSin/spl/module/spl/spl-windows.c index 03fff797..455a1306 100644 --- a/ZFSin/spl/module/spl/spl-windows.c +++ b/ZFSin/spl/module/spl/spl-windows.c @@ -75,7 +75,7 @@ extern uint64_t segkmem_total_mem_allocated; #define MAXHOSTNAMELEN 64 extern char hostname[MAXHOSTNAMELEN]; -uint32_t spl_hostid = 0; +uint8_t spl_hostid = 0; /* * Solaris delay is in ticks (hz) and Windows in 100 nanosecs diff --git a/ZFSin/zfs/include/sys/wzvol.h b/ZFSin/zfs/include/sys/wzvol.h index 5bdd91e6..b79cc87f 100644 --- a/ZFSin/zfs/include/sys/wzvol.h +++ b/ZFSin/zfs/include/sys/wzvol.h @@ -221,6 +221,7 @@ typedef struct _MP_WorkRtnParms { /* ZFS ZVOLDI */ void* zv; zfsiodesc_t ioDesc; + 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 c79b3a84..96bb150e 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 *zvol_taskq; inline int resolveArrayIndex(int t, int l, int nbL) { return (t * nbL) + l; } static inline void wzvol_decref_target(wzvolContext* zvc) @@ -906,7 +908,6 @@ wzvol_GeneralWkRtn( VOID bzvol_ReadWriteWkRtn( - __in PVOID pDummy, // Not used. __in PVOID pWkParms // Parm list pointer. ) { @@ -916,9 +917,6 @@ bzvol_ReadWriteWkRtn( uio_t* uio = pWkRtnParms->pUio; int iores; - UNREFERENCED_PARAMETER(pDummy); - IoUninitializeWorkItem((PIO_WORKITEM)pWkRtnParms->pQueueWorkItem); - /* Call ZFS to read/write data */ if (ActionRead == pWkRtnParms->Action) { iores = zvol_read(pWkRtnParms->zv, uio); @@ -931,7 +929,7 @@ bzvol_ReadWriteWkRtn( pIo->Cb(pIo, iores == 0 ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL, TRUE); } uio_free(uio); - ExFreePoolWithTag(pWkRtnParms, MP_TAG_GENERAL); + kmem_free(pWkRtnParms, sizeof(MP_WorkRtnParms)); } NTSTATUS @@ -955,21 +953,14 @@ DiReadWriteSetup( if (pIo->Flags & ZFSZVOLFG_AlwaysPend) { pMP_WorkRtnParms pWkRtnParms = NULL; - pWkRtnParms = (pMP_WorkRtnParms)ExAllocatePoolWithTag(NonPagedPool, sizeof(MP_WorkRtnParms)+IoSizeofWorkItem(), MP_TAG_GENERAL); - if (NULL == pWkRtnParms) { - uio_free(uio); - return STATUS_INSUFFICIENT_RESOURCES; - } - + pWkRtnParms = kmem_alloc(sizeof (MP_WorkRtnParms), KM_SLEEP); RtlZeroMemory(pWkRtnParms, sizeof(MP_WorkRtnParms)); pWkRtnParms->ioDesc = *pIo; pWkRtnParms->pUio = uio; pWkRtnParms->zv = zv; pWkRtnParms->Action = action; - extern PDEVICE_OBJECT ioctlDeviceObject; - IoInitializeWorkItem(ioctlDeviceObject, (PIO_WORKITEM)pWkRtnParms->pQueueWorkItem); - - IoQueueWorkItem((PIO_WORKITEM)pWkRtnParms->pQueueWorkItem, bzvol_ReadWriteWkRtn, DelayedWorkQueue, pWkRtnParms); + taskq_init_ent(&pWkRtnParms->ent); + taskq_dispatch_ent(zvol_taskq, bzvol_ReadWriteWkRtn, pWkRtnParms, 0, &pWkRtnParms->ent); return STATUS_PENDING; // queued up. } else { 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 ab290a2b..55e5a3c2 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 *zvol_taskq; extern int zfs_major; extern int zfs_bmajor; @@ -2859,7 +2861,13 @@ zvol_busy(void) int zvol_init(void) { + int threads = MIN(MAX(zvol_threads, 1), 1024); + dprintf("zvol_init\n"); + zvol_taskq = taskq_create(ZVOL_DRIVER, threads, maxclsyspri, + threads * 2, INT_MAX, 0); + if (zvol_taskq == NULL) + return (-ENOMEM); VERIFY(ddi_soft_state_init(&zfsdev_state, sizeof (zfs_soft_state_t), 1) == 0); #ifdef illumos @@ -2877,6 +2885,7 @@ zvol_fini(void) mutex_destroy(&zfsdev_state_lock); #endif ddi_soft_state_fini(&zfsdev_state); + taskq_destroy(zvol_taskq); } @@ -2895,4 +2904,4 @@ void DecZvolRef(PVOID Context) { mutex_enter(&zfsdev_state_lock); atomic_dec_32(&zv->zv_total_opens); mutex_exit(&zfsdev_state_lock); -} \ No newline at end of file +}