thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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