From patchwork Thu Feb 21 10:33:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 10823643 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 AF68D13A4 for ; Thu, 21 Feb 2019 10:38:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC99307C6 for ; Thu, 21 Feb 2019 10:38:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90FB9307CB; Thu, 21 Feb 2019 10:38:16 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI 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 22706307A7 for ; Thu, 21 Feb 2019 10:38:16 +0000 (UTC) Received: from localhost ([127.0.0.1]:57913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwlk7-0002N8-Ay for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Feb 2019 05:38:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwlfx-0006wI-CB for qemu-devel@nongnu.org; Thu, 21 Feb 2019 05:33:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwlfl-000422-9m for qemu-devel@nongnu.org; Thu, 21 Feb 2019 05:33:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60668) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwlfg-0003pB-IE; Thu, 21 Feb 2019 05:33:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 93FAC3091761; Thu, 21 Feb 2019 10:33:29 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-117-132.ams2.redhat.com [10.36.117.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0762460BE6; Thu, 21 Feb 2019 10:33:15 +0000 (UTC) From: Stefano Garzarella To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 11:33:04 +0100 Message-Id: <20190221103314.58500-1-sgarzare@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 21 Feb 2019 10:33:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v6 00/10] virtio-blk: add DISCARD and WRITE_ZEROES features 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: Laurent Vivier , Kevin Wolf , Thomas Huth , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Jason Wang , "Dr . David Alan Gilbert" , Stefan Hajnoczi , Paolo Bonzini , Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This series adds the support of DISCARD and WRITE_ZEROES commands and extends the virtio-blk-test to test these new commands. v6: - fixed patchew failure on patch 8 (do not initialise globals to 0 or NULL) - added R-b tags by Stefan v5: - rebased on master - handled the config size for DISCARD and WRITE_ZEROES features as in virtio-net (patches 4 and 5) [Michael, Stefan] - fixed an endianness issues on the WRITE_ZEROES test (patches 8 and 9) - added a test for DISCARD command to only test the status returned by the request (patch 10) - others patches are unchanged (patches 1, 2, 3, 6, 7) v4: - fixed error with mingw compiler in patch 4 gcc and clang want %lu, but mingw wants %llu for BDRV_REQUEST_MAX_SECTORS. Since is less than INT_MAX, I casted it to integer and I used %d in the format string of error_setg. (mingw now is happy) v3: - rebased on master (I removed Based-on tag since the new virtio headers from linux v5.0-rc1 are merged) - added patch 2 to add host_features field (as in virtio-net) [Michael] - fixed patch 3 (previously 2/5) using the new host_features field - fixed patch 4 (previously 3/5) following the Stefan's comments: - fixed name of functions and fields - used vdev and s pointers - removed "wz-may-unmap" property - split "dwz-max-sectors" in two properties v2: - added patch 1 to use virtio_blk_handle_rw_error() with discard operation - added patch 2 to make those new features machine-type dependent (thanks David) - fixed patch 3 (previously patch 1/2) adding more checks, block_acct_start() for WRITE_ZEROES requests, and configurable parameters to initialize the limits (max_sectors, wzeroes_may_unmap). (thanks Stefan) I moved in a new function the code to handle a single segment, in order to simplify the support of multiple segments in the future. - added patch 4 to change the assert on data_size following the discussion with Thomas, Changpeng, Michael, and Stefan (thanks all) - fixed patch 5 (previously patch 2/2) using local dwz_hdr variable instead of dynamic allocation (thanks Thomas) Thanks, Stefano Stefano Garzarella (10): virtio-blk: add acct_failed param to virtio_blk_handle_rw_error() virtio-blk: add host_features field in VirtIOBlock virtio-blk: add "discard" and "write-zeroes" properties virtio-net: make VirtIOFeature usable for other virtio devices virtio-blk: set config size depending on the features enabled virtio-blk: add DISCARD and WRITE_ZEROES features tests/virtio-blk: change assert on data_size in virtio_blk_request() tests/virtio-blk: add virtio_blk_fix_dwz_hdr() function tests/virtio-blk: add test for WRITE_ZEROES command tests/virtio-blk: add test for DISCARD command hw/block/virtio-blk.c | 245 ++++++++++++++++++++++++++++++--- hw/core/machine.c | 2 + hw/net/virtio-net.c | 31 +---- hw/virtio/virtio.c | 15 ++ include/hw/virtio/virtio-blk.h | 6 +- include/hw/virtio/virtio.h | 15 ++ tests/virtio-blk-test.c | 127 ++++++++++++++++- 7 files changed, 391 insertions(+), 50 deletions(-)