From patchwork Wed Jul 20 16:21:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9239953 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 5826F602F0 for ; Wed, 20 Jul 2016 16:36:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 492E327D29 for ; Wed, 20 Jul 2016 16:36:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E02A27D64; Wed, 20 Jul 2016 16:36:02 +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 D6CF627D29 for ; Wed, 20 Jul 2016 16:36:01 +0000 (UTC) Received: from localhost ([::1]:35695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuTY-00065Q-SW for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 12:36:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuG7-0003Ae-Jq for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPuG5-0004ce-IB for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38748) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuG5-0004cZ-BI for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:05 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 F2C4E710AE; Wed, 20 Jul 2016 16:22:04 +0000 (UTC) Received: from localhost (ovpn-112-63.ams2.redhat.com [10.36.112.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6KGM3E8000591; Wed, 20 Jul 2016 12:22:04 -0400 From: Stefan Hajnoczi To: Date: Wed, 20 Jul 2016 17:21:12 +0100 Message-Id: <1469031682-21863-16-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.24 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:05 +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 15/25] block: Add .bdrv_co_pdiscard() driver callback 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 There's enough drivers with a sector-based callback that it will be easier to switch one at a time. This patch adds a byte-based callback, and then after all drivers are swapped, we'll drop the sector-based callback. [checkpatch doesn't like the space after coroutine_fn in block_int.h, but it's consistent with the rest of the file] Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-id: 1468624988-423-10-git-send-email-eblake@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 7 +++++-- include/block/block_int.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index 5c759fa..5ba0195 100644 --- a/block/io.c +++ b/block/io.c @@ -2423,7 +2423,8 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, return 0; } - if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_pdiscard) { + if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_co_pdiscard && + !bs->drv->bdrv_aio_pdiscard) { return 0; } @@ -2455,7 +2456,9 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, int ret; int num = MIN(count, max_pdiscard); - if (bs->drv->bdrv_co_discard) { + 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 { diff --git a/include/block/block_int.h b/include/block/block_int.h index 9bf9aed..8f16d16 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -167,6 +167,8 @@ struct BlockDriver { 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, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file);