Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZFS-159: Replace IoQueueWorkItem with taskq dispatch #11

Draft
wants to merge 1 commit into
base: tech-preview-2020
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ZFSin/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <storport.h>
//#include <wdf.h>

#include <sys/zfs_context.h>
#include <sys/wzvol.h>

DRIVER_INITIALIZE DriverEntry;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ZFSin/spl/module/spl/spl-windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ZFSin/zfs/include/sys/wzvol.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions ZFSin/zfs/module/zfs/zfs_windows_zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <wmistr.h>
#include <hbapiwmi.h>
#include <wdf.h>
#include <sys/zfs_context.h>
#include <sys/wzvol.h>

extern PDRIVER_OBJECT WIN_DriverObject;
Expand Down
21 changes: 6 additions & 15 deletions ZFSin/zfs/module/zfs/zfs_windows_zvol_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
//#include <wmistr.h>
//#include <wdf.h>
//#include <hbaapi.h>
#include <sys/zfs_context.h>
#include <sys/wzvol.h>
//#include <sys/wzvolwmi.h>

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -906,7 +908,6 @@ wzvol_GeneralWkRtn(

VOID
bzvol_ReadWriteWkRtn(
__in PVOID pDummy, // Not used.
__in PVOID pWkParms // Parm list pointer.
)
{
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions ZFSin/zfs/module/zfs/zfs_windows_zvol_wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

#include <sys/zfs_context.h>
#include <ntddk.h>
#include <storport.h>
#include <scsiwmi.h>
Expand Down
11 changes: 10 additions & 1 deletion ZFSin/zfs/module/zfs/zvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -2877,6 +2885,7 @@ zvol_fini(void)
mutex_destroy(&zfsdev_state_lock);
#endif
ddi_soft_state_fini(&zfsdev_state);
taskq_destroy(zvol_taskq);
}


Expand All @@ -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);
}
}