]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Allow BLKIF_OP_WRITE_BARRIER or BLKIF_OP_FLUSH_DISKCACHE...
authorOwen Smith <owen.smith@cloud.com>
Mon, 21 Oct 2024 11:47:08 +0000 (12:47 +0100)
committerPaul Durrant <pdurrant@amazon.com>
Fri, 8 Nov 2024 17:48:41 +0000 (17:48 +0000)
... when a SCSIOP_SYNCHRONIZE_CACHE is issued, which should be the last
operation issued by the crash kernel.
Certain backends do not advertise WriteBarrier support, and use SyncDiskCache
instead. Add support for creating crashdumps on these backends.

Signed-off-by: Owen Smith <owen.smith@cloud.com>
src/xencrsh/frontend.c
src/xencrsh/frontend.h
src/xencrsh/pdo.c

index d88f498ca0cffb6b3f3dbb6e1862a1451af51046..0b9e46bf9b6ed3632ef0bf9972b945d7815ad215 100644 (file)
@@ -268,6 +268,7 @@ FrontendInsertRequestOnRing(
         }
         break;
     case BLKIF_OP_WRITE_BARRIER:
+    case BLKIF_OP_FLUSH_DISKCACHE:
         RingReq->operation          = Request->Operation;
         RingReq->nr_segments        = 0;
         RingReq->handle             = (USHORT)Frontend->DeviceId;
@@ -470,6 +471,15 @@ __ReadFeatures(
         Frontend->FeatureBarrier = FALSE;
     }
 
+    Status = StoreRead(NULL, Frontend->BackendPath,
+                        "feature-flush-cache", &Buffer);
+    if (NT_SUCCESS(Status)) {
+        Frontend->FeatureFlush = (strtoul(Buffer, NULL, 10) == 1);
+        AustereFree(Buffer);
+    } else {
+        Frontend->FeatureFlush = FALSE;
+    }
+
     Status = StoreRead(NULL, Frontend->BackendPath,
                         "feature-discard", &Buffer);
     if (NT_SUCCESS(Status)) {
@@ -479,9 +489,10 @@ __ReadFeatures(
         Frontend->FeatureDiscard = FALSE;
     }
 
-    LogVerbose("Features: DomId=%d, RingOrder=0, %s %s\n",
+    LogVerbose("Features: DomId=%d, RingOrder=0, %s %s %s\n",
                 Frontend->BackendId,
                 Frontend->FeatureBarrier ? "BARRIER" : "NOT_BARRIER",
+                Frontend->FeatureFlush ? "FLUSH" : "NOT_FLUSH",
                 Frontend->FeatureDiscard ? "DISCARD" : "NOT_DISCARD");
 }
 static VOID
index 174e4d73a380fda161b5964f351a0c577fda9685..2e2c305c8103c43ede1d5ea5f2fff24fc1e740e6 100644 (file)
@@ -62,6 +62,7 @@ typedef struct _XENVBD_FRONTEND {
     // Capabilities
     BOOLEAN                     Connected;
     BOOLEAN                     FeatureBarrier;
+    BOOLEAN                     FeatureFlush;
     BOOLEAN                     FeatureDiscard;
     BOOLEAN                     Paging;
     BOOLEAN                     Hibernation;
index 9fe3c53065108181249267393f9a03a54a5efaf4..76c4d5906bfcf8616fea94279d2be7bf4230c5c4 100644 (file)
@@ -564,17 +564,31 @@ PrepareSyncCache(
 {
     PXENVBD_SRBEXT          SrbExt = GetSrbExt(Srb);
     PXENVBD_REQUEST         Request;
-    
+    UCHAR                   Operation;
+
+    if (Pdo->Frontend.FeatureBarrier) {
+        Operation = BLKIF_OP_WRITE_BARRIER;
+    } else if (Pdo->Frontend.FeatureFlush) {
+        Operation = BLKIF_OP_FLUSH_DISKCACHE;
+    } else {
+        // cannot submit this to backend, just complete the SRB
+        Srb->SrbStatus = SRB_STATUS_SUCCESS;
+        Srb->ScsiStatus = 0x00; // SCSI_GOOD
+
+        FdoCompleteSrb(Pdo->Fdo, Srb);
+        return;
+    }
+
     SrbExt->NumRequests = 1;
     Request = &SrbExt->Requests[0];
     Request->Srb = Srb;
 
-    Request->Operation      = BLKIF_OP_WRITE_BARRIER;
+    Request->Operation      = Operation;
     Request->NrSegments     = 0;
     Request->FirstSector    = Cdb_LogicalBlock(Srb);
     Request->NrSectors      = 0;
 
-    __UpdateStats(Pdo, BLKIF_OP_WRITE_BARRIER);
+    __UpdateStats(Pdo, Operation);
     QueueInsertTail(&Pdo->PreparedSrbs, Srb);
 }
 
@@ -692,6 +706,13 @@ PdoCompleteSubmittedRequest(
             Pdo->Frontend.FeatureBarrier = FALSE;
         }
         break;
+    case BLKIF_OP_FLUSH_DISKCACHE:
+        LogVerbose("FLUSH\n");
+        if (Status == BLKIF_RSP_EOPNOTSUPP) {
+            // remove supported feature
+            Pdo->Frontend.FeatureFlush = FALSE;
+        }
+        break;
     case BLKIF_OP_DISCARD:
         LogVerbose("DISCARD\n");
         if (Status == BLKIF_RSP_EOPNOTSUPP) {