Skip to content

Commit 436d100

Browse files
author
Martin Drab
committed
[viostor]: Introduce action-on-reset feature from vioscsi
The action-on-reset determines what the driver should do when a bus reset request arrives. It can be configured to: - complete pending requests, - do nothing, - bug check. This feature is already present in vioscsi but not in viostor. Signed-Off-By: Martin Drab <martin.drab@virtuozzo.com>
1 parent 4894602 commit 436d100

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

viostor/virtio_stor.c

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@ VirtIoFindAdapter(IN PVOID DeviceExtension,
487487
adaptExt->slot_number = ConfigInfo->SlotNumber;
488488
adaptExt->dump_mode = IsCrashDumpMode;
489489

490+
adaptExt->action_on_reset = VirtioResetCompleteRequests;
491+
VioStorReadRegistryParameter(DeviceExtension,
492+
REGISTRY_ACTION_ON_RESET,
493+
FIELD_OFFSET(ADAPTER_EXTENSION, action_on_reset));
494+
490495
ConfigInfo->Master = TRUE;
491496
ConfigInfo->ScatterGather = TRUE;
492497
ConfigInfo->DmaWidth = Width32Bits;
@@ -1203,7 +1208,21 @@ VirtIoStartIo(IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
12031208
case SRB_FUNCTION_RESET_DEVICE:
12041209
case SRB_FUNCTION_RESET_LOGICAL_UNIT:
12051210
{
1206-
CompletePendingRequests(DeviceExtension);
1211+
switch (adaptExt->action_on_reset)
1212+
{
1213+
case VirtioResetCompleteRequests:
1214+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Completing all pending SRBs\n");
1215+
CompletePendingRequests(DeviceExtension);
1216+
break;
1217+
case VirtioResetDoNothing:
1218+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Doing nothing with all pending SRBs\n");
1219+
break;
1220+
case VirtioResetBugCheck:
1221+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Let's bugcheck due to this reset event\n");
1222+
KeBugCheckEx(0xDEADDEAD, (ULONG_PTR)Srb, SRB_PATH_ID(Srb), SRB_TARGET_ID(Srb), SRB_LUN(Srb));
1223+
break;
1224+
}
1225+
12071226
CompleteRequestWithStatus(DeviceExtension, (PSRB_TYPE)Srb, SRB_STATUS_SUCCESS);
12081227
#ifdef DBG
12091228
RhelDbgPrint(TRACE_LEVEL_INFORMATION,
@@ -1425,7 +1444,21 @@ VirtIoResetBus(IN PVOID DeviceExtension, IN ULONG PathId)
14251444
PADAPTER_EXTENSION adaptExt;
14261445
adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
14271446

1428-
CompletePendingRequests(DeviceExtension);
1447+
switch (adaptExt->action_on_reset)
1448+
{
1449+
case VirtioResetCompleteRequests:
1450+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Completing all pending SRBs\n");
1451+
CompletePendingRequests(DeviceExtension);
1452+
break;
1453+
case VirtioResetDoNothing:
1454+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Doing nothing with all pending SRBs\n");
1455+
break;
1456+
case VirtioResetBugCheck:
1457+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Let's bugcheck due to this reset event\n");
1458+
KeBugCheckEx(0xDEADDEAD, (ULONG_PTR)DeviceExtension, PathId, (ULONG_PTR)-1, (ULONG_PTR)-1);
1459+
break;
1460+
}
1461+
14291462
return TRUE;
14301463
}
14311464

viostor/virtio_stor.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,18 @@ typedef struct _REQUEST_LIST
206206
ULONG srb_cnt;
207207
} REQUEST_LIST, *PREQUEST_LIST;
208208

209+
#define REGISTRY_ACTION_ON_RESET "VirtioActionOnReset"
210+
211+
typedef enum ACTION_ON_RESET
212+
{
213+
VirtioResetCompleteRequests,
214+
VirtioResetDoNothing,
215+
VirtioResetBugCheck = 0xDEADDEAD,
216+
} ACTION_ON_RESET;
217+
209218
typedef struct _ADAPTER_EXTENSION
210219
{
211220
VirtIODevice vdev;
212-
213221
PVOID pageAllocationVa;
214222
ULONG pageAllocationSize;
215223
ULONG pageOffset;
@@ -256,6 +264,7 @@ typedef struct _ADAPTER_EXTENSION
256264
REQUEST_LIST processing_srbs[MAX_CPU];
257265
BOOLEAN reset_in_progress;
258266
ULONGLONG fw_ver;
267+
ACTION_ON_RESET action_on_reset;
259268
ULONG_PTR last_srb_id;
260269
#ifdef DBG
261270
LONG srb_cnt;

0 commit comments

Comments
 (0)