Skip to content

Commit 6d0a8b4

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 2cd9088 commit 6d0a8b4

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

viostor/virtio_stor.c

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

489+
adaptExt->action_on_reset = VirtioResetCompleteRequests;
490+
VioStorReadRegistryParameter(DeviceExtension, REGISTRY_ACTION_ON_RESET, FIELD_OFFSET(ADAPTER_EXTENSION, action_on_reset));
491+
489492
ConfigInfo->Master = TRUE;
490493
ConfigInfo->ScatterGather = TRUE;
491494
ConfigInfo->DmaWidth = Width32Bits;
@@ -1193,7 +1196,21 @@ VirtIoStartIo(IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
11931196
case SRB_FUNCTION_RESET_DEVICE:
11941197
case SRB_FUNCTION_RESET_LOGICAL_UNIT:
11951198
{
1196-
CompletePendingRequests(DeviceExtension);
1199+
switch (adaptExt->action_on_reset)
1200+
{
1201+
case VirtioResetCompleteRequests:
1202+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Completing all pending SRBs\n");
1203+
CompletePendingRequests(DeviceExtension);
1204+
break;
1205+
case VirtioResetDoNothing:
1206+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Doing nothing with all pending SRBs\n");
1207+
break;
1208+
case VirtioResetBugCheck:
1209+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Let's bugcheck due to this reset event\n");
1210+
KeBugCheckEx(0xDEADDEAD, (ULONG_PTR)Srb, SRB_PATH_ID(Srb), SRB_TARGET_ID(Srb), SRB_LUN(Srb));
1211+
break;
1212+
}
1213+
11971214
CompleteRequestWithStatus(DeviceExtension, (PSRB_TYPE)Srb, SRB_STATUS_SUCCESS);
11981215
#ifdef DBG
11991216
RhelDbgPrint(TRACE_LEVEL_INFORMATION,
@@ -1415,7 +1432,21 @@ VirtIoResetBus(IN PVOID DeviceExtension, IN ULONG PathId)
14151432
PADAPTER_EXTENSION adaptExt;
14161433
adaptExt = (PADAPTER_EXTENSION)DeviceExtension;
14171434

1418-
CompletePendingRequests(DeviceExtension);
1435+
switch (adaptExt->action_on_reset)
1436+
{
1437+
case VirtioResetCompleteRequests:
1438+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Completing all pending SRBs\n");
1439+
CompletePendingRequests(DeviceExtension);
1440+
break;
1441+
case VirtioResetDoNothing:
1442+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Doing nothing with all pending SRBs\n");
1443+
break;
1444+
case VirtioResetBugCheck:
1445+
RhelDbgPrint(TRACE_LEVEL_INFORMATION, " Let's bugcheck due to this reset event\n");
1446+
KeBugCheckEx(0xDEADDEAD, (ULONG_PTR)DeviceExtension, PathId, (ULONG_PTR)-1, (ULONG_PTR)-1);
1447+
break;
1448+
}
1449+
14191450
return TRUE;
14201451
}
14211452

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
#ifdef DBG
260269
LONG srb_cnt;
261270
LONG inqueue_cnt;

0 commit comments

Comments
 (0)