From nobody Sun Feb 8 14:35:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1588166014; cv=pass; d=zohomail.com; s=zohoarc; b=YHrv5Im6j81Yv/wxGosTlJDa80ldVWaSttDoHNqmku2qcNqj5kAYanSDPCoMl+PTCErGXP8AEIHVYUWmnqB9JPNod7lUMLOjqno55cu8Q59d7c9eMWw2Uta/Vb44CJGxOJ0+uHphuxEsere+20jscxbd34SKMQBiix0ib3FctvA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588166014; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ln4J+gXgYopBJjdwMRlDdnwd0zyUvPHCA7EC1VSZv4A=; b=JL+H1DIeW8F1IzMHoqUTzGr/1YHUMoi5t6flHnK445SZEbgV+icgNG2kj4wLfrm6SdT+cLEY8fk6gihpshGg0hrQUYnCW8G/kdssklx9o3Ij8Bo5w69xCnXTImPnCbD29uUAZyRI0dlnDAE9i/Z2LIq2Kc0z6sQDMkoA6Cf8s7Q= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1588166014110432.73086264074084; Wed, 29 Apr 2020 06:13:34 -0700 (PDT) Received: from localhost ([::1]:51484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTmWq-0002HJ-No for importer@patchew.org; Wed, 29 Apr 2020 09:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34750) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTmV7-0007wi-U4 for qemu-devel@nongnu.org; Wed, 29 Apr 2020 09:11:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTmUz-000856-Nm for qemu-devel@nongnu.org; Wed, 29 Apr 2020 09:11:45 -0400 Received: from mail-eopbgr80118.outbound.protection.outlook.com ([40.107.8.118]:18917 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jTmSl-0007bZ-5z; Wed, 29 Apr 2020 09:09:19 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM7PR08MB5446.eurprd08.prod.outlook.com (2603:10a6:20b:107::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Wed, 29 Apr 2020 13:09:14 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::acfa:5:88c8:b7b9%3]) with mapi id 15.20.2937.023; Wed, 29 Apr 2020 13:09:14 +0000 Received: from localhost.localdomain (185.215.60.184) by AM0PR04CA0031.eurprd04.prod.outlook.com (2603:10a6:208:122::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Wed, 29 Apr 2020 13:09:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sg/RfQQGADZFpnrUdCQ76VDlmjxpmS54qYgTky5fCLVTdQlstlVCPui15227zRqMuaxgsa7Yya+bkQb5isjefPMqhDt68U/l6/ThBUDTsSMkz7J1Yqwer3o7VrTxVA0DZ809PqdgVrCS1BtaoshHZ7Yfs7jbuRmWsLhwKn53xuM9W07K9NByFIkYKSSJOjmhBAaxiUCeYnUq6ayS3dCuMxL9w1n28DQ+YOTVolVoZTa/gwXlPf9PZOV9Yv040i41gS0cgiMddRzDqT3/oU8kK58DjuuuBlvduqvZzSGpG8S41JhxeDAI7/2rP1f6PFz9cNDEMyKQWl1GkLzMLl5xGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ln4J+gXgYopBJjdwMRlDdnwd0zyUvPHCA7EC1VSZv4A=; b=AZ1bW8khu5js54fwEw1Pmj7kq4rezTmvtvDCh9//tKmNBqvOGsotATb2Fm9oXQMqlLykQBSNfSaNwJ/xzD/auWf/iWr0v8AFSaM7xBG7448Mptnw5qUIe+inHE2VqRENN7yc/bw0eC+qJhIuDXyC/A+RPEOWcnZ4+4ZPYdXYK1l/2l70QxzFIUvBBM9j0tz0kM4tjjIxkQ4dCLzSSYMC5WS4ZyAzzROLyGhz3+zyTH9t67hT1UsJcORwTnNSP0wcpxSfaZlv9FZ9l15FLfIMy0rrP4/lxVWYlFs1K6iRD0uEF7eM7jFndyS2nV2RQXf4eq5wR9sYHK2bfggGGNM6/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ln4J+gXgYopBJjdwMRlDdnwd0zyUvPHCA7EC1VSZv4A=; b=qPSQWEgKxrUByXvo1DgJM41BUw0YYPTFtQ49a5Kxg5B9oAKbzts1Y+f4WdvLaQmIlnngTmkjpjuEpL14HnNon5Qsz3iqJy/z49KJFjFs3U3w9DA0Y+07dcWhysbHOALLWxleSmJabl/e7UKhGVNKyfk0UyT6IQk+Hcp7denKmyo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v4 1/5] block/block-copy: rename in-flight requests to tasks Date: Wed, 29 Apr 2020 16:08:43 +0300 Message-Id: <20200429130847.28124-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200429130847.28124-1-vsementsov@virtuozzo.com> References: <20200429130847.28124-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR04CA0031.eurprd04.prod.outlook.com (2603:10a6:208:122::44) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.184] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a86e1e9-bda0-47cb-f04b-08d7ec3e8434 X-MS-TrafficTypeDiagnostic: AM7PR08MB5446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:345; X-Forefront-PRVS: 03883BD916 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(376002)(346002)(39840400004)(366004)(396003)(8936002)(16526019)(2616005)(107886003)(6512007)(66946007)(66556008)(66476007)(316002)(36756003)(6486002)(52116002)(5660300002)(186003)(6506007)(26005)(4326008)(956004)(1076003)(69590400007)(478600001)(6666004)(86362001)(2906002)(6916009)(8676002)(334744003); DIR:OUT; SFP:1102; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fJv9zj73vA8sBV0w2lTuOJFaozCoTrSiKiEOVOvoe3aDkOYFoEo/2ZtPlrgvSDA2PiD1pM+hHyMT+AAIUMew8+1K9FxuQ/V3aIJ+kPcwwxyMSxR+dfw6Q4u56gPYPrgGHgJWeiibSuvSE+avWP+TYuVemF+/eyEKWmm1Pvn/sJXmdH/VUuFnVX5lbvdMcNK1QGF0C+xwqCc8pEE6pNjVg9WROL2xiIzgvpOoFl0PKNchk3ppBZCC+cewPPosjNIKStkBLFnJe4j150dtBSfftQ0sTRmDPodghylzw5OAZW13YP7jjPMfYky+e7EhSugiKQ7e8DI/XnX7UEO4ez1qlCSj5nHvo+OO1myv1dwgGo9PPgCnZDaRIbVBLWBn09pPJb/YAP1f1VpVbofkBu/dwPehgXchmVMvDINS0YiIAYe1spUKUUu1Jzoq5f3qmAgNtKrA3DcncKF2be2SzA73/JE1PxhKD9pxx654GqYu8T0GLC6SiU5QWt80aeJwnl9YhCq1JO6IkhRZT4jKRib8IA== X-MS-Exchange-AntiSpam-MessageData: +OgWoYx522ExxDaJCvLVldO0xBA8urvKJ+2smOWA5XoPyN/Lt7cw3EcQk63H8X6S63+Zqp85LYnNIPHtui/3gqUMHV6Y+vC0jEp5arS9E36iSTtyVTHrJI3UrthCkAw+eHBNZ8OhG1C/t22cQPX5at7lt7NmCQS9Ile1EIbD3VrTWlqOTowEFn1zURbThtGYbTHLwmnXLJpTenEBycuLTIuN3m27IOAFf8Kl3dv1IxMimhJFKvYCKMfoSfHNUE4ow5Uxxl+MQOhWaAIfzBEG5x703FNO7rkezjYEzkbjWh5pmmuL1FwbrqSR3lCG5OW/yWLKzSzAF3jLjmUe1eBuGQUZJOf+ErMSDtyjF6UH/U9VPqSv1z4wZ+GlJxkVIB/vlvph74SE3rcJ3DNWpiwYKLSuCh8WOvGPoUUC+AAjPRD6KI8PFNth4sjkBIZpH9tgox+2MZRcBzB0MOr4fgjXC23U5NobW9H6bTysMcJpLH5SxKnGtjfFcYfElsEcOvS/yz54wVipiK2x7NwAsKjmIrVBAAK042jF94UUdXv3sJ7KonLbFNQhjKZZX5QWQZXim1u7AVHqPrp7JU7UE+OW3ecPPal5Ho1Jx9l7ng8FT2yuISIU7wv+note5To7s8gyp/pPrza/fYQpWhTz5wW1H8eiGP9KREpvHqltS1N38Ct+Y8JzmLic+gUFNmorxKeZVTVqMYEKAOLT95nBKJVn8K9g3gYN+XE+Q0xskD6aO0i/XDukpp67Id74GUdc9YXgnz952O5G93b4VAPN0EwGrscS80k+aWBxktBbl5MHpDk= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a86e1e9-bda0-47cb-f04b-08d7ec3e8434 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2020 13:09:14.8235 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8UXx2O8bKsTrCKiPznLailH0HERgI0+rQlDExTXyez9fX7oIilJR7xHWFW6upOm5J+3k/k8FRxqO/QPy5i7PFTJP9KE/co/RL3c8v/Joc7A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5446 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=40.107.8.118; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/29 09:09:15 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Received-From: 40.107.8.118 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, den@openvz.org, vsementsov@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" We are going to use aio-task-pool API and extend in-flight request structure to be a successor of AioTask, so rename things appropriately. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Max Reitz --- block/block-copy.c | 98 +++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/block/block-copy.c b/block/block-copy.c index 05227e18bf..bbb29366dc 100644 --- a/block/block-copy.c +++ b/block/block-copy.c @@ -24,12 +24,12 @@ #define BLOCK_COPY_MAX_BUFFER (1 * MiB) #define BLOCK_COPY_MAX_MEM (128 * MiB) =20 -typedef struct BlockCopyInFlightReq { +typedef struct BlockCopyTask { int64_t offset; int64_t bytes; - QLIST_ENTRY(BlockCopyInFlightReq) list; - CoQueue wait_queue; /* coroutines blocked on this request */ -} BlockCopyInFlightReq; + QLIST_ENTRY(BlockCopyTask) list; + CoQueue wait_queue; /* coroutines blocked on this task */ +} BlockCopyTask; =20 typedef struct BlockCopyState { /* @@ -45,7 +45,7 @@ typedef struct BlockCopyState { bool use_copy_range; int64_t copy_size; uint64_t len; - QLIST_HEAD(, BlockCopyInFlightReq) inflight_reqs; + QLIST_HEAD(, BlockCopyTask) tasks; =20 BdrvRequestFlags write_flags; =20 @@ -73,15 +73,14 @@ typedef struct BlockCopyState { SharedResource *mem; } BlockCopyState; =20 -static BlockCopyInFlightReq *find_conflicting_inflight_req(BlockCopyState = *s, - int64_t offset, - int64_t bytes) +static BlockCopyTask *find_conflicting_task(BlockCopyState *s, + int64_t offset, int64_t bytes) { - BlockCopyInFlightReq *req; + BlockCopyTask *t; =20 - QLIST_FOREACH(req, &s->inflight_reqs, list) { - if (offset + bytes > req->offset && offset < req->offset + req->by= tes) { - return req; + QLIST_FOREACH(t, &s->tasks, list) { + if (offset + bytes > t->offset && offset < t->offset + t->bytes) { + return t; } } =20 @@ -89,73 +88,72 @@ static BlockCopyInFlightReq *find_conflicting_inflight_= req(BlockCopyState *s, } =20 /* - * If there are no intersecting requests return false. Otherwise, wait for= the - * first found intersecting request to finish and return true. + * If there are no intersecting tasks return false. Otherwise, wait for the + * first found intersecting tasks to finish and return true. */ static bool coroutine_fn block_copy_wait_one(BlockCopyState *s, int64_t of= fset, int64_t bytes) { - BlockCopyInFlightReq *req =3D find_conflicting_inflight_req(s, offset,= bytes); + BlockCopyTask *task =3D find_conflicting_task(s, offset, bytes); =20 - if (!req) { + if (!task) { return false; } =20 - qemu_co_queue_wait(&req->wait_queue, NULL); + qemu_co_queue_wait(&task->wait_queue, NULL); =20 return true; } =20 /* Called only on full-dirty region */ -static void block_copy_inflight_req_begin(BlockCopyState *s, - BlockCopyInFlightReq *req, - int64_t offset, int64_t bytes) +static void block_copy_task_begin(BlockCopyState *s, BlockCopyTask *task, + int64_t offset, int64_t bytes) { - assert(!find_conflicting_inflight_req(s, offset, bytes)); + assert(!find_conflicting_task(s, offset, bytes)); =20 bdrv_reset_dirty_bitmap(s->copy_bitmap, offset, bytes); s->in_flight_bytes +=3D bytes; =20 - req->offset =3D offset; - req->bytes =3D bytes; - qemu_co_queue_init(&req->wait_queue); - QLIST_INSERT_HEAD(&s->inflight_reqs, req, list); + task->offset =3D offset; + task->bytes =3D bytes; + qemu_co_queue_init(&task->wait_queue); + QLIST_INSERT_HEAD(&s->tasks, task, list); } =20 /* - * block_copy_inflight_req_shrink + * block_copy_task_shrink * - * Drop the tail of the request to be handled later. Set dirty bits back a= nd - * wake up all requests waiting for us (may be some of them are not inters= ecting - * with shrunk request) + * Drop the tail of the task to be handled later. Set dirty bits back and + * wake up all tasks waiting for us (may be some of them are not intersect= ing + * with shrunk task) */ -static void coroutine_fn block_copy_inflight_req_shrink(BlockCopyState *s, - BlockCopyInFlightReq *req, int64_t new_bytes) +static void coroutine_fn block_copy_task_shrink(BlockCopyState *s, + BlockCopyTask *task, + int64_t new_bytes) { - if (new_bytes =3D=3D req->bytes) { + if (new_bytes =3D=3D task->bytes) { return; } =20 - assert(new_bytes > 0 && new_bytes < req->bytes); + assert(new_bytes > 0 && new_bytes < task->bytes); =20 - s->in_flight_bytes -=3D req->bytes - new_bytes; + s->in_flight_bytes -=3D task->bytes - new_bytes; bdrv_set_dirty_bitmap(s->copy_bitmap, - req->offset + new_bytes, req->bytes - new_bytes); + task->offset + new_bytes, task->bytes - new_byte= s); =20 - req->bytes =3D new_bytes; - qemu_co_queue_restart_all(&req->wait_queue); + task->bytes =3D new_bytes; + qemu_co_queue_restart_all(&task->wait_queue); } =20 -static void coroutine_fn block_copy_inflight_req_end(BlockCopyState *s, - BlockCopyInFlightReq = *req, - int ret) +static void coroutine_fn block_copy_task_end(BlockCopyState *s, + BlockCopyTask *task, int ret) { - s->in_flight_bytes -=3D req->bytes; + s->in_flight_bytes -=3D task->bytes; if (ret < 0) { - bdrv_set_dirty_bitmap(s->copy_bitmap, req->offset, req->bytes); + bdrv_set_dirty_bitmap(s->copy_bitmap, task->offset, task->bytes); } - QLIST_REMOVE(req, list); - qemu_co_queue_restart_all(&req->wait_queue); + QLIST_REMOVE(task, list); + qemu_co_queue_restart_all(&task->wait_queue); } =20 void block_copy_state_free(BlockCopyState *s) @@ -223,7 +221,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source,= BdrvChild *target, s->copy_size =3D MAX(s->cluster_size, BLOCK_COPY_MAX_BUFFER); } =20 - QLIST_INIT(&s->inflight_reqs); + QLIST_INIT(&s->tasks); =20 return s; } @@ -474,7 +472,7 @@ static int coroutine_fn block_copy_dirty_clusters(Block= CopyState *s, assert(QEMU_IS_ALIGNED(bytes, s->cluster_size)); =20 while (bytes) { - BlockCopyInFlightReq req; + BlockCopyTask task; int64_t next_zero, cur_bytes, status_bytes; =20 if (!bdrv_dirty_bitmap_get(s->copy_bitmap, offset)) { @@ -495,14 +493,14 @@ static int coroutine_fn block_copy_dirty_clusters(Blo= ckCopyState *s, assert(next_zero < offset + cur_bytes); /* no need to do MIN()= */ cur_bytes =3D next_zero - offset; } - block_copy_inflight_req_begin(s, &req, offset, cur_bytes); + block_copy_task_begin(s, &task, offset, cur_bytes); =20 ret =3D block_copy_block_status(s, offset, cur_bytes, &status_byte= s); assert(ret >=3D 0); /* never fail */ cur_bytes =3D MIN(cur_bytes, status_bytes); - block_copy_inflight_req_shrink(s, &req, cur_bytes); + block_copy_task_shrink(s, &task, cur_bytes); if (s->skip_unallocated && !(ret & BDRV_BLOCK_ALLOCATED)) { - block_copy_inflight_req_end(s, &req, 0); + block_copy_task_end(s, &task, 0); progress_set_remaining(s->progress, bdrv_get_dirty_count(s->copy_bitmap) + s->in_flight_bytes); @@ -518,7 +516,7 @@ static int coroutine_fn block_copy_dirty_clusters(Block= CopyState *s, ret =3D block_copy_do_copy(s, offset, cur_bytes, ret & BDRV_BLOCK_= ZERO, error_is_read); co_put_to_shres(s->mem, cur_bytes); - block_copy_inflight_req_end(s, &req, ret); + block_copy_task_end(s, &task, ret); if (ret < 0) { return ret; } --=20 2.21.0