thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 6 months ago
Clone

Blame SOURCES/kvm-virtio-scsi-move-request-related-items-from-.h-to-.c.patch

29b115
From 6603f216dbc07a1d221b1665409cfec6cc9960e2 Mon Sep 17 00:00:00 2001
29b115
From: Stefan Hajnoczi <stefanha@redhat.com>
29b115
Date: Tue, 17 May 2022 09:28:26 +0100
29b115
Subject: [PATCH 14/16] virtio-scsi: move request-related items from .h to .c
29b115
29b115
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
29b115
RH-MergeRequest: 88: virtio-scsi: fix 100% CPU consumption with IOThreads
29b115
RH-Commit: [6/6] ecdf5289abd04062c85c5ed8e577a5249684a3b0 (stefanha/centos-stream-qemu-kvm)
29b115
RH-Bugzilla: 2079347
29b115
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
29b115
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
29b115
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
29b115
29b115
There is no longer a need to expose the request and related APIs in
29b115
virtio-scsi.h since there are no callers outside virtio-scsi.c.
29b115
29b115
Note the block comment in VirtIOSCSIReq has been adjusted to meet the
29b115
coding style.
29b115
29b115
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
29b115
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
29b115
Message-id: 20220427143541.119567-7-stefanha@redhat.com
29b115
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
29b115
(cherry picked from commit 3dc584abeef0e1277c2de8c1c1974cb49444eb0a)
29b115
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
29b115
---
29b115
 hw/scsi/virtio-scsi.c           | 45 ++++++++++++++++++++++++++++++---
29b115
 include/hw/virtio/virtio-scsi.h | 40 -----------------------------
29b115
 2 files changed, 41 insertions(+), 44 deletions(-)
29b115
29b115
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
29b115
index df5ff8bab7..2450c9438c 100644
29b115
--- a/hw/scsi/virtio-scsi.c
29b115
+++ b/hw/scsi/virtio-scsi.c
29b115
@@ -29,6 +29,43 @@
29b115
 #include "hw/virtio/virtio-access.h"
29b115
 #include "trace.h"
29b115
 
29b115
+typedef struct VirtIOSCSIReq {
29b115
+    /*
29b115
+     * Note:
29b115
+     * - fields up to resp_iov are initialized by virtio_scsi_init_req;
29b115
+     * - fields starting at vring are zeroed by virtio_scsi_init_req.
29b115
+     */
29b115
+    VirtQueueElement elem;
29b115
+
29b115
+    VirtIOSCSI *dev;
29b115
+    VirtQueue *vq;
29b115
+    QEMUSGList qsgl;
29b115
+    QEMUIOVector resp_iov;
29b115
+
29b115
+    union {
29b115
+        /* Used for two-stage request submission */
29b115
+        QTAILQ_ENTRY(VirtIOSCSIReq) next;
29b115
+
29b115
+        /* Used for cancellation of request during TMFs */
29b115
+        int remaining;
29b115
+    };
29b115
+
29b115
+    SCSIRequest *sreq;
29b115
+    size_t resp_size;
29b115
+    enum SCSIXferMode mode;
29b115
+    union {
29b115
+        VirtIOSCSICmdResp     cmd;
29b115
+        VirtIOSCSICtrlTMFResp tmf;
29b115
+        VirtIOSCSICtrlANResp  an;
29b115
+        VirtIOSCSIEvent       event;
29b115
+    } resp;
29b115
+    union {
29b115
+        VirtIOSCSICmdReq      cmd;
29b115
+        VirtIOSCSICtrlTMFReq  tmf;
29b115
+        VirtIOSCSICtrlANReq   an;
29b115
+    } req;
29b115
+} VirtIOSCSIReq;
29b115
+
29b115
 static inline int virtio_scsi_get_lun(uint8_t *lun)
29b115
 {
29b115
     return ((lun[2] << 8) | lun[3]) & 0x3FFF;
29b115
@@ -45,7 +82,7 @@ static inline SCSIDevice *virtio_scsi_device_get(VirtIOSCSI *s, uint8_t *lun)
29b115
     return scsi_device_get(&s->bus, 0, lun[1], virtio_scsi_get_lun(lun));
29b115
 }
29b115
 
29b115
-void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
29b115
+static void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
29b115
 {
29b115
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
29b115
     const size_t zero_skip =
29b115
@@ -58,7 +95,7 @@ void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req)
29b115
     memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip);
29b115
 }
29b115
 
29b115
-void virtio_scsi_free_req(VirtIOSCSIReq *req)
29b115
+static void virtio_scsi_free_req(VirtIOSCSIReq *req)
29b115
 {
29b115
     qemu_iovec_destroy(&req->resp_iov);
29b115
     qemu_sglist_destroy(&req->qsgl);
29b115
@@ -801,8 +838,8 @@ static void virtio_scsi_reset(VirtIODevice *vdev)
29b115
     s->events_dropped = false;
29b115
 }
29b115
 
29b115
-void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
29b115
-                            uint32_t event, uint32_t reason)
29b115
+static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
29b115
+                                   uint32_t event, uint32_t reason)
29b115
 {
29b115
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
29b115
     VirtIOSCSIReq *req;
29b115
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
29b115
index 2497530064..abdda2cbd0 100644
29b115
--- a/include/hw/virtio/virtio-scsi.h
29b115
+++ b/include/hw/virtio/virtio-scsi.h
29b115
@@ -94,42 +94,6 @@ struct VirtIOSCSI {
29b115
     uint32_t host_features;
29b115
 };
29b115
 
29b115
-typedef struct VirtIOSCSIReq {
29b115
-    /* Note:
29b115
-     * - fields up to resp_iov are initialized by virtio_scsi_init_req;
29b115
-     * - fields starting at vring are zeroed by virtio_scsi_init_req.
29b115
-     * */
29b115
-    VirtQueueElement elem;
29b115
-
29b115
-    VirtIOSCSI *dev;
29b115
-    VirtQueue *vq;
29b115
-    QEMUSGList qsgl;
29b115
-    QEMUIOVector resp_iov;
29b115
-
29b115
-    union {
29b115
-        /* Used for two-stage request submission */
29b115
-        QTAILQ_ENTRY(VirtIOSCSIReq) next;
29b115
-
29b115
-        /* Used for cancellation of request during TMFs */
29b115
-        int remaining;
29b115
-    };
29b115
-
29b115
-    SCSIRequest *sreq;
29b115
-    size_t resp_size;
29b115
-    enum SCSIXferMode mode;
29b115
-    union {
29b115
-        VirtIOSCSICmdResp     cmd;
29b115
-        VirtIOSCSICtrlTMFResp tmf;
29b115
-        VirtIOSCSICtrlANResp  an;
29b115
-        VirtIOSCSIEvent       event;
29b115
-    } resp;
29b115
-    union {
29b115
-        VirtIOSCSICmdReq      cmd;
29b115
-        VirtIOSCSICtrlTMFReq  tmf;
29b115
-        VirtIOSCSICtrlANReq   an;
29b115
-    } req;
29b115
-} VirtIOSCSIReq;
29b115
-
29b115
 static inline void virtio_scsi_acquire(VirtIOSCSI *s)
29b115
 {
29b115
     if (s->ctx) {
29b115
@@ -151,10 +115,6 @@ void virtio_scsi_common_realize(DeviceState *dev,
29b115
                                 Error **errp);
29b115
 
29b115
 void virtio_scsi_common_unrealize(DeviceState *dev);
29b115
-void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req);
29b115
-void virtio_scsi_free_req(VirtIOSCSIReq *req);
29b115
-void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
29b115
-                            uint32_t event, uint32_t reason);
29b115
 
29b115
 void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp);
29b115
 int virtio_scsi_dataplane_start(VirtIODevice *s);
29b115
-- 
29b115
2.31.1
29b115