win-pvdrivers

view xenvbd_scsiport/xenvbd.h @ 1106:2d392ecdd366

Fix race is xenvbd causing 30 second freeze under high load
author James Harper <james.harper@bendigoit.com.au>
date Tue Nov 11 23:08:11 2014 +1100 (2014-11-11)
parents 27bd2a5a4704
children
line source
1 /*
2 PV Drivers for Windows Xen HVM Domains
4 Copyright (c) 2014, James Harper
5 All rights reserved.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 * Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 * Neither the name of James Harper nor the
15 names of its contributors may be used to endorse or promote products
16 derived from this software without specific prior written permission.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL JAMES HARPER BE LIABLE FOR ANY
22 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
30 #if !defined(_XENVBD_H_)
31 #define _XENVBD_H_
33 #include <ntddk.h>
34 //#include <wdm.h>
35 #include <initguid.h>
36 #define NTSTRSAFE_LIB
37 #include <ntstrsafe.h>
39 #if (NTDDI_VERSION < NTDDI_WINXP) /* srb.h causes warnings under 2K for some reason */
40 #pragma warning(disable:4201) /* nameless struct/union */
41 #pragma warning(disable:4214) /* bit field types other than int */
42 #endif
44 #include <srb.h>
45 #include <scsi.h>
46 #include <ntddscsi.h>
47 #include <ntdddisk.h>
48 #include <stdlib.h>
50 #define __DRIVER_NAME "XenVbd"
52 #include <xen_windows.h>
53 #include <xen_public.h>
54 #include <io/protocols.h>
55 #include <memory.h>
56 #include <event_channel.h>
57 #include <hvm/params.h>
58 #include <hvm/hvm_op.h>
59 #include <io/ring.h>
60 #include <io/blkif.h>
61 #include <io/xenbus.h>
63 #include "..\xenvbd_common\common.h"
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
66 #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
68 #define SHADOW_ID_ID_MASK 0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
69 #define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
71 /* if this is ever increased to more than 1 then we need a way of tracking it properly */
72 #define DUMP_MODE_UNALIGNED_PAGES 1 /* only for unaligned buffer use */
74 #include "common.h"
76 struct {
77 PXENVBD_DEVICE_DATA xvdd;
78 ULONG outstanding;
79 PVOID hypercall_stubs;
80 PSCSI_REQUEST_BLOCK stop_srb;
81 /* this is the size of the buffer to allocate at the end of DeviceExtenstion. It includes an extra PAGE_SIZE-1 bytes to assure that we can always align to PAGE_SIZE */
82 #define UNALIGNED_BUFFER_DATA_SIZE ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1)
83 #define UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE ((DUMP_MODE_UNALIGNED_PAGES + 1) * PAGE_SIZE - 1)
84 /* this has to be right at the end of DeviceExtension */
85 /* can't allocate too much data in dump mode so size DeviceExtensionSize accordingly */
86 UCHAR aligned_buffer_data[1];
87 } typedef XENVBD_SCSIPORT_DATA, *PXENVBD_SCSIPORT_DATA;
89 #endif