win-pvdrivers

changeset 839:e48c6f765e5f 0.11.0.252

Do the right thing on running out of shadow entries. Fix SMP issue (virtual storport does not locking).
author James Harper <james.harper@bendigoit.com.au>
date Thu Feb 03 14:13:00 2011 +1100 (2011-02-03)
parents 37f8c113b006
children c750a369bce5
files xenvbd/xenvbd_storport.c
line diff
     1.1 --- a/xenvbd/xenvbd_storport.c	Wed Feb 02 13:52:01 2011 +1100
     1.2 +++ b/xenvbd/xenvbd_storport.c	Thu Feb 03 14:13:00 2011 +1100
     1.3 @@ -503,7 +503,12 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
     1.4  
     1.5      remaining = block_count * 512;
     1.6      shadow = get_shadow_from_freelist(xvdd);
     1.7 -    ASSERT(shadow);
     1.8 +    if (!shadow)
     1.9 +    {
    1.10 +      /* put the srb back at the start of the queue */
    1.11 +      InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb->SrbExtension);
    1.12 +      return; /* stall the queue */
    1.13 +    }
    1.14      ASSERT(!shadow->aligned_buffer_in_use);
    1.15      ASSERT(!shadow->srb);
    1.16      shadow->req.sector_number = sector_number;
    1.17 @@ -1192,9 +1197,12 @@ static BOOLEAN
    1.18  XenVbd_HandleEvent(PVOID DeviceExtension)
    1.19  {
    1.20    BOOLEAN retval;
    1.21 +  STOR_LOCK_HANDLE lock_handle;
    1.22    
    1.23    //if (dump_mode) FUNCTION_ENTER();
    1.24 +  StorPortAcquireSpinLock(DeviceExtension, StartIoLock, NULL, &lock_handle);
    1.25    retval = StorPortSynchronizeAccess(DeviceExtension, XenVbd_HandleEventSynchronised, NULL);
    1.26 +  StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
    1.27    //if (dump_mode) FUNCTION_EXIT();
    1.28    return retval;
    1.29  }
    1.30 @@ -1221,10 +1229,13 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.31    PXENVBD_DEVICE_DATA xvdd = DeviceExtension;
    1.32    ULONG data_transfer_length;
    1.33    UCHAR srb_status = SRB_STATUS_PENDING;
    1.34 +  STOR_LOCK_HANDLE lock_handle;
    1.35  
    1.36    //if (dump_mode) FUNCTION_ENTER();
    1.37    //if (dump_mode) KdPrint((__DRIVER_NAME "     srb = %p\n", srb));
    1.38  
    1.39 +  StorPortAcquireSpinLock(DeviceExtension, StartIoLock, NULL, &lock_handle);
    1.40 +
    1.41    data_transfer_length = srb->DataTransferLength;
    1.42    
    1.43    if (xvdd->inactive)
    1.44 @@ -1232,6 +1243,7 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.45      KdPrint((__DRIVER_NAME "     Inactive srb->Function = %08X\n", srb->Function));
    1.46      srb->SrbStatus = SRB_STATUS_NO_DEVICE;
    1.47      StorPortNotification(RequestComplete, DeviceExtension, srb);
    1.48 +    StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
    1.49      return TRUE;
    1.50    }
    1.51  
    1.52 @@ -1246,6 +1258,7 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.53      srb->SrbStatus = SRB_STATUS_BUSY;
    1.54      StorPortNotification(RequestComplete, DeviceExtension, srb);
    1.55      KdPrint((__DRIVER_NAME " --- HwStorStartIo (Still figuring out ring)\n"));
    1.56 +    StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
    1.57      return TRUE;
    1.58    }
    1.59  
    1.60 @@ -1255,6 +1268,7 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.61      srb->SrbStatus = SRB_STATUS_BUSY;
    1.62      StorPortNotification(RequestComplete, DeviceExtension, srb);
    1.63      //KdPrint((__DRIVER_NAME " <-- HwStorStartIo (Suspending/Resuming)\n"));
    1.64 +    StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
    1.65      return TRUE;
    1.66    }
    1.67  
    1.68 @@ -1263,6 +1277,7 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.69      srb->SrbStatus = SRB_STATUS_NO_DEVICE;
    1.70      StorPortNotification(RequestComplete, DeviceExtension, srb);
    1.71      KdPrint((__DRIVER_NAME " --- HwStorStartIo (Out of bounds - PathId = %d, TargetId = %d, Lun = %d)\n", srb->PathId, srb->TargetId, srb->Lun));
    1.72 +    StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
    1.73      return TRUE;
    1.74    }
    1.75  
    1.76 @@ -1713,6 +1728,7 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
    1.77    }
    1.78  
    1.79    //if (dump_mode) FUNCTION_EXIT();
    1.80 +  StorPortReleaseSpinLock(DeviceExtension, &lock_handle);
    1.81    return TRUE;
    1.82  }
    1.83