From patchwork Wed Jul 20 16:21:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9239959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 00C516077C for ; Wed, 20 Jul 2016 16:39:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E65A527C2C for ; Wed, 20 Jul 2016 16:39:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA11327D29; Wed, 20 Jul 2016 16:39:57 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86B5A27C2C for ; Wed, 20 Jul 2016 16:39:57 +0000 (UTC) Received: from localhost ([::1]:35712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuXM-0000xx-Gi for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 12:39:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuGQ-0003Ok-A0 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPuGO-0004fk-AN for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuGO-0004fg-4K for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:24 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1AB811BB6F; Wed, 20 Jul 2016 16:22:23 +0000 (UTC) Received: from localhost (ovpn-112-63.ams2.redhat.com [10.36.112.63]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6KGMM11028141; Wed, 20 Jul 2016 12:22:23 -0400 From: Stefan Hajnoczi To: Date: Wed, 20 Jul 2016 17:21:20 +0100 Message-Id: <1469031682-21863-24-git-send-email-stefanha@redhat.com> In-Reply-To: <1469031682-21863-1-git-send-email-stefanha@redhat.com> References: <1469031682-21863-1-git-send-email-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Jul 2016 16:22:23 +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] [PULL v2 23/25] block: Kill .bdrv_co_discard() 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: Peter Maydell , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Blake Now that all drivers have a byte-based .bdrv_co_pdiscard(), we no longer need to worry about the sector-based version. We can also relax our minimum alignment to 1 for drivers that support it. Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-id: 1468624988-423-18-git-send-email-eblake@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 9 ++------- include/block/block_int.h | 2 -- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/block/io.c b/block/io.c index 5ba0195..7323f0f 100644 --- a/block/io.c +++ b/block/io.c @@ -2423,14 +2423,12 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, return 0; } - if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_co_pdiscard && - !bs->drv->bdrv_aio_pdiscard) { + if (!bs->drv->bdrv_co_pdiscard && !bs->drv->bdrv_aio_pdiscard) { return 0; } /* Discard is advisory, so ignore any unaligned head or tail */ - align = MAX(BDRV_SECTOR_SIZE, - MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment)); + align = MAX(bs->bl.pdiscard_alignment, bs->bl.request_alignment); assert(is_power_of_2(align)); head = MIN(count, -offset & (align - 1)); if (head) { @@ -2458,9 +2456,6 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, if (bs->drv->bdrv_co_pdiscard) { ret = bs->drv->bdrv_co_pdiscard(bs, offset, num); - } else if (bs->drv->bdrv_co_discard) { - ret = bs->drv->bdrv_co_discard(bs, offset >> BDRV_SECTOR_BITS, - num >> BDRV_SECTOR_BITS); } else { BlockAIOCB *acb; CoroutineIOCompletion co = { diff --git a/include/block/block_int.h b/include/block/block_int.h index 8f16d16..a069f97 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -165,8 +165,6 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_pwrite_zeroes)(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags); - int coroutine_fn (*bdrv_co_discard)(BlockDriverState *bs, - int64_t sector_num, int nb_sectors); int coroutine_fn (*bdrv_co_pdiscard)(BlockDriverState *bs, int64_t offset, int count); int64_t coroutine_fn (*bdrv_co_get_block_status)(BlockDriverState *bs,