win-pvdrivers

changeset 1032:306c10cdcba1

Added online resize. Untested under storport yet (>= Vista)
author James Harper <james.harper@bendigoit.com.au>
date Sun Mar 03 12:19:31 2013 +1100 (2013-03-03)
parents 329b9b9d47ec
children cb767700f91c
files xenvbd_common/common_miniport.h xenvbd_common/common_xen.h xenvbd_scsiport/common.h xenvbd_scsiport/xenvbd.c xenvbd_storport/xenvbd.h
line diff
     1.1 --- a/xenvbd_common/common_miniport.h	Thu Feb 21 20:37:38 2013 +1100
     1.2 +++ b/xenvbd_common/common_miniport.h	Sun Mar 03 12:19:31 2013 +1100
     1.3 @@ -681,6 +681,14 @@ XenVbd_ProcessSrbList(PXENVBD_DEVICE_DAT
     1.4    PSRB_IO_CONTROL sic;
     1.5    ULONG prev_offset;
     1.6  
     1.7 +  if (xvdd->device_state == DEVICE_STATE_ACTIVE) {
     1.8 +    if (xvdd->new_total_sectors == -1L)
     1.9 +      xvdd->new_total_sectors = xvdd->total_sectors;
    1.10 +    if (xvdd->new_total_sectors != xvdd->total_sectors) {
    1.11 +      xvdd->total_sectors = xvdd->new_total_sectors;
    1.12 +      SxxxPortNotification(BusChangeDetected, xvdd, 0);
    1.13 +    }
    1.14 +  }
    1.15    while(!xvdd->aligned_buffer_in_use && xvdd->shadow_free && (srb_entry = (srb_list_entry_t *)RemoveHeadList(&xvdd->srb_list)) != (srb_list_entry_t *)&xvdd->srb_list) {
    1.16      srb = srb_entry->srb;
    1.17      prev_offset = srb_entry->offset;
     2.1 --- a/xenvbd_common/common_xen.h	Thu Feb 21 20:37:38 2013 +1100
     2.2 +++ b/xenvbd_common/common_xen.h	Sun Mar 03 12:19:31 2013 +1100
     2.3 @@ -91,6 +91,7 @@ XenVbd_Connect(PXENVBD_DEVICE_DATA xvdd,
     2.4    }
     2.5  
     2.6    // TODO: some of this stuff should be read on first connect only, then only verified on resume
     2.7 +  xvdd->new_total_sectors = (ULONGLONG)-1L;
     2.8    status = XnReadInt64(xvdd->handle, XN_BASE_BACKEND, "sectors", &xvdd->total_sectors);
     2.9    status = XnReadInt32(xvdd->handle, XN_BASE_BACKEND, "sector-size", &xvdd->hw_bytes_per_sector);
    2.10    if (xvdd->device_type == XENVBD_DEVICETYPE_CDROM) {
    2.11 @@ -196,6 +197,7 @@ XenVbd_Disconnect(PVOID DeviceExtension,
    2.12    return STATUS_SUCCESS;
    2.13  }
    2.14  
    2.15 +
    2.16  static VOID
    2.17  XenVbd_DeviceCallback(PVOID context, ULONG callback_type, PVOID value) {
    2.18    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)context;
    2.19 @@ -208,6 +210,11 @@ XenVbd_DeviceCallback(PVOID context, ULO
    2.20      state = (ULONG)(ULONG_PTR)value;
    2.21      if (state == xvdd->backend_state) {
    2.22        FUNCTION_MSG("same state %d\n", state);
    2.23 +      /* could be rewriting same state because of size change */
    2.24 +      if (xvdd->backend_state == XenbusStateConnected) {
    2.25 +        /* just set the new value - it will be noticed sooner or later */
    2.26 +        XnReadInt64(xvdd->handle, XN_BASE_BACKEND, "sectors", &xvdd->new_total_sectors);
    2.27 +      }
    2.28        FUNCTION_EXIT();
    2.29      }
    2.30      FUNCTION_MSG("XenBusState = %d -> %d\n", xvdd->backend_state, state);
     3.1 --- a/xenvbd_scsiport/common.h	Thu Feb 21 20:37:38 2013 +1100
     3.2 +++ b/xenvbd_scsiport/common.h	Sun Mar 03 12:19:31 2013 +1100
     3.3 @@ -47,6 +47,7 @@ struct {
     3.4    ULONG bytes_per_sector; /* 512 for disk, 2048 for CDROM) */
     3.5    ULONG hw_bytes_per_sector; /* underlying hardware format, eg 4K */
     3.6    ULONGLONG total_sectors;
     3.7 +  ULONGLONG new_total_sectors;
     3.8    ULONG feature_flush_cache;
     3.9    ULONG feature_discard;
    3.10    ULONG feature_barrier;
     4.1 --- a/xenvbd_scsiport/xenvbd.c	Thu Feb 21 20:37:38 2013 +1100
     4.2 +++ b/xenvbd_scsiport/xenvbd.c	Sun Mar 03 12:19:31 2013 +1100
     4.3 @@ -71,6 +71,11 @@ XenVbd_NotificationNextLuRequest(PXENVBD
     4.4    ScsiPortNotification(NextLuRequest, xvdd->xvsd, PathId, TargetId, Lun);
     4.5  }
     4.6  
     4.7 +VOID
     4.8 +XenVbd_NotificationBusChangeDetected(PXENVBD_DEVICE_DATA xvdd, UCHAR PathId) {
     4.9 +  ScsiPortNotification(BusChangeDetected, xvdd->xvsd, PathId);
    4.10 +}
    4.11 +
    4.12  #include "..\xenvbd_common\common_miniport.h"
    4.13  
    4.14  
     5.1 --- a/xenvbd_storport/xenvbd.h	Thu Feb 21 20:37:38 2013 +1100
     5.2 +++ b/xenvbd_storport/xenvbd.h	Sun Mar 03 12:19:31 2013 +1100
     5.3 @@ -89,6 +89,7 @@ struct {
     5.4    ULONG bytes_per_sector; /* 512 for disk, 2048 for CDROM) */
     5.5    ULONG hw_bytes_per_sector; /* underlying hardware format, eg 4K */
     5.6    ULONGLONG total_sectors;
     5.7 +  ULONGLONG new_total_sectors;
     5.8    CHAR serial_number[64];
     5.9    ULONG feature_flush_cache;
    5.10    ULONG feature_discard;