From patchwork Wed Jul 20 16:21:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 9239949 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 1BD65602F0 for ; Wed, 20 Jul 2016 16:35:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02C4127BFC for ; Wed, 20 Jul 2016 16:35:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9D9E27D4D; Wed, 20 Jul 2016 16:35:32 +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 346BF27BFC for ; Wed, 20 Jul 2016 16:35:32 +0000 (UTC) Received: from localhost ([::1]:35684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuT4-0005bn-Fx for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 12:35:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55917) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuG4-00038J-Hi for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPuG3-0004cA-6X for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPuG2-0004c4-UI for qemu-devel@nongnu.org; Wed, 20 Jul 2016 12:22:03 -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 969D146210; Wed, 20 Jul 2016 16:22:02 +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 u6KGM0qR000556; Wed, 20 Jul 2016 12:22:01 -0400 From: Stefan Hajnoczi To: Date: Wed, 20 Jul 2016 17:21:11 +0100 Message-Id: <1469031682-21863-15-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.29]); Wed, 20 Jul 2016 16:22:02 +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 14/25] block: Convert .bdrv_aio_discard() to byte-based 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 Another step towards byte-based interfaces everywhere. Replace the sector-based driver callback .bdrv_aio_discard() with a new byte-based .bdrv_aio_pdiscard(). Only raw-posix and RBD drivers are affected, so it was not worth splitting into multiple patches. Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-id: 1468624988-423-9-git-send-email-eblake@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io.c | 7 +++---- block/raw-posix.c | 18 ++++++++---------- block/rbd.c | 15 +++++++-------- include/block/block_int.h | 4 ++-- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/block/io.c b/block/io.c index 58fdac5..5c759fa 100644 --- a/block/io.c +++ b/block/io.c @@ -2423,7 +2423,7 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, return 0; } - if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) { + if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_pdiscard) { return 0; } @@ -2464,9 +2464,8 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverState *bs, int64_t offset, .coroutine = qemu_coroutine_self(), }; - acb = bs->drv->bdrv_aio_discard(bs, offset >> BDRV_SECTOR_BITS, - num >> BDRV_SECTOR_BITS, - bdrv_co_io_em_complete, &co); + acb = bs->drv->bdrv_aio_pdiscard(bs, offset, num, + bdrv_co_io_em_complete, &co); if (acb == NULL) { ret = -EIO; goto out; diff --git a/block/raw-posix.c b/block/raw-posix.c index b48efb3..6ed7547 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1786,14 +1786,13 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, return ret | BDRV_BLOCK_OFFSET_VALID | start; } -static coroutine_fn BlockAIOCB *raw_aio_discard(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, +static coroutine_fn BlockAIOCB *raw_aio_pdiscard(BlockDriverState *bs, + int64_t offset, int count, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; - return paio_submit(bs, s->fd, sector_num << BDRV_SECTOR_BITS, NULL, - nb_sectors << BDRV_SECTOR_BITS, + return paio_submit(bs, s->fd, offset, NULL, count, cb, opaque, QEMU_AIO_DISCARD); } @@ -1865,7 +1864,7 @@ BlockDriver bdrv_file = { .bdrv_co_preadv = raw_co_preadv, .bdrv_co_pwritev = raw_co_pwritev, .bdrv_aio_flush = raw_aio_flush, - .bdrv_aio_discard = raw_aio_discard, + .bdrv_aio_pdiscard = raw_aio_pdiscard, .bdrv_refresh_limits = raw_refresh_limits, .bdrv_io_plug = raw_aio_plug, .bdrv_io_unplug = raw_aio_unplug, @@ -2204,8 +2203,8 @@ static int fd_open(BlockDriverState *bs) return -EIO; } -static coroutine_fn BlockAIOCB *hdev_aio_discard(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, +static coroutine_fn BlockAIOCB *hdev_aio_pdiscard(BlockDriverState *bs, + int64_t offset, int count, BlockCompletionFunc *cb, void *opaque) { BDRVRawState *s = bs->opaque; @@ -2213,8 +2212,7 @@ static coroutine_fn BlockAIOCB *hdev_aio_discard(BlockDriverState *bs, if (fd_open(bs) < 0) { return NULL; } - return paio_submit(bs, s->fd, sector_num << BDRV_SECTOR_BITS, NULL, - nb_sectors << BDRV_SECTOR_BITS, + return paio_submit(bs, s->fd, offset, NULL, count, cb, opaque, QEMU_AIO_DISCARD|QEMU_AIO_BLKDEV); } @@ -2309,7 +2307,7 @@ static BlockDriver bdrv_host_device = { .bdrv_co_preadv = raw_co_preadv, .bdrv_co_pwritev = raw_co_pwritev, .bdrv_aio_flush = raw_aio_flush, - .bdrv_aio_discard = hdev_aio_discard, + .bdrv_aio_pdiscard = hdev_aio_pdiscard, .bdrv_refresh_limits = raw_refresh_limits, .bdrv_io_plug = raw_aio_plug, .bdrv_io_unplug = raw_aio_unplug, diff --git a/block/rbd.c b/block/rbd.c index 01cbb63..0106fea 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -930,14 +930,13 @@ static int qemu_rbd_snap_list(BlockDriverState *bs, } #ifdef LIBRBD_SUPPORTS_DISCARD -static BlockAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs, - int64_t sector_num, - int nb_sectors, - BlockCompletionFunc *cb, - void *opaque) +static BlockAIOCB *qemu_rbd_aio_pdiscard(BlockDriverState *bs, + int64_t offset, + int count, + BlockCompletionFunc *cb, + void *opaque) { - return rbd_start_aio(bs, sector_num << BDRV_SECTOR_BITS, NULL, - nb_sectors << BDRV_SECTOR_BITS, cb, opaque, + return rbd_start_aio(bs, offset, NULL, count, cb, opaque, RBD_AIO_DISCARD); } #endif @@ -1001,7 +1000,7 @@ static BlockDriver bdrv_rbd = { #endif #ifdef LIBRBD_SUPPORTS_DISCARD - .bdrv_aio_discard = qemu_rbd_aio_discard, + .bdrv_aio_pdiscard = qemu_rbd_aio_pdiscard, #endif .bdrv_snapshot_create = qemu_rbd_snap_create, diff --git a/include/block/block_int.h b/include/block/block_int.h index a6b13ad..9bf9aed 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -142,8 +142,8 @@ struct BlockDriver { BlockCompletionFunc *cb, void *opaque); BlockAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque); - BlockAIOCB *(*bdrv_aio_discard)(BlockDriverState *bs, - int64_t sector_num, int nb_sectors, + BlockAIOCB *(*bdrv_aio_pdiscard)(BlockDriverState *bs, + int64_t offset, int count, BlockCompletionFunc *cb, void *opaque); int coroutine_fn (*bdrv_co_readv)(BlockDriverState *bs,