win-pvdrivers

changeset 876:7ec9138621d6

Fix a crash in dump mode where requests from pre-dump mode were still confusing dump mode if they arrived after the dump had started writing.
author James Harper <james.harper@bendigoit.com.au>
date Mon Mar 14 16:06:35 2011 +1100 (2011-03-14)
parents 8d7560d67376
children 254b8424e23b
files xenvbd/xenvbd_scsiport.c xenvbd/xenvbd_scsiport.h
line diff
     1.1 --- a/xenvbd/xenvbd_scsiport.c	Sun Mar 13 10:13:35 2011 +1100
     1.2 +++ b/xenvbd/xenvbd_scsiport.c	Mon Mar 14 16:06:35 2011 +1100
     1.3 @@ -75,7 +75,7 @@ get_shadow_from_freelist(PXENVBD_DEVICE_
     1.4  static VOID
     1.5  put_shadow_on_freelist(PXENVBD_DEVICE_DATA xvdd, blkif_shadow_t *shadow)
     1.6  {
     1.7 -  xvdd->shadow_free_list[xvdd->shadow_free] = (USHORT)shadow->req.id;
     1.8 +  xvdd->shadow_free_list[xvdd->shadow_free] = (USHORT)(shadow->req.id & SHADOW_ID_ID_MASK);
     1.9    shadow->srb = NULL;
    1.10    shadow->reset = FALSE;
    1.11    xvdd->shadow_free++;
    1.12 @@ -277,6 +277,9 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
    1.13      for (i = 0; i < SHADOW_ENTRIES; i++)
    1.14      {
    1.15        xvdd->shadows[i].req.id = i;
    1.16 +      /* make sure leftover real requests's are never confused with dump mode requests */
    1.17 +      if (dump_mode)
    1.18 +        xvdd->shadows[i].req.id |= SHADOW_ID_DUMP_FLAG;
    1.19        put_shadow_on_freelist(xvdd, &xvdd->shadows[i]);
    1.20        if (dump_mode)
    1.21        {
    1.22 @@ -1013,11 +1016,15 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.23          ScsiPortNotification(NextRequest, DeviceExtension);
    1.24          break;
    1.25        case RING_DETECT_STATE_COMPLETE:
    1.26 -        shadow = &xvdd->shadows[rep->id];
    1.27 +        shadow = &xvdd->shadows[rep->id & SHADOW_ID_ID_MASK];
    1.28          if (shadow->reset)
    1.29          {
    1.30            KdPrint((__DRIVER_NAME "     discarding reset shadow\n"));
    1.31          }
    1.32 +        else if (dump_mode && !(rep->id & SHADOW_ID_DUMP_FLAG))
    1.33 +        {
    1.34 +          KdPrint((__DRIVER_NAME "     discarding stale (non-dump-mode) shadow\n"));
    1.35 +        }
    1.36          else
    1.37          {
    1.38            srb = shadow->srb;
     2.1 --- a/xenvbd/xenvbd_scsiport.h	Sun Mar 13 10:13:35 2011 +1100
     2.2 +++ b/xenvbd/xenvbd_scsiport.h	Mon Mar 14 16:06:35 2011 +1100
     2.3 @@ -94,7 +94,10 @@ typedef struct {
     2.4    #endif
     2.5  } blkif_shadow_t;
     2.6  
     2.7 -#define MAX_SHADOW_ENTRIES 64
     2.8 +#define MAX_SHADOW_ENTRIES  64
     2.9 +#define SHADOW_ID_ID_MASK   0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
    2.10 +#define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
    2.11 +
    2.12  #define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, min(BLK_RING_SIZE, BLK_OTHER_RING_SIZE))
    2.13  
    2.14  typedef enum {