[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [win-pv-devel] [PATCH v2 3/4] Rework BlkifRingDisable


  • To: Owen Smith <owen.smith@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Paul Durrant <Paul.Durrant@xxxxxxxxxx>
  • Date: Wed, 18 Sep 2019 15:52:16 +0000
  • Accept-language: en-GB, en-US
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=Paul.Durrant@xxxxxxxxxx; spf=Pass smtp.mailfrom=Paul.Durrant@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Wed, 18 Sep 2019 15:52:23 +0000
  • Ironport-sdr: vR2LrhA7j4+7V+CzSbbbw0uIJQEAdLfSUhCuJbTQe68U4UPkKws7q6ZCZSLJLXhrLUYrcbZkqy A3e7eVUfMfF0n5QVynYULk33C6h9KMNwlCddHl63Tyx1Pqm8jy/gSTg55D4r/yookKXx0OSFr0 NofI++u85ttNy+lviFdIEH4V/kn0vrzA/JgziFUd10/hAh/7vnYoVmZ7/RdF5pes3ytJvram// NRzo7b+CU3RGFgmZxMexJdripcoimYtregBaNSRvH3zH14st575R/Df892QCicvOPbmwRmdoMe MHI=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Thread-index: AQHVbiSkVasJwyUfd067S4FjDPdw/KcxlTQA
  • Thread-topic: [win-pv-devel] [PATCH v2 3/4] Rework BlkifRingDisable

> -----Original Message-----
> From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of 
> Owen Smith
> Sent: 18 September 2019 14:25
> To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: Owen Smith <owen.smith@xxxxxxxxxx>
> Subject: [win-pv-devel] [PATCH v2 3/4] Rework BlkifRingDisable
> 
> Clean up all prepared and submitted requests when the ring is disabled,
> so that outstanding SRBs are returned to storport for queueing. This is
> especially important on the return from suspend path, as the ring is no
> longer valid, and any submitted requests would be lost and trigger a
> storport target reset.
> Also ignores missing requests for responses.
> 
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
> ---
>  src/xenvbd/ring.c | 68 
> ++++++++++++++++++++-----------------------------------
>  1 file changed, 25 insertions(+), 43 deletions(-)
> 
> diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
> index 6edee5c..8dcdee3 100644
> --- a/src/xenvbd/ring.c
> +++ b/src/xenvbd/ring.c
> @@ -1242,17 +1242,17 @@ BlkifRingPoll(
> 
>              rsp = RING_GET_RESPONSE(&BlkifRing->Front, rsp_cons);
>              rsp_cons++;
> -            BlkifRing->ResponsesProcessed++;
> 
>              BlkifRing->Stopped = FALSE;
> 
>              Request = __BlkifRingGetSubmittedRequest(BlkifRing,
>                                                       rsp->id);
> -            ASSERT3P(Request, != , NULL);
> -
> -            __BlkifRingCompleteResponse(BlkifRing,
> -                                        Request,
> -                                        rsp->status);
> +            if (Request != NULL) {
> +                BlkifRing->ResponsesProcessed++;
> +                __BlkifRingCompleteResponse(BlkifRing,
> +                                            Request,
> +                                            rsp->status);
> +            }

This really should not happen, but I guess it may avoid a non-obvious crash in 
the non-debug case (where the assert is compiled out).

Acked-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> 
>              if (rsp_cons - BlkifRing->Front.rsp_cons > 
> XENVBD_BATCH(BlkifRing))
>                  Retry = TRUE;
> @@ -2044,57 +2044,39 @@ BlkifRingDisable(
>      IN  PXENVBD_BLKIF_RING  BlkifRing
>      )
>  {
> -    PXENVBD_RING            Ring = BlkifRing->Ring;
> -    ULONG                   Attempt;
> -
>      Trace("====> %u\n", BlkifRing->Index);
> 
>      __BlkifRingAcquireLock(BlkifRing);
>      ASSERT(BlkifRing->Enabled);
> 
> -    // Discard any pending requests
> -    while (!IsListEmpty(&BlkifRing->PreparedQueue)) {
> -        PLIST_ENTRY         ListEntry;
> -        PXENVBD_REQUEST     Request;
> -        PXENVBD_SRBEXT      SrbExt;
> -        PSCSI_REQUEST_BLOCK Srb;
> -
> -        ListEntry = RemoveHeadList(&BlkifRing->PreparedQueue);
> -        ASSERT3P(ListEntry, !=, &BlkifRing->PreparedQueue);
> +    BlkifRing->Enabled = FALSE;
> 
> -        Request = CONTAINING_RECORD(ListEntry,
> -                                    XENVBD_REQUEST,
> -                                    ListEntry);
> -        SrbExt = Request->SrbExt;
> -        Srb = SrbExt->Srb;
> -        Srb->SrbStatus = SRB_STATUS_ABORTED;
> -        Srb->ScsiStatus = 0x40; // SCSI_ABORTED
> +    while (!IsListEmpty(&BlkifRing->SubmittedList)) {
> +        PLIST_ENTRY ListEntry;
> +        PXENVBD_REQUEST Request;
> 
> -        BlkifRingPutRequest(BlkifRing, Request);
> +        ListEntry = RemoveHeadList(&BlkifRing->SubmittedList);
> +        ASSERT3P(ListEntry, !=, &BlkifRing->SubmittedList);
> 
> -        if (InterlockedDecrement(&SrbExt->RequestCount) == 0)
> -            __BlkifRingCompleteSrb(BlkifRing, SrbExt);
> +        Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry);
> +        BlkifRing->ResponsesProcessed++;
> +        __BlkifRingCompleteResponse(BlkifRing, Request, BLKIF_RSP_ERROR);
>      }
> 
> -    Attempt = 0;
> -    ASSERT3U(BlkifRing->RequestsPushed, == , BlkifRing->RequestsPosted);
> -    while (BlkifRing->ResponsesProcessed != BlkifRing->RequestsPushed) {
> -        Attempt++;
> -        ASSERT(Attempt < 100);
> -
> -        // Try to move things along
> -        __BlkifRingSend(BlkifRing);
> -        (VOID)BlkifRingPoll(BlkifRing);
> +    while (!IsListEmpty(&BlkifRing->PreparedQueue)) {
> +        PLIST_ENTRY ListEntry;
> +        PXENVBD_REQUEST Request;
> 
> -        // We are waiting for a watch event at DISPATCH_LEVEL so
> -        // it is our responsibility to poll the store ring.
> -        XENBUS_STORE(Poll,
> -                     &Ring->StoreInterface);
> +        ListEntry = RemoveHeadList(&BlkifRing->PreparedQueue);
> +        ASSERT3P(ListEntry, !=, &BlkifRing->PreparedQueue);
> 
> -        KeStallExecutionProcessor(1000);    // 1ms
> +        Request = CONTAINING_RECORD(ListEntry, XENVBD_REQUEST, ListEntry);
> +        // Dont increment ResponsesProcessed, as this is a faked response
> +        __BlkifRingCompleteResponse(BlkifRing, Request, BLKIF_RSP_ERROR);
>      }
> 
> -    BlkifRing->Enabled = FALSE;
> +    BlkifRing->Stopped = FALSE;
> +
>      __BlkifRingReleaseLock(BlkifRing);
> 
>      Trace("<==== %u\n", BlkifRing->Index);
> --
> 2.16.2.windows.1
> 
> 
> _______________________________________________
> win-pv-devel mailing list
> win-pv-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/win-pv-devel
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.