From patchwork Fri Jun 8 06:04:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 10453825 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 AD59260234 for ; Fri, 8 Jun 2018 06:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CA2A29530 for ; Fri, 8 Jun 2018 06:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F61D29532; Fri, 8 Jun 2018 06:10: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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 39EFF29530 for ; Fri, 8 Jun 2018 06:10:57 +0000 (UTC) Received: from localhost ([::1]:33318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRAbw-0005MU-71 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 08 Jun 2018 02:10:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRAWN-0000Ix-Lh for qemu-devel@nongnu.org; Fri, 08 Jun 2018 02:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRAWM-0008Ru-Q6 for qemu-devel@nongnu.org; Fri, 08 Jun 2018 02:05:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40232 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fRAWK-0008Ok-IU; Fri, 08 Jun 2018 02:05:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A9BE401EF04; Fri, 8 Jun 2018 06:05:08 +0000 (UTC) Received: from lemon.usersys.redhat.com (ovpn-12-108.pek2.redhat.com [10.72.12.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5749C1C65D; Fri, 8 Jun 2018 06:05:03 +0000 (UTC) From: Fam Zheng To: qemu-devel@nongnu.org Date: Fri, 8 Jun 2018 14:04:15 +0800 Message-Id: <20180608060417.10170-5-famz@redhat.com> In-Reply-To: <20180608060417.10170-1-famz@redhat.com> References: <20180608060417.10170-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 08 Jun 2018 06:05:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 08 Jun 2018 06:05:08 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'famz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 4/6] block-backend: Add blk_aio_copy_range 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Jeff Cody , Max Reitz , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Fam Zheng --- block/block-backend.c | 36 ++++++++++++++++++++++++++++++++++ include/sysemu/block-backend.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index e20a204bee..36d928e13d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1213,6 +1213,14 @@ typedef struct BlkRwCo { unsigned long int req; void *buf; } ioctl; + + struct { + BlockBackend *dst_blk; + int64_t src_off; + int64_t dst_off; + int bytes; + BdrvRequestFlags flags; + } copy_range; }; } BlkRwCo; @@ -1505,6 +1513,34 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, return blk_aio_prwv(blk, &rwco, blk_aio_write_entry, cb, opaque); } +static void blk_aio_copy_range_entry(void *opaque) +{ + BlkAioEmAIOCB *acb = opaque; + BlkRwCo *rwco = &acb->rwco; + + rwco->ret = blk_co_copy_range(rwco->blk, rwco->copy_range.src_off, + rwco->copy_range.dst_blk, + rwco->copy_range.dst_off, + rwco->copy_range.bytes, + rwco->copy_range.flags); + blk_aio_complete(acb); +} + +BlockAIOCB *blk_aio_copy_range(BlockBackend *src, int64_t src_offset, + BlockBackend *dst, int64_t dst_offset, + uint64_t bytes, BdrvRequestFlags flags, + BlockCompletionFunc *cb, void *opaque) +{ + BlkRwCo rwco = (BlkRwCo) { + .copy_range.src_off = src_offset, + .copy_range.dst_blk = dst, + .copy_range.dst_off = dst_offset, + .copy_range.bytes = bytes, + .copy_range.flags = flags, + }; + return blk_aio_prwv(src, &rwco, blk_aio_copy_range_entry, cb, opaque); +} + static void blk_aio_flush_entry(void *opaque) { BlkAioEmAIOCB *acb = opaque; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8d03d493c2..ea121eac3f 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -147,6 +147,10 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk, BlockCompletionFunc *cb, void *opaque); BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int bytes, BlockCompletionFunc *cb, void *opaque); +BlockAIOCB *blk_aio_copy_range(BlockBackend *src, int64_t src_offset, + BlockBackend *dst, int64_t dst_offset, + uint64_t bytes, BdrvRequestFlags flags, + BlockCompletionFunc *cb, void *opaque); void blk_aio_cancel(BlockAIOCB *acb); void blk_aio_cancel_async(BlockAIOCB *acb); int blk_co_ioctl(BlockBackend *blk, unsigned long int req, void *buf);