From patchwork Fri May 17 08:42:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 10947505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D5471515 for ; Fri, 17 May 2019 08:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D3F11FF62 for ; Fri, 17 May 2019 08:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20D7C212BE; Fri, 17 May 2019 08:46:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B4B2228C8 for ; Fri, 17 May 2019 08:46:00 +0000 (UTC) Received: from localhost ([127.0.0.1]:44596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRYV5-0000Z0-Mx for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 May 2019 04:45:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hRYTF-0007S3-AA for qemu-devel@nongnu.org; Fri, 17 May 2019 04:44:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hRYTC-00061t-PX for qemu-devel@nongnu.org; Fri, 17 May 2019 04:44:04 -0400 Received: from charlie.dont.surf ([128.199.63.193]:40154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hRYT8-0005tR-Iv; Fri, 17 May 2019 04:43:58 -0400 Received: from apples.localdomain (ip-5-186-120-196.cgn.fibianet.dk [5.186.120.196]) by charlie.dont.surf (Postfix) with ESMTPSA id 6A699C00AA; Fri, 17 May 2019 08:43:55 +0000 (UTC) From: Klaus Birkelund Jensen To: qemu-block@nongnu.org Date: Fri, 17 May 2019 10:42:26 +0200 Message-Id: <20190517084234.26923-1-klaus@birkelund.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 128.199.63.193 Subject: [Qemu-devel] [PATCH 0/8] nvme: v1.3, sgls, metadata and new 'ocssd' device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Keith Busch , Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi, This series of patches contains a number of refactorings to the emulated nvme device, adds additional features, such as support for metadata and scatter gather lists, and bumps the supported NVMe version to 1.3. Lastly, it contains a new 'ocssd' device. The motivation for the first seven patches is to set everything up for the final patch that adds a new 'ocssd' device and associated block driver that implements the OpenChannel 2.0 specification[1]. Many of us in the OpenChannel comunity have used a qemu fork[2] for emulation of OpenChannel devices. The fork is itself based on Keith's qemu-nvme tree[3] and we recently merged mainline qemu into it, but the result is still a "hybrid" nvme device that supports both conventional nvme and the OCSSD 2.0 spec through a 'dialect' mechanism. Merging instead of rebasing also created a pretty messy commit history and my efforts to try and rebase our work onto mainline was getting hairy to say the least. And I was never really happy with the dialect approach anyway. I have instead prepared this series of fresh patches that incrementally adds additional features to the nvme device to bring it into shape for finally introducing a new (and separate) 'ocssd' device that emulates an OpenChannel 2.0 device by reusing core functionality from the nvme device. Providing a separate ocssd device ensures that no ocssd specific stuff creeps into the nvme device. The ocssd device is backed by a new 'ocssd' block driver that holds internal meta data and keeps state permanent across power cycles. In the future I think we could use the same approach for the nvme device to keep internal metadata such as utilization and deallocated blocks. For now, the nvme device does not support the Deallocated and Unwritten Logical Block Error (DULBE) feature or the Data Set Management command as this would require such support. I have tried to make the patches to the nvme device in this series as digestible as possible, but I undestand that commit 310fcd5965e5 ("nvme: bump supported spec to 1.3") is pretty huge. I can try to chop it up if required, but the changes pretty much needs to be done in bulk to actually implement v1.3. This version was recently used to find a bug in use of SGLs in the Linux kernel, so I believe there is some value in introducing these new features. As for the ocssd device I believe that it is time it is included upstream and not kept seperately. I have knowledge of at least one other qemu fork implementing OCSSD 2.0 used by the SPDK team and I think we could all benefit from using a common implementation. The ocssd device is feature complete with respect to the OCSSD 2.0 spec (mandatory as well as optional features). [1]: http://lightnvm.io/docs/OCSSD-2_0-20180129.pdf [2]: https://github.com/OpenChannelSSD/qemu-nvme [3]: http://git.infradead.org/users/kbusch/qemu-nvme.git Klaus Birkelund Jensen (8): nvme: move device parameters to separate struct nvme: bump supported spec to 1.3 nvme: simplify PRP mappings nvme: allow multiple i/o's per request nvme: add support for metadata nvme: add support for scatter gather lists nvme: keep a copy of the NVMe command in request nvme: add an OpenChannel 2.0 NVMe device (ocssd) MAINTAINERS | 14 +- Makefile.objs | 1 + block.c | 2 +- block/Makefile.objs | 2 +- block/nvme.c | 20 +- block/ocssd.c | 690 ++++++++++ hw/block/Makefile.objs | 2 +- hw/block/nvme.c | 1405 ------------------- hw/block/nvme.h | 92 -- hw/block/nvme/nvme.c | 2485 +++++++++++++++++++++++++++++++++ hw/block/nvme/ocssd.c | 2647 ++++++++++++++++++++++++++++++++++++ hw/block/nvme/ocssd.h | 140 ++ hw/block/nvme/trace-events | 136 ++ hw/block/trace-events | 91 -- include/block/block_int.h | 3 + include/block/nvme.h | 152 ++- include/block/ocssd.h | 231 ++++ include/hw/block/nvme.h | 233 ++++ include/hw/pci/pci_ids.h | 2 + qapi/block-core.json | 47 +- 20 files changed, 6774 insertions(+), 1621 deletions(-) create mode 100644 block/ocssd.c delete mode 100644 hw/block/nvme.c delete mode 100644 hw/block/nvme.h create mode 100644 hw/block/nvme/nvme.c create mode 100644 hw/block/nvme/ocssd.c create mode 100644 hw/block/nvme/ocssd.h create mode 100644 hw/block/nvme/trace-events create mode 100644 include/block/ocssd.h create mode 100644 include/hw/block/nvme.h