From nobody Sat Sep 21 01:08:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1599638469; cv=none; d=zohomail.com; s=zohoarc; b=JKpuW4Y/MMZ7H7+Gago7oT5fDXQXOH/1AXZPOGuOthJSHUaycoz0plEBFHx/6QsLSFnS/3aBlGmWz0Jqax2yYEPN+AyLXPe4e+C3wno+bSIrkSrC3AKXOd8btboHiTAiabyvGRx+MmisuXdOuTJHHSjKT62qwP5GmlDJac4ThWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599638469; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=WiShvUgskqykiMOdHsLuoFlNAhgGyPel+lPdGWHOWw4=; b=V55EHXqGCaOAuHX1a4HEa3cIr2KH4vjZGTFVfQvnI+F5Ip/Rcv45XckIzUnZP4WSiRN9eT6gtHP7pZ72ph4v9AbNLoQ/0kXHYsplKNmgZLJqZfD4uUFUjtbrQVA5l+wYqEy6laxnSe6AKgd4hme11o6EfIP0QQmg3hossibh3z4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599638469748868.0874932066697; Wed, 9 Sep 2020 01:01:09 -0700 (PDT) Received: from localhost ([::1]:54576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFv2S-0001JG-EA for importer@patchew.org; Wed, 09 Sep 2020 04:01:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFv1L-0000n6-LU for qemu-devel@nongnu.org; Wed, 09 Sep 2020 03:59:59 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kFv1J-0001OP-IQ for qemu-devel@nongnu.org; Wed, 09 Sep 2020 03:59:59 -0400 Received: by mail-pg1-x541.google.com with SMTP id 7so1474901pgm.11 for ; Wed, 09 Sep 2020 00:59:56 -0700 (PDT) Received: from localhost.localdomain ([47.75.244.237]) by smtp.gmail.com with ESMTPSA id l2sm1217093pjy.3.2020.09.09.00.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 00:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WiShvUgskqykiMOdHsLuoFlNAhgGyPel+lPdGWHOWw4=; b=Y8dfvxILFIRlKBeZO4xfcy5PDroS8YHFuc1M6H4S58u3va6vL9bLM+cUOL/CwLkils /uB3wNFhotRn91oR4ub7w5bFXvXkbVAx16pjva/hGm/RCXgrxBCRQ4Tl2qO5ZX6klaO9 uWKt9TffsSu+j2QoGhqOuSLURX+85i3NG87WKLIAOMvmUVvRZc+GrIC0plsFRWYsiRss E7b1EmMY7HcvVz7XpSdPA9uZCniYQW3mcYtjeJKqQymjT4XgGcPJMW7abRImySxu6XH3 0v61Vu9pPa5o6zXt2rsa8v3xCdPdQ7HXfDEjuA0q1QV0vKffh3kEtQxL9fKoUoSj45sw R0tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WiShvUgskqykiMOdHsLuoFlNAhgGyPel+lPdGWHOWw4=; b=PJRzb1420pEvYZtxf+YK24t5Gcy9PziV/bZsfjmn892u1W6v7s8A3vVtzh1b707Tu/ ltEmEoWAX7qa+zvlvzJUQsB6wAjsP5ylW3CUhBr3GppuWG6JEpW4ElYUpePTzYR0gDVA 0tjRKgdloWBmAL0jiN7Yh3ETXtw2XLUAHl6JSwGQ5yEtwDFTCx6i8h6fKKQBkmlvct57 8FdDO0HgAme2M5UEL2spj5nEl/cvr1snxMA7a75eJfb+KRT98EvHfOc2LlnE9Pdx1MGv eUgDULl3uqPuMRbqiJoSDnzfgaZifxw3mW6iTr2LvAPF2pMhDXQIiDegnHJSHudZEJco YCNg== X-Gm-Message-State: AOAM530YFErl2SEjP0KZAY4mAJiWTLLsNvYA+ELlouhanhKkVW/mvpSO tC9URoWkaEY1eVbcuiiqMAKHpA== X-Google-Smtp-Source: ABdhPJxgyEdZu0K7g+gJl5J/zMNPMGaoze7DNxnt399qOSjsWy3b/vNd5YOhbWFfuzKAQCCoRewy/A== X-Received: by 2002:a17:902:8c96:b029:d0:ad87:6668 with SMTP id t22-20020a1709028c96b02900d0ad876668mr3100305plo.2.1599638394848; Wed, 09 Sep 2020 00:59:54 -0700 (PDT) From: Li Feng To: lifeng1519@gmail.com, Paolo Bonzini , Fam Zheng , "Michael S. Tsirkin" , qemu-devel@nongnu.org (open list:All patches CC here) Subject: [PATCH] vhost-scsi: support inflight io track Date: Wed, 9 Sep 2020 20:20:21 +0800 Message-Id: <20200909122021.1055174-1-fengli@smartx.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::541; envelope-from=fengli@smartx.com; helo=mail-pg1-x541.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 11 X-Spam_score: 1.1 X-Spam_bar: + X-Spam_report: (1.1 / 5.0 requ) BAYES_00=-1.9, DATE_IN_FUTURE_03_06=3.027, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Feng Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @smartx-com.20150623.gappssmtp.com) Content-Type: text/plain; charset="utf-8" Qemu will send GET_INFLIGHT_FD and SET_INFLIGH_FD to backend, and the backend setup the inflight memory to track the io. Change-Id: I805d6189996f7a1b44c65f0b12ef7473b1789510 Signed-off-by: Li Feng --- hw/scsi/vhost-scsi-common.c | 27 +++++++++++++++++++++++++++ include/hw/virtio/vhost-scsi-common.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c index 8ec49d7fef..767f827e55 100644 --- a/hw/scsi/vhost-scsi-common.c +++ b/hw/scsi/vhost-scsi-common.c @@ -32,6 +32,8 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); =20 + VirtIOSCSICommon *vs =3D (VirtIOSCSICommon *)vsc; + if (!k->set_guest_notifiers) { error_report("binding does not support guest notifiers"); return -ENOSYS; @@ -49,6 +51,23 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) } =20 vsc->dev.acked_features =3D vdev->guest_features; + + assert(vsc->inflight =3D=3D NULL); + vsc->inflight =3D g_new0(struct vhost_inflight, 1); + ret =3D vhost_dev_get_inflight(&vsc->dev, + vs->conf.virtqueue_size, + vsc->inflight); + if (ret < 0) { + error_report("Error get inflight: %d", -ret); + goto err_guest_notifiers; + } + + ret =3D vhost_dev_set_inflight(&vsc->dev, vsc->inflight); + if (ret < 0) { + error_report("Error set inflight: %d", -ret); + goto err_guest_notifiers; + } + ret =3D vhost_dev_start(&vsc->dev, vdev); if (ret < 0) { error_report("Error start vhost dev"); @@ -66,6 +85,9 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc) return ret; =20 err_guest_notifiers: + g_free(vsc->inflight); + vsc->inflight =3D NULL; + k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false); err_host_notifiers: vhost_dev_disable_notifiers(&vsc->dev, vdev); @@ -89,6 +111,11 @@ void vhost_scsi_common_stop(VHostSCSICommon *vsc) } assert(ret >=3D 0); =20 + if (vsc->inflight) { + vhost_dev_free_inflight(vsc->inflight); + vsc->inflight =3D NULL; + } + vhost_dev_disable_notifiers(&vsc->dev, vdev); } =20 diff --git a/include/hw/virtio/vhost-scsi-common.h b/include/hw/virtio/vhos= t-scsi-common.h index 16bf1a73c1..6cd6431d67 100644 --- a/include/hw/virtio/vhost-scsi-common.h +++ b/include/hw/virtio/vhost-scsi-common.h @@ -35,6 +35,8 @@ typedef struct VHostSCSICommon { int lun; uint64_t host_features; bool migratable; + + struct vhost_inflight *inflight; } VHostSCSICommon; =20 int vhost_scsi_common_start(VHostSCSICommon *vsc); --=20 2.26.2