From patchwork Sat Sep 4 16:24:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F63C433F5 for ; Sat, 4 Sep 2021 16:27:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFCE660EFD for ; Sat, 4 Sep 2021 16:27:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CFCE660EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYVi-0006JZ-2i for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTZ-0002UB-Hp; Sat, 04 Sep 2021 12:25:05 -0400 Received: from mail-vi1eur05on2102.outbound.protection.outlook.com ([40.107.21.102]:64544 helo=EUR05-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 1mMYTW-0007MU-PN; Sat, 04 Sep 2021 12:25:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k5iyp/HBfDl1k3M6lgRbGyXi5wfFQnScK9HncYQ8P/BuTZsEM9b3PCwBjUDvOMQpZ7VOXh3JDjvItEp+x0FTct/oHCDUdnRV/mKcGazlOsRl2gt/5nrOzAHZCqKybjIiRaUUie8wddIRuITWuPlvCBA7uW1doyHrORQvUQy+fzqZfhoiw/Jiz4WHEpOrQNiCuUDQP1MWWgXLZEFOY+PE9REma5eFITb0i9VxXYAY2hw27wVUTlZLmulqQYJB54YSzcx6sZQwmbRlp16G1SFeTHUTvn9qcgG0sDN48gB1rOQgnnDepztO0anfFrDgQPr5o4MBgn7Od75eJwnQ3NsRNg== 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; bh=edNG5+/Gx3BBqfLjoEG7swLq9drCCgu1BzgGL/EUQxg=; b=XPfSjrDaBwghUKh6zWJCH1mnhKHPdCH+FaGbu8G7ldcaCYHc70OwnAo4TXYnJDH0Suoej3jj8FP7gJy/dUW07hzNPyDiluH68Wl1WlM9TaGJJCS1X+lBwfxjrpbiiaDgIsqya+2xcpWMiRzUkh3A+Ryqu1NvZhRB8XgAzbEjyrCTN2BKSrXo64/dMBrgy5VGagTCd7CPiS0HgLtOdecf2kzSjn9SN4O6T70z5YOgSdaz3/tCHaNjRofX8dmnnkonzkkJWqlsCcJS3x2DjYItik8/eWHi9W2CeqEefomc9zKy9hceSi4hbpz8444oliZT5S510TB4IJ9qXwVOVwVOjA== 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=edNG5+/Gx3BBqfLjoEG7swLq9drCCgu1BzgGL/EUQxg=; b=H93JnVy3lS16PlJS7u7xQgVBDXKQAia1eR0iBR6YpjCHkU3TJKbAT0Mx53umxUx52jgxX6YpfjoX1wv+Z6bFKcdG/fhrSnJcymkSQj3Kbrhj2EGD37olfxGpTBA+FHevg/FdEdPaT+kPA0N/Fdre8XppTk8su1xHpB3IEkPuoeo= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:54 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:54 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 01/11] block/reqlist: drop extra assertion Date: Sat, 4 Sep 2021 19:24:18 +0300 Message-Id: <20210904162428.222008-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dd52a992-0956-4267-0c3f-08d96fc08727 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A70cI7DeJRhfeCg4rOeELNoHr5IwKSkv3v7zI6jDtpQigx/LOW/XQpojfK62EgRvPjL7FdF6f4x+CjvSjIDKNJVH2TpPo6zeDnZk/H5NArg8rI5WwIUW0hgrV49Os9mZt5hsg5Mhc+BJ7d+Bx/xR4zw0uf9ZQeuvOHSdEJplVc1lsDLlfVAqEfpyfSYpHwQ2rRXxmLcLzQaDjP6aEmDd+DHCq9MJfRw1H+TI9PlbPBE26e+QyqPBenM/Bxcb+2keL/4uWA4RsLPVPzsmPKc57F89CsxKVsJ4K6AXP16cVBYhvDmyhkOyK65JMQXE0+UzlmDAxT7/PinwRRGHVRCMI/cPBaQlHQB7bM3NHWLMLZ7q+K3SFbTlhJKbyb0qcRM71OFhJ4XZKJJxcRKVqmIi8yP+vsChMlxuwiUnufGhUrT3sAbdzhv5ihY8PIpAaHj4bJERmx7BiPNA2mlpvskNHJ5/GABr+HDsXyZWi7Wvjzoaor4mYclB+swr6Ru9VzbwK/fU93EZPRTCEhzf2uldlKKSk8LpXAuiOlXwwQTJ3Za2JtRki8OOTvFrw22Ic0TN/UvspYrRY3UJ49AJ8dxqeoB3c1EdnWQnsqhPAxXhur27+16G9fAgcZrKiDL1z0CdWnFcddzIlSaDSmsrUz9OWdCllNzUKsBftJGfBgwaTRAohb+lVOFBS0146A3EJXKpmaa7GA5DIZ3A/InPFpL6xA== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(4744005)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9XMNDWlUeszVhGbdnip4OXIK8F7y54ybN1JH+76xlASdk9DZhqmuPoKP9HEiY5B599TS6dJEc1QaIR9mR6exOC1HrI4dRzytswDOJiC8R5UrLpPY5Lm2g/jCVA14ET1HGtT+w0NiX9Y+yAf0W1SzujPp/OKtbxgflw0EJKJDCFsg8I25pXbQfwOcz7WVd+V+wZmKZ59rENNP8WO+4Y4ZBWUk/go4WHviP7icfgbLm0I1/BG2IyzyDUmBfh1NtiRjaKfgjzkYw7XpVJUr5YsTdRqbuajcavdwx+R+dc3eoKaGry8PmEmU79MgXhMD0x7gs5QD7F3B7XQH/bDg274l3TyCY3jslKj5p1c7oPo+ip8t6EsjK31pxRGhWR/DokdGKj1YYeYV0CcZknn3sdaXEqDB1hrN+blHCxa5IOEj97g+kQjOMe59SuQsOQXFkMsPRaL2Buig1o5iT5VO/VMre5h7cvFY8GwLgi79uvt1/OR+T5IcXvDsIhGrhwWosLAA8Ejw1fcGHQD8BZS1OkXBYSQlUYoXUuUU5DfM/u35S8cHCSxeUB2LTfhiGc0SajHclH7DfJ408oQJvvCI6lUSh0a772pOZeil+UAR3WTDtnrH8+FtH1gjGswZeBQpq/3hdT/2rVXm/KEjPrz2Ie5371zveBG2z4P7iAJRNHZVgf2oEDuQZoTYa35fJPHYk8X/vgLZyVA+HyaQzyOJMZvX/5+tK59x0V4mP7eJIyda9aDjz7W2aMeG07fL2wMT8wOFJt6izHc23JK1Si+hwfsO2c7eYWK6NkxBI3W6NhRhadDR9V4jW1y3qGmRqKK/WkvdzHgWAyS2TMJlNEVHc1rzU850F3vOWV8jpQFka88E5ABEg3bdyWYDvuGy44A762/2qpMTkGIMgPV0/Oy2V2QoMwcCsLY4Pf6x4B4e29CQkoQyayBlNaj+1JmAvh0FlRuEEL5imRnGu7lQscRrblaku7YtU+6D5DasL+nVnAvG17BjVN+0F+8KmkBSlPPFldkliR1jXGPEfjZYLura2wozl8ogMagqlQecz+HPl51XKqi+Emb+N02b5USUl8tc0P7kRZ63DGipHwfA6Z30VqQ8AUwQ+yfuZOfsJNir99wth+AngGSGW/pBNUzilboaEtn0pqGOXvqHZlirt9MVw9MmUcb6oObmZk9DZZKSzzaKZ58mBImLo3/EgkhqjgZuSViXMZnf+2hwJSbBwWj7AOr9U1Zk+FTM5JlOkpZIBBE0DduczbGvZY54/CkDjUWyXMkMgHG+AaMChCZbVSrc3BebHhpIuliDy9xGWeWf3bqldi4+WY2Yq6vjMC6LpYjzlWc3 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd52a992-0956-4267-0c3f-08d96fc08727 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:54.3803 (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: YxIvE1I1d8BF1oqrpw78NNmHLXd8EZYC/tB7BCFe7j5AFmAw0hKe5Wtl2N9AJU4R4DfcvUUt+f2hISLgAxohJAt9H9eyLv+a6ZZOTp91zhI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.102; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to reuse reqlist in conditions where intersecting requests are possible in the list. So, drop the assertion. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/reqlist.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/reqlist.c b/block/reqlist.c index 5e320ba649..c580752db7 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -19,8 +19,6 @@ void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, int64_t bytes) { - assert(!reqlist_find_conflict(reqs, offset, bytes)); - *req = (BlockReq) { .offset = offset, .bytes = bytes, From patchwork Sat Sep 4 16:24:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0971AC433F5 for ; Sat, 4 Sep 2021 16:27:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 363EB60EB7 for ; Sat, 4 Sep 2021 16:27:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 363EB60EB7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYVZ-0005or-9K for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:27:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTX-0002QA-Sb; Sat, 04 Sep 2021 12:25:03 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTW-0007GP-0f; Sat, 04 Sep 2021 12:25:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/6A1p9q85PkSSDeT5aiH4xvAaV7KDGQr6yfDo1LHkMnAcuwIhDlnzy8orflSBOrHE4buLdvmdVm3n7md0LT1YiA0g1C1aUxM7sFkPAryFtyC+Bqx9Zft173OugfMIxlGMQC4vCvi73NuYxN2UsACq/xCZrW2p2rEdFjGaye6UPK24gwZF4uEwCC/h8N2l0dnmE7mnGT4Mo3dh9J2e4K7WzXnaq7edT2xrFJf260S0POL61GsM3jXU86Y47bfYt9JaU7CKM6Y3zTp1uxbW0cLi0N5p7I+T/fBSot+7h2StbrI1/XJ8/bn9fWDeEfeXfYwGo6aSa8dv9dEow0bqYRzA== 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; bh=I9Jtv1DP6rs/J+W8weW3o3sqgzZ1lyN4tEXcxtKx+lo=; b=Y5L9057N9iFnFw5aZFavjZCiBNMpKjFfMMI5QvCG/IVYd6KBCHFz9vO5kyhek/eEHPFYrYk2aJz8EHwbfB9IFsih+9NJKabemMYg0LRnAAAO7YTMp9EUCtcBg2VhryxDmz+2dXhrPSH6pCU+VdBuOZcNKKRgUh1SMBJn5hL0cNh6nVGvDsKejuWl9uOWiNLTbtJrrXdUc9hAD95r6sqZs0IUVBcJRSLAdOvKgLlaoAoGyaDg7Hs5VLQs4iHOnH+TheAFy64Fu/o4xqwQZFRGADjrsdKvLhkh/h476AkLx7/wO3AZPYAy++6qjnu+vn8aTBQHrnu3oEFjnMrjkr9oyw== 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=I9Jtv1DP6rs/J+W8weW3o3sqgzZ1lyN4tEXcxtKx+lo=; b=A3ZtHutpuoWqmkP06Q78t3QcZ8S9Pj9/CU+bRXhQKKsskPI6NhEWwVPpAQRUDLzn6L3Xk7UYmYEDVWV9MzS0c2FrYOwxSuXm4gNaNn3PMrzFQqsB9Ofyhb1Di+FCxhpHTYyYF+jvIFnasdvBbQ9M3c21JskhcWyfUrl48dfeNpI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:55 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:55 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 02/11] block/reqlist: add reqlist_new_req() and reqlist_free_req() Date: Sat, 4 Sep 2021 19:24:19 +0300 Message-Id: <20210904162428.222008-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 317200f4-0aed-4322-1d52-08d96fc087ea X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1e+35RlfEiuQfku529SFvGUz8agJz3AvLAakcnkf4A+9bSyNFXl1NNctYx9nbYb5+3ojASPHXQNsRwAwKnbPCL99Yuc1kdqay3a9pfHLvTD/tZCNhSq6HUG3SlVvSFTykaORZpfKnyRcYllerWwpiUjPW15898XThr5qKPSZV1D0D4uYKza5L/daFSa5h1YZbULNEjpOgHpc9KftQqY9FI3Jpg/NM8mYI/Hz+G0PA+3a7s4RKqEOBRK+xe9u0hRBYh2y9wx3rocDlwPPC+dv9j1QIieWqYhrB2f5zJeOInzzwsAZnSkMLCFl6faEl1KvuHHDJ5YAEIzT1xHlW0IWIwcou3wfAOQ00rqsbORe3ZCpPDrUOY6LId71VoDw+W6rZvhGaXy0Rb1aAMoQwyFBKUahN7Bsg4rIR2T1SKWC4Ss6lug8JvT8yvAWxyzbHhwRRhHJatOHmvFE+I+MN4bSmzX6jtyYvxethAlJ7jjxrYKBYQzE+pLKlZsFNy1CSaI7b48RkgupYMEWcQ/d+sx8v5sZJ4+W+I/AuYiCjFgtX7fYffj7wMaJupFWZz8/um5GHbrqvzDws+dQT1FZy131TZ1PJqlUopzsrnrs90wejfKx0m2OU5Um8kq5kiWYmsEUbGworCwOaFHWwDRk/yAAqZxNEwM95puU5d0Ia7A73RVoCkxA2YvfkXskClOB3VimHaft/B0AEmFwprt/mrw6JA== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(4744005)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Viu39yUyFvQR3PJ9+eayftb9y5Ut6NnQkWcsTbE5FeMZmtQy4t/Ypv3JwH136hgBxhmU7B+3u+S3cleCsRa6fU80JdeElSL5iGZkaUihXBbuP68oMyHNSzSQnCedYFvqOLyill2F3uvAM1kuXnXEu0JWs+0XSDf3MahLGCTxE4xjh94HXcL+d9/rGclxAWTwaX5XBzI+LBtwfqFyfMCN8W9Mg14t07f/T7Z8i+3qYnQQYogtn5tFQPpOINLpT6o7eyUp1FcZeG8Y75444+fbJEPqeVSiqNdnYYXNVLC0ANI6Y9Wzp1/fuC3cKOCUPX5HHo1/sUQIplKssnujK7uJtOvZRbmGIU1KfJ8G2TlKwOJhJyYYkQIsekwZCeAbdLKeEN7xRwFrMnd0sxq0f7JbtJRZo2PwA5ZfPFPsGkexLiqGTq01fmKrgMqDRt/AFqgb02ZUX6Mnp1BJ7ccXNKwDyCC8+JKtTY78TO2s+hxjWS7d4MvT3rpU78U22cGEPhqOrMOtZ3Ma59gfCL0CFMDr/PN0/7JKJi946/T2b7wRpNp4NYsT57ElR1GqLUSP3Qk/MZ9j6Dvz3m79VIuDA/ZqZsPLpxWYPdJHogB0BXMiwN36gCU/CpPgCohIuLLZRyBaXYmQ/QVnhDHQGGkRMwLmmShshq8is0rjXtB7AgRliI2h6HCQdevCEcFmDIulcrN2s3GnaQHXbcxRQaK69xS/2rJUBXCad48A4u2TIXbZi+ac+Oi1eM5CwQENnv/sWCVZq8tduVqidEAAs4qI5WJNC//eiLAvpfxQWwjcA39ki3+/oWrxUZz2/8R6I5bWMngDDN4m8eeJdZoPSuZgygZnU99sdKT7QvW+utMTF9R/O2NdkIgedo4bettfW1eCb3t7b3DpLSYCkymAmneAtyVSLK7+DbIp1Y/FVd8l8Eqt6XTHgI0WwaWN0VdBufEoly1Poo+qBB5dphWxdA37UgGJVxutiLDYYBIK7UmbJDNyTfgqNSztd2iRnJqslOnmtKagd3vNiYlOVZYH3jFhrzq2me5lZaFQ2wKF+WynxfOcvUR4bHQrz9MLplsnslTi7y/9VadrqxwlrAjJ6AyWbfsa1GQRNjWKsPjMpqAi+muxnihNkI4U9/IlHXz6fyQ/q+x1AvqOzg+08xcpLF0FAYOTj2047aFiZQ9wg0n2j4+L1vtbnGxbW9yEEFQPe+e+1GYtbpjSBn6o+RVEmZTwfRo6K/N+xc1oPNfEKq1qRG33bWde55UWv6jrkgwiAAjYNVlYHawn7gT4qQ4ZuTLA0VC6oKD3zeSKe2ucX1PX3B8mm1GspC5DEI/nM2UbzlK2Ik1b X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 317200f4-0aed-4322-1d52-08d96fc087ea X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:55.7871 (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: esORg8TupAA3Q/UlwAZkkNduR6wq+eZEOcGFAmX2ts9SGmuwH3XbClRuMWMz8DYpMIMFENNUWHoSeugcnjAZLoLagXTxfeQstuKENQpUuIs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add convenient helpers for heap allocation of requests. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/reqlist.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/block/reqlist.h b/include/block/reqlist.h index b904d80216..32dc87666f 100644 --- a/include/block/reqlist.h +++ b/include/block/reqlist.h @@ -64,4 +64,24 @@ void coroutine_fn reqlist_shrink_req(BlockReq *req, int64_t new_bytes); */ void coroutine_fn reqlist_remove_req(BlockReq *req); +/* Allocate, initialize and add to the list new request. */ +static inline BlockReq *reqlist_new_req(BlockReqList *reqs, uint64_t offset, + uint64_t bytes) +{ + BlockReq *req = g_new(BlockReq, 1); + + reqlist_init_req(reqs, req, offset, bytes); + + return req; +} + +/* Remove request and g_free it. */ +static inline void reqlist_free_req(BlockReq *req) +{ + if (req) { + reqlist_remove_req(req); + g_free(req); + } +} + #endif /* REQLIST_H */ From patchwork Sat Sep 4 16:24:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D939C433EF for ; Sat, 4 Sep 2021 16:28:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5D6F60EB7 for ; Sat, 4 Sep 2021 16:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E5D6F60EB7 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYXJ-000191-0f for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:28:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTa-0002Wd-Fi; Sat, 04 Sep 2021 12:25:06 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTY-0007GP-JL; Sat, 04 Sep 2021 12:25:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TM7yPTKv+GK193PcPYPOtAr08mvVb3g63NDhlz0DJenxBgUWjYuWaFWTm7xbFfNv0Ym3btvidCIU2GwOCZkisKFoF6NqdGTUpKHVUgqKzM8JehNHYEjNYsy/M659IIHAGqF26uVBUcH8WK4cB9piduXggzpaDW9C0ITusBALwLmhGjuqLaHyCiGqaltGUuPsLTofZU6bZBu6h4nZD5drgwDf9uFgYRZVlANY9WHakwnrdnmiib/Bm5uJVt4EjAEpi3LH/WVEaxH3xQKct2+0t493Niq3TGu0ve8lUYKQ6nVbRsuxpTfaLrYQNvFY7rKKmjbaMp2vCft/+IRsp/xrcA== 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; bh=iXZs9GFBvUAXNvJ2vlQnOgXar2kFLPug2NV9BHHGUJM=; b=JtG4xI0lCvzV9V9FohbbSLK2QMs0s6H2IQ0t2DvXy1Afnz7AU7ARYi25EceAuK4qFtc93xB8ix/tenuutwHv2A1kcToWidKnF39mIVvbNNaLt7AsDrjQKBkBbabdu+gXoa6y2F+Zi2JUVixBrro5Qm3nJK5ol+o4R7+ommjvh7Fuj69Q13PzT8bt2K990Qu25kKsx3FZDbBPwbQnlZ+RNXdRn6b7aU1QgMEchlj9NLRxt7BZcq6vRFQqic257SVxMB6PhRJpfWEOBiX9/iFJWur/4pjcznNyPvpNA6Fa7vR+obvPlRB0YlgrZnyhPK6egOKFtzkvXTVfHhhV7/+4qQ== 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=iXZs9GFBvUAXNvJ2vlQnOgXar2kFLPug2NV9BHHGUJM=; b=p35T+IVplt6q1WYD1mZg6sgmEc3d//qja/V0pjpaSSE/B7/BAMUFpirPhjLxdnNVw+buA5sDiwSctsviNQeg9RRRnfDUC+rBy+NjnVbtEwt71L8rO60/kV645bGH905ZpGMEJq50Gd0dGwoQUgo9wsJTbk4NQN9dSq2UaelcMsg= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:56 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 03/11] iotests: add qcow2-discard-during-rewrite Date: Sat, 4 Sep 2021 19:24:20 +0300 Message-Id: <20210904162428.222008-4-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd5ee6d7-89b3-488c-ecea-08d96fc0889c X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8HL8bAtNVY/tewHn8O6+Gzx77utvbBCd8eAWxsIkCcy27of0hJXtvBOQCqHAxhiOE3FpT/M4wbUiqr1rKRM428PXCyPQMZqImPsXi3Vg97VO3Lze47266XJk4Y5VRhkpkIDGI4LrhDVkBCjSflTfLivYybh36GsLnG6ZHZZq/oi8j6dvM/CldXHEdlzudEHKkMOe9agjfQFDUgsYcsK9RkBtlfFre6VwmiPUbGCLBSJbQ1JgTJSh5JHrDACd+KUXhGQUq5J+3FjHqFLlXsUEdmseTUGmGwjuh4WjVvSvk1a40tzP68Lu6AT6LplzRvhV3TQvMhJp+WYY3ZDHwXkSIZTZyNKu0o966Kqsov2ezxmdPoX0GSxP9KDzr99T7FYIz76S33PpRK2TcXTuAEwjEwLzMXzPVqrcBUpJN5TN+3akFCm83tZGtEpAKuo8KBSvdrNuMin42Yfos/WI3AKUkRdgq/MQeplcn5W1c9OPXBy9upHX5+eByYvwEhtqE1uAG0nVp4MVE5MajkDbgeO4F9w4/MGAyhU473Lco185cW0FNhcrmBlmjF356Vl7Ihy8nq1QFvyIndE5Gm0YmLuDvnHcA3N8sEVJd87y00HyvVKKSNNNqRxGB6ZH2kM6Chresld2RtPGGqjhCaVxacJ8KRPEXyD3d6FFv+hjaSsOQuo+z3GpIFQpwsYU/Wb97WwzPUVf6F3LCFiKnEql5IB6kZ8hsHF5N1+dJuAv4zieKKjZ/fgqYSCxeqFH3/zg74/ZHMuCp2rF0RGXGLGL6rq4Cf6M0IzhNY71edn4AXSucLYfu7dCPUJQGbfGaKAxOGCZt44z0wFMHELNFC8U/XbKuQ== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007)(2004002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M3ic+ZHSs2yuGHreoqC+nn3aHNr4SWzuNa4y2rmaCzq6Jx0k0Qx82ElSfiKeVZK0QhTc9Xse38qcDmEz4Eb2LbFTpaHcKANXcN3QlI9EUbqWp89igRaUsbvDnv0pVBFF7T6qDF0q8te/j0PdniziIVfnBv4jUTky+GeDW2D2CrTMH91+xh+JJ+2SpoFouUE0qF8c/EE5CmqQqA6nJmNfKFbcL7xmBvxNJ50x7FQifxjU18ed1MpGQXFXiLotx4ziOo7l0ZfHzC31xeQeHgp/X3XxJ0e7Bt9ZISpzQSDrNaxlHap84vOea7DOpTNoJZJexZmm/63kScBX1U22IqEOYSqn3uQOYzMkN/L3sVsrR3DLUQgiqFLsKdO+Y+wBgjYdwA4Y6MjVVDC5wvvd5ulBAKsDrFDU6Pc8RImi+gCty4Lzl7Ek4FAIby2MTaaDO/ie8oS9pldN18nMcVGt6RJ6SCBbkG9kBQORxwwwHgBXlKNTlO41N6G4y8ZP5oLQDaBl/w53H9TjDD3VpQ0wwyiyHizMj2+0h3Lhu2W25BWjwzc+tHB28LqWd2KKzkxKyD+MsHc4EmeBG6+TpI2kgZXxgQcDvA4WZXZQpQkrOTND30MlebmIL77iZH6IMVSfYWLZQ9WWj1T6v7TKhNmSFC8C3ef4Wt05Zb0PcQZEa9LwGEwqKi6p6yUW41BMqaoXkOfHoa5QE08ExBm+ifu83QTVc2xY51rccHJ6WD0Ftoz2Q1WafvAdlZaaLbNvQPJCTIAa2Nu4a8ORl6zy6+9VSQ7I7a8+qeJ12jiCqpDtzOsIMTmRk9YaeY7wRe9Mx+td224Zw9nPYWz7N8wEa98OwylT5B/QrJcTaiN47zPJeCBwaxE1Wl7nFoQhmeWyrOc0iRXcuVzI8nXU5vWJSoHU8z57c5MKSiHYTDbfmM3x5l/wm53cqYhNMAOV714sC7k1N52m8QCXxFlnfPSBP5a5H5JpzspOzvAA6xuYdcP9vc+0+4PsVB10mdytBK7WOh4m1sw/HiiAWl7QRUrLNUvhZ6lYaTtU4ZujjS19eFqzfK3nI/V29/R/uG6azesbrxb9FFf3hARp596QIs9ONrBIUdfPqJSPEvlv2MMOFpL1n0uMrQWDRbgiAomk2+FYsI5K3Ww78iG2n5ojqw1s1L+E43tzdULhKNBbpUxJ+3uRx2rPJKGbyyzPA920go7XLQzkjTxCGq+if6l8mhbCj6ghbaihLqP+mnnVWG+dcj0UWFBVgsEvyCnlEgO58hm2jpn/ZxhipJQWXVPI4O3DNMZe6R/AkNg5BX8g0Tx1b+esBQPNw50iFDWWMTdD99QEf9eUowQm X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd5ee6d7-89b3-488c-ecea-08d96fc0889c X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:56.7090 (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: 7z81eAvtOsQUxZ8hki3QkWTK9jQNDfebti7RwlogeUKfukXg2e6+kx6Wf6icM7GB27+WY8gLXtltHu5qpmbb2kbdFrhsyO4oO9Wlr+xNE4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Simple test: - start writing to allocated cluster A - discard this cluster - write to another unallocated cluster B (it's allocated in same place where A was allocated) - continue writing to A For now last action pollutes cluster B which is a bug fixed by the following commit. For now, add test to "disabled" group, so that it doesn't run automatically. Signed-off-by: Vladimir Sementsov-Ogievskiy --- .../tests/qcow2-discard-during-rewrite | 72 +++++++++++++++++++ .../tests/qcow2-discard-during-rewrite.out | 21 ++++++ 2 files changed, 93 insertions(+) create mode 100755 tests/qemu-iotests/tests/qcow2-discard-during-rewrite create mode 100644 tests/qemu-iotests/tests/qcow2-discard-during-rewrite.out diff --git a/tests/qemu-iotests/tests/qcow2-discard-during-rewrite b/tests/qemu-iotests/tests/qcow2-discard-during-rewrite new file mode 100755 index 0000000000..7f0d8a107a --- /dev/null +++ b/tests/qemu-iotests/tests/qcow2-discard-during-rewrite @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +# group: quick disabled +# +# Test discarding (and reusing) host cluster during writing data to it. +# +# Copyright (c) 2021 Virtuozzo International GmbH. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=vsementsov@virtuozzo.com + +seq=`basename $0` +echo "QA output created by $seq" + +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./../common.rc +. ./../common.filter + +_supported_fmt qcow2 +_supported_proto file fuse +_supported_os Linux + +size=1M +_make_test_img $size + +( +cat < X-Patchwork-Id: 12475691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C3EAC433F5 for ; Sat, 4 Sep 2021 16:33:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D336E60F38 for ; Sat, 4 Sep 2021 16:33:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D336E60F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYbS-0000BY-TG for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:33:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTc-0002ae-7b; Sat, 04 Sep 2021 12:25:08 -0400 Received: from mail-vi1eur05on2102.outbound.protection.outlook.com ([40.107.21.102]:64544 helo=EUR05-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 1mMYTa-0007MU-BS; Sat, 04 Sep 2021 12:25:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKbBMe4d6A23Q5kzvaO/nL8e2r8qSICOkYmD1dtZJd+ZNCG666XhjpWykWmb83FA3fxhwoucQcQ8GJ255ZJBsp1P6AUCg2fxd5EI+IbMYBmnwViMbkz8BNcq5EBsbkVU9sFj3vSrtgVxEalCicLIOLqU7YOLuBqGHQ4rnJ1VpcA2nYQ3mB7/Jd5tAOyplhYnTSccldXrUvU7vlzLgtm+++Pcbu+PPvPbAi69IqsPFRRKdMEiqEcmW+AjxrZvUF4TFTCj+tBwdoIMhBCPhMpjjgHNCKFvJmFkRdlPNbBCOCWMd/yt8GuxF9ZB0kuDeOsKw/GbyIqVQWBpzD6bVLXq7w== 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; bh=CcURf/lFhcsYAxwLtqa7e3ZB0qF24OaX1tymCrJJVsU=; b=bHIvPmgqymlFEppGwDQuLZV3NzPr21TnkcAIZJUcnZGVJbmyu9wxKKgacLloixYSgQndRAlsXwWD/E2zW+q5AlvwQUpGYd8FStEKtYE8smmIs/KpY5/5qqeNIX8RSSgEOfG6ubBpXE40BPaJcQwJPNT60E9D61ZkrGlayv1mrN++AKudPfuksF3GYywN6EpidBp0HDgn1D3R6Jjc6SzZZ2rMCXsSVT2W/fFoQsoLHWH+htCIB0zkiFZQWvYutf4PdPnaaOnqPCZZaKqvdcNZmu85QIizhju140JYfpENCIzwoe9GuuOBvCtQcBFA9gT1o9igQtGvPviFHdhik+ANSA== 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=CcURf/lFhcsYAxwLtqa7e3ZB0qF24OaX1tymCrJJVsU=; b=I9XxoJ5wVw/POba3gubg4kRlyHATT8r86cggpSLVwA7gQp46TwvTZrvl6Bj0Q40xCZKNH/DYlBPHSNmxR136t3lnjRAYub9rBOT2D1D9ZGHMP+cdgqVNP1XSN288uRwjv1BeJZp4rIwLe+GRqhEqJqzljrbDKy5kP9/Kp2w3i+A= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:57 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:57 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 04/11] qcow2: introduce qcow2_parse_compressed_cluster_descriptor() Date: Sat, 4 Sep 2021 19:24:21 +0300 Message-Id: <20210904162428.222008-5-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb830fca-03a6-46ac-e289-08d96fc08937 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:148; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S9vdKZY2eHvWNFqsQUeaUr18h/cogZqeCYTaXz5rbrLDhWbCziWdGfX4YfXNcg03UuVmIUYc89bk6CsWAv9HHDGY/Pp4lcC+wrLQg6u7LNhhhYUg0q2riekv/YNbnjuZSfMWeky/ilKfxrVNAnpJjwklqQmIh1RFwjlfLszg6NQq95ZcYSEmn3RHI9t4NBlOn2FqZFW7XQgiLwM9ov4FFOocToRmIjNi2wLb5HVJrqcTxHg4x+Pf/dLU8MaNDeieMmprSjCTTSQm1CsRrZVeipJvOU9Sxqmkj2WRMKWCYLAcPupZnKwnHnfmA5nyVWCXDf+7m6+3VGIlmV36khyoLfG4UknrNt8hDRt1DY74sD3HIzS0gCV7ZmgG8C2ZH5+dtI2+LUg2dNe4Ag6gWign7fzL4jNzzOx4sTnn9ndK78FLF2mjM7x+GbF6eJTsM9cVQt4m6LQg+Mz0CQMUqJ2I0dyYZ4bxko43+cimc2PVkWHePaXomV+97tNd1YZCPaty1whi6UciXk7TkLdeuVx5ok4nzP26LOQiDYohkBPA8UK6YJTW6dZ8Nc4jC2APoF7B+84b6ikgXOdTPWWf8ZTdwtM0KidO3fDuJ2Etr7obYcoW6IHtoWk+o0pIQTf1jk/UPdeihADLAMn69jM45hG+gtcqd7Ii7iMVzwd7YEWaa9EvOH8EI4sjIHd77gqZ4zIP9PKpLVTcGCb89nziMvP/kQ== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PihLmQleuB01lRtrImchKgvHtYkcOu15Fgxbl0PB8x/pWEGrQ+DndaUGf/1G1Xu9lyYXx7JXbWP/Aqxsg/XN4MshB3wZk+O3ys5u9BZLRP4CSFR9JTdmYOISfz/yjKeSpGBwK2weLm/5l+Kkx13Uj7NMCJd7030Vj7vWR/lXkcW4AA8SjTuiq1OwUhInHOoPW4DUQbW53z3mzsxSEb612FDCvo70tn3T9anMvGOu4JS1l0npvC9mSih6iWmIAiP3AoWSxf+gXsNKjF+Bu5cEHEZW68tfdQHDtdjFyeU4Jw7ZA79dobRldoC1XWFYN7apmH0aMm9ZK78k0rdmOPxhyseBHN5456H+5novuCy3+2k+acMXkMum5uC8R9PLL6MkeMz+Mhr2Af5g1VHAvZkLNBDK/RcaKGAUKDDQ/6HhojvpNIeAU3R0K2Ccpnf/RBpTl1Yn/rRjF4jkrdW8rUq9cOolvLCXCSCwlhtAvdbEEbnIE/ZKnhQTKm85mdF0HvUPgM3UATZtynIy+aOCaUOtMOKzjTovw4N4wp0rMdCz5k7pltPVin47I3iI58DEDcJIqejucKYsnjzZCTMYZIWoFfHPcTxuud27wvGzsUZRBWWJC1tP0niprc8iYmvFjIiumAOhfsQlVlXCjO2y8Yfn0zF4/CuMh6P16OxDwu6GoXNjZF3Htgf9AzgDWrM6xuWIOvtzXEHC7OGn93JQJlvgMEWCSUzBVnvlAxxAPSQNQ6/jS7PlmZcSYSnIKY5FpyaeUKzhxbQzlr/FdGNIBm3Kqc+vHnTPm1pwoF4KWVntSFsXjCb6QoJaX6Fi8uV7IAJz79wLGuZBVHUtlFYT1wrLvEsP91LwBPIiCdMMB2AhcK1J2uCQaJSiypMw0hFarNn+1Chq6X0BMFmHV/ABGywGhfigLEqrRvWc9XYeElZS0yc6yIXbBVJFT54iMz86x/fHPTiolpSJUY05ykc9AGSETNcCi5IFoBF7rRxPVdhL1FFsU39SSuVduCZk9gLIYpjdZB045cidU34r+ivZD2VVnNIfkgkiFhtfkQQLIa27IYs9oN4w/E7fbcM5/Mbh4GF1sO5DCwS1WcArcB9+rtFD/khUwDv8R1Cv9ivaM384bsjzmMcEGrpUVCElGCEWGPkAQWLT+4o9GsnPp0pzeO0gcGKn4sLnwGHO2OLZOSyMmj96tMloaTPQTqu6/8xs4adygPYGh2VTgq2ynJqRPFMcQFsSW2B00M0Ef2owbrLo1L9iyf+WJxqug5yCVFapYe+CQzt/e30uNRl+xQm/f5b2Gv3xolIObxfS7aby8LF4yhPESWIMdMRZwaiHtqV/rYr3 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb830fca-03a6-46ac-e289-08d96fc08937 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:57.7286 (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: NkIbAQhJTUnnMTqG8K1YTiPCQVzJ0F7x86NYY8n+sQ9OOa2GlPCeAZx3fryIH2KubGwQPh9G8NSqlAAcB9Y9kSt/pAvJJUdInx2A05SDZYE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.102; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This functionality will be reused later. Let's make a separate function now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 4 ++++ block/qcow2.c | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 0fe5f74ed3..4859ca3d0d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -914,6 +914,10 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size, uint64_t *host_offset); +void qcow2_parse_compressed_cluster_descriptor(BDRVQcow2State *s, + uint64_t cluster_descriptor, + uint64_t *coffset, + int *csize); int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m); void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m); diff --git a/block/qcow2.c b/block/qcow2.c index 9f1b6461c8..2095188b6f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4691,6 +4691,19 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, return ret; } +void qcow2_parse_compressed_cluster_descriptor(BDRVQcow2State *s, + uint64_t cluster_descriptor, + uint64_t *coffset, + int *csize) +{ + int nb_csectors; + + *coffset = cluster_descriptor & s->cluster_offset_mask; + nb_csectors = ((cluster_descriptor >> s->csize_shift) & s->csize_mask) + 1; + *csize = nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE - + (*coffset & ~QCOW2_COMPRESSED_SECTOR_MASK); +} + static int coroutine_fn qcow2_co_preadv_compressed(BlockDriverState *bs, uint64_t cluster_descriptor, @@ -4700,15 +4713,13 @@ qcow2_co_preadv_compressed(BlockDriverState *bs, size_t qiov_offset) { BDRVQcow2State *s = bs->opaque; - int ret = 0, csize, nb_csectors; + int ret = 0, csize; uint64_t coffset; uint8_t *buf, *out_buf; int offset_in_cluster = offset_into_cluster(s, offset); - coffset = cluster_descriptor & s->cluster_offset_mask; - nb_csectors = ((cluster_descriptor >> s->csize_shift) & s->csize_mask) + 1; - csize = nb_csectors * QCOW2_COMPRESSED_SECTOR_SIZE - - (coffset & ~QCOW2_COMPRESSED_SECTOR_MASK); + qcow2_parse_compressed_cluster_descriptor(s, cluster_descriptor, &coffset, + &csize); buf = g_try_malloc(csize); if (!buf) { From patchwork Sat Sep 4 16:24:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56DD0C433F5 for ; Sat, 4 Sep 2021 16:30:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E582F60F38 for ; Sat, 4 Sep 2021 16:30:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E582F60F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYYn-0003Y4-PM for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:30:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTc-0002cy-Tk; Sat, 04 Sep 2021 12:25:08 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTb-0007GP-5L; Sat, 04 Sep 2021 12:25:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fho6gFh7Pxm2HQF8juBDDy+194q+ckcDQvB4/CAq34bNwhxLlfl//KHl6FGkjsXYWr8HVNtK9XYcpeJ/VuQAtrHKmrBX0himpBMQ0LILnepMmb21N5JkKAvCSO2rS7FFEQ2o1G4BzpSui0Dzc2W5HV14hyy0Yq/wU7Q7DmBfSvctpoHsAfkIq+KEOdR5elvbwPu6kLPgdc+vtiAhwQE0pIES0ImnUYRSieVbePV+A4Ic623axl45ps6o0LMQpRNHg2odl+eSYOXaShlJ6N8yt4u1hmSWz5rXaTwG+tYQuHJa3WelwCz3CrV+2zG4ohybIxmTK6C1ejHeA3SUViFG9Q== 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; bh=SD8banx/qCHhvCQEA/nqA5kcEzw60W3bfEqUgLGW28g=; b=HQBtnyS4Pws8PcbNCKRhl4MmEyZ/C7lrSRVXutuslxuMipBiTi5qET8R3viLLtgFcmf0EhQTNimO2Qk/n52oJQz7Vck8xh45CVrb44rvp+bTeVb2JPVbgFUVHtxxys71NR8Ejj9muDSG43assxu8nMZkidPg+yNbYLt0Hvr/CINWbKIDSftE1Y6prTaa768VdIQ6JiynR6YLdE+MPTkWILP5yjF2OLZxBL85f/tcXmfZz/tXXNrGZfuESvDdTRlmA83ku73oJsJF4XXs3T5oKYHeV9c83s9OlkWQLj/M546rf6I+ZGllBUvGPnTrnmPrv6c3rqKEVJWFL/ylplhEsg== 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=SD8banx/qCHhvCQEA/nqA5kcEzw60W3bfEqUgLGW28g=; b=O9MLWkteErX294U8K6u7Pw8PS7ohdie48D+1z0UppGlbNKxAnVo6mX3erklfloEw6gpkwDwA0w5A4r1nRF+MrHwJl8BY5D6mEOQggpel0ZPcVkRbT8G4R26FLQICP6elZIQVeVznvjH5IitgrH3yr3UKpFqdu+yS2t/mEV91BeQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:58 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:58 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 05/11] qcow2: refactor qcow2_co_preadv_task() to have one return Date: Sat, 4 Sep 2021 19:24:22 +0300 Message-Id: <20210904162428.222008-6-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0de04fc9-8639-43d6-7d22-08d96fc089ca X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:376; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EnrKJChrjdKBbc7J3cxkTJPJhkljaww58gkX/ySp0CcKrRnN93mzRZiWsPyI8l8U5ttiJoPQlA7OEvY92F/8JKunoNIyxFlFumEJARdq/oSQutJuy2x0L9dgdPeTfbj3Wxy+SOjvkiGX3QbjX4ebOmdJ2XtdrahYl/N8kQqEOwSBlzqmq6m0hoKMA194/nOf6frcd9bHYO8FTE7KtQyoMCB0ZFl7BWUDnjRj/PeHdkSFJSeTaB5BvhigcGyI+2toBe1YuLZypHlTLqeH0PQIln1oL+Ya3J0K639HujLTxPebsE7IKy3cEkhIpSzaXYoiPrA2hjgB/RR0qkRWkSzuo5vHwXMXa2VkTDI/LsUHKlUXRpsy+4ASBVMQFzOxOISHJC6fW/sJ665HLFvrjKob7DoDCEAPsne3leLJpO/rWKoqgBXDg+ytr3+NRZPHhZnL0i3oOW2mWcILLpHUK3PDHn9PAmB1A6lYR3PcYSSApF4SWdcKg2zP3WuAIshe5ofPlxHAzQD/dA6KpmHJm0zxckCz/DhLjP5Pcljf3SWgOP83k3UrAoRg3EbJxvxmGDnsx/FaITBmWv8boulWdHoIodtOW5eMmcljU0LC9FWsMwX6Jrk/Aud9BqL8Z0Ek9vq2c0E+Iu4VhkPduBoJVzDMBT+1W2jCrtDgOCR2qKjy3cxex1Qz93/CgLYHNGtPoLgQsBdE1cteZQ/Zp0Kjq1hEzA== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7cTYGOWpWcxcG/8QLQc1Wmn5RwIQvU2SX5MFtRSpesDJdwrF3u7V9wAWdAijKO/QZzHCZbbgqtsO7VYSDF9HwMV103eM4OyWJlQZgh92WefJuTjYotP1q9SgT9O/WiKcalWfW1YE403lzo6SPxM5RvYzyqaNTe7JrT1X6NVwrbe4rdBT1ZDWOcOZz/2jbcTpQVTxExLKGuzNVuJ77UHKM84YyLmmced8lSslXW2sDpmyObta0ZAoTEktuLOjC3w6Bb0UlwuWfwE5a1iCZKIsU/eQphvWLUkiyzl4zhfOzdtoZ04jXo24960uONUqPsD1UJUzpJ8LEEGt5il/mqsOOAqvLgWT0AlzDYKNt7BFEm66ShTyEtSv9Qs4nKs5UyBosKqrLogtgThHxqy7XANBUnKH/CAqwLNdDmCnMvxUQ0gsH4KCBrbC7q7GY7L7GglvtNUPHeIGYbZqBjpdoHIA4EMun//8URAbNXdfxMuTMNVKj2HGUrNcyI/LbnYY0dGP7KGOCzzsRVlK4FnbeV6SeRF2J51nCr3T4PdwBL1GN6jLfbp3aRy/wSvzdQcw7z634PetL405+cc745lTGRR1xhzhEPk0JA3Jn+1397ZUn3FHo52R5xx++ST3wn8DIVh8OV1HWWTI+HZrTUFKaYHkb1+G40cFynPoDlT6k2VTeyoTpY0lloxhnLOB39QwqyEIHepPk+ISQl3v4gDGsBL7T0WT48g64bAsclBkVjIAI2Brjus7JF0QrXPX9b69IMAhC5PdsqhfcRffkMGsHPXywK5OxdKqdz3tzSbJUkl/xJQQhuMPMmMs17HkP1oaaOQwq7yB4nBZHVLJgHsBxPNI9fjTlpF50POUXXgDR+XUjkDBieTLqTSWRyA3GUeA8tnTeKBE+fTCOOueBmlYCBfMiGT8TAEb7k2+vrXTYy3Is7FJtfza+YujH/lqd/FMLcV3yA2ZEkUcyYq6b3jnvKoe0pLMs1Usag6pEpb/hapuF0aRD0uDF8I5M3lxZHPFIhnuL+335956fqzWohajFjYbqb1Q7XGJJYhFVfrCfsDlvslv7zO80uDZ7PhueitgEKcBVe0kGc2Tg81PBVqX0SPoRVwgzeBk2MNcwRIWziNTmrZkBfIKT2RJOGoPLDMVr1YeLQk93x90mdmjvZRG9qKvEMBrmz9mmUPhaTB2/qLnDQQPhsppUGuPb8CD3sg8MQUpaW6znrI2bYn2g8VAQjR2Bu7K5fIOvpyycVogqwDV/4NyyFBIgZQ+ddG4zOR1CD6y4uzUrhN7BfOMxgGRwWfhyMywNhgrTw6M49s8RbphKvLVUytvUK0Ak/8dwxKPDZk/ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0de04fc9-8639-43d6-7d22-08d96fc089ca X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:58.7083 (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: MFwISxvRl/3RUHOx9RmsRU/S1ekM/2h3txIF1nTBoIWZHVcn+eqM7Fo6OeOkC7Xv+g/UAjzA6QgaNQIeJLOruGL6JuBGB4+EH+XQ5QjEyQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to add an action before return for this function. Refactor function now to make further patch simpler. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 2095188b6f..7fbcc600da 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2262,6 +2262,7 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs, size_t qiov_offset) { BDRVQcow2State *s = bs->opaque; + int ret; switch (subc_type) { case QCOW2_SUBCLUSTER_ZERO_PLAIN: @@ -2274,28 +2275,31 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs, assert(bs->backing); /* otherwise handled in qcow2_co_preadv_part */ BLKDBG_EVENT(bs->file, BLKDBG_READ_BACKING_AIO); - return bdrv_co_preadv_part(bs->backing, offset, bytes, - qiov, qiov_offset, 0); + ret = bdrv_co_preadv_part(bs->backing, offset, bytes, + qiov, qiov_offset, 0); + break; case QCOW2_SUBCLUSTER_COMPRESSED: - return qcow2_co_preadv_compressed(bs, host_offset, - offset, bytes, qiov, qiov_offset); + ret = qcow2_co_preadv_compressed(bs, host_offset, + offset, bytes, qiov, qiov_offset); + break; case QCOW2_SUBCLUSTER_NORMAL: if (bs->encrypted) { - return qcow2_co_preadv_encrypted(bs, host_offset, - offset, bytes, qiov, qiov_offset); + ret = qcow2_co_preadv_encrypted(bs, host_offset, + offset, bytes, qiov, qiov_offset); + } else { + BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); + ret = bdrv_co_preadv_part(s->data_file, host_offset, + bytes, qiov, qiov_offset, 0); } - - BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO); - return bdrv_co_preadv_part(s->data_file, host_offset, - bytes, qiov, qiov_offset, 0); + break; default: g_assert_not_reached(); } - g_assert_not_reached(); + return ret; } static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task) From patchwork Sat Sep 4 16:24:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDCA3C433EF for ; Sat, 4 Sep 2021 16:32:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B03660F38 for ; Sat, 4 Sep 2021 16:32:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2B03660F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYaj-0006xT-DN for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:32:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTg-0002nu-9g; Sat, 04 Sep 2021 12:25:12 -0400 Received: from mail-vi1eur05on2102.outbound.protection.outlook.com ([40.107.21.102]:64544 helo=EUR05-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 1mMYTd-0007MU-2U; Sat, 04 Sep 2021 12:25:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RN+Wd4vhj1ALZHzidgR+F8/euyMC7xpEXL6ANz0GlEiJOiqa3jqI41haTJUIuEMs25lNzCF8oVHd//UPr6//omfWu8lrhc+FffLIRDkqXKQfxRIzdxCJiaj7BCQ8J3tWwdW2KckE+1mtIRgj9zZFS/qp5P0ooZFM1+X00TtVsPGAgRXH618zOrojVLT4/ZdXdTrE0GpgN3h3nvornYzMsL8qeFNYLUl8DhHfLejU8pi3uG//1v5W9oG2tICEPNBYvuFrcFT+eB7giuMia57mtlvMXcPZOG/+7EZtj1GpWa5smq2N3en8ClIkzK6MWdKmGX5PqdmIHQ50l7XGp/wStg== 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; bh=8rIvAILB+1i7Lzmx+VgeHtLRUfWktVVAEb1Ww92jGqU=; b=H9yJMJBzjMYJtSSdqQfudr85jsaP+TuPXoEE27jddDrcP5jgM+RJiApH47PJ2t/iqCsiUKSXZDyHYeZ6xVIxvCvG39coUvcn0bbc8LoHqvKA9QGTXX9RXqG/hIdJ32HHqZz2Ft6tJo54GNL5upKA2KHpJ5jnG3kTuS76t9SN+R0oJ6qQjHzrXNeAlQeD3OQzWGwZ2WALMDzwPQhg//viJQuUyxe0KdPDkDYCYtd6tu/X9QiEx4DDUG9OO/ghKwZvC+xps+ZUclG4jnuYCLyLyov2IgKaFj2Vew7XsE+iMngmfj6SFpVWObagu76mneFZ25esQCbIzfAoVm6k5OBjiQ== 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=8rIvAILB+1i7Lzmx+VgeHtLRUfWktVVAEb1Ww92jGqU=; b=Ot78ji+Qk+tpP7nAq8E3X3h7els7cRe6Y6jO5jt0GHLw3q671catSMFwnKisE0Mu/2mJaFbHKmFUZ0eVZDOZsvrylHoy+lzsGbEgyXfYhyoFSOeXgkYjL/z9K8SggDlfdQnJnXWaqCwIo6+kXQlkVQ4TjLduIxZbjRSYsSzIYsM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:24:59 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:24:59 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 06/11] qcow2: prepare for tracking guest io requests in data_file Date: Sat, 4 Sep 2021 19:24:23 +0300 Message-Id: <20210904162428.222008-7-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:24:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b21d692-d6b2-43d9-248f-08d96fc08a59 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:459; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bwtXlhrHg+Dw3+kz+iQ1aHbQcK5HTlKpDIDn4IGFJJyuxlYcssJM//kQN+QMC3oULSa5NsQyqn2n2KrZUdyNMIfivBNmbLWDOi4g7uU/KVk/x3KO3s/NGHAK8avtJ9nWFNCCvqJqkNoQE2h2mAy0hlNZQD4pVF1dHIZ5UpgdQUDyIHngAlq4B0Qtt9c9eKup8e8C+aIEp2SqrjybjKfNlhZ4BdaY1mvxa74OpFFmdobPAo2OVvFF2f/q+cKl+rI8SKr70DhbeuLraGhgP3f5nVU9TFmxconcvnXi18LAS4D+WLtXZIPvtWhzcikkPSqeW2my6Ft9X0gZzaptmbQJCooWNj7CsMfTCH24tDUdN3PlWSDgdIhD+ATRlrl1n/DqOe0hJbYVoHaKysrpeBY4AwC37NSrfBGc7kBcgtuknSjBsFLB3Tpzax8I+Q5K3tsRvihQ/oGszisxHsRSzUpgY01/gNZwcFvjAleFRKoSGHPBeAwo3fIxeAGs9IAR+GwCoupo3MKHnUyfiKLnkkI+h3t1Jt5n1zAdXZq12HNH8KxUGerB1c5XyVEH8Rq+cVAXgY9WCubEJEHw0IeSTRva7tUDMdFCAwVMhcffqXJi5V88KWJ1dvffQ75hWavvz+SBjojAMR62vUN19YqVhUcgGbWtWykRzpcxFmYQFipR02oYSXKBRLtHPlALnWA5BxfQnRTNmp56tai2Rvo+JvyIbg== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(19627235002)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UpM0S7DzsZ9pXEMcRsQ1DSORZXjLrnv3ffcALzwPB3w5nK875Y5MtKT6ULwJHnj+09V3aAajfpJwaRn/mcgjlM/HgmLCcZNh3glNvZrzy+NfJGXmErMWbmg/3Uti0KeKeaFM5xSB/cdcTMu0WywFLkLc/mYI+lFWvQMhLULmDdQSN3v/haz30H6iX7t/oN5v9zAHLZg8z8VXDnF+2/4MuPBaYHZpqkhK3U4coGt5h/DcejzAtoxmxjsHq4qRXvJldmY3+cGAPRLGldCR/08BCoCOm8Y4K8/CUjnjsM4APXx7M1kIpjMrbl5jBKfUiaDKDrqoImxX4nTIBFFmT4/Poq5ChpT+qqsE2JBj6mZNc9D9tmuh/2jku+tKMl7xyAv7BbVQIxRYEiZjRUEZlF9iWYFHvdKxxXjVVYsIVOd+JzM2eizEQhpPZcSHMuwOhHzWlCk91m2IWKyB+UFsKUmQyxQ53kYww1aJ+pX0GYVI3yNw9j7pUGU0BP/ybUSgitjAT9cYvx57DnEu1H4H5kbf/XZeg6TasuNJyBnvS3RVtS4yMDtL3OJdKseEu2djcJl56I5usd8WS1gQ6cI21BqPJqOPyFWeKM6BSq/pA0xvoWvoy1gTT/pMm+HuItoF/lb5hEeTLXSKGuANGLeppF2l8v0A27C6XkSdrSQJtOupkcfSdYucWvjS4Z2fwEwuu8MCYyT4wVuoTFmq42AaC1B/HX1BKoE0JuBGBTY21GBt4LeInAdOCfjOFXtl9rnn8WEXR5kbbJT5/UECdOjGddN1+dOlDjSSRf7PiycxW6ByfVnQUaYh3WKUlwrOrUAkuXQKgqpFKyx0kBjLs3NdzkIeEme+1SS8zKiTCSxMaxU/mXRIPQIzj1R/yqbfToLxs+3JaNO8r+DXvvEU7JKMG9XxfbuQdxn8CYRxG+ZZe1/61dKpYa8E+OJy99sCia4PkjNMRaSpx7wgyGvaZr8fsVCzxen2KxR09u6qhgESq4ZGJ36+1G8wqouzWJHMdz/RYAZjKPvHGe7+w3WSIFMT9c6nqMFP+wy+pZRcz9ipuHS4ac6FoP6Kg3DVBTk3ECtPB/Cb3C0fhZskewYAhDqYT+ac07HYC9JwoMUC4r9e2YJ/CbEerQ+V1yaVsfcDidqrjkXpmboT03GFiU5LDFjAZAaMJpgTmOrA3Hj6QrmBoMIxCDNnsOiQnWJQ0mPhheXQoR9nxok6WEd4NL6QTj71jNNyktP4s73Ei33XB7gQv6TBx4m4a8paH1IcsUIYvhauhvq2WjNK6H+Vs4EbY6OwrfISbwL1zq58n33a8bCuf8g45is27HrzmsWfC78Pia4jDXEJ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b21d692-d6b2-43d9-248f-08d96fc08a59 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:24:59.7945 (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: aIU83kTQbAb65Sq11cZP2tK+LWM1+LDdnPAS8AQiLUS1je6rkWnOELN7Np12ndnd5FO7wTcnP6VNxqb9igf9YVUS+Mvkx8IdiL31WEVOiI8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.102; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to fix a bug of reallocating host cluster that are under guest operation. For this we need to track these operations. Guest io operations in data_file has 3 entry points: qcow2_get_host_offset() qcow2_alloc_host_offset() qcow2_alloc_compressed_cluster_offset() These functions provides the offset in data_file. So for now, add a possibility for these function to start a BlockReq. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.h | 11 ++++++++--- block/qcow2-cluster.c | 45 ++++++++++++++++++++++++++++++++++++++++--- block/qcow2.c | 17 ++++++++-------- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index 4859ca3d0d..7b9fafc6ec 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -29,6 +29,7 @@ #include "qemu/coroutine.h" #include "qemu/units.h" #include "block/block_int.h" +#include "block/reqlist.h" //#define DEBUG_ALLOC //#define DEBUG_ALLOC2 @@ -420,6 +421,8 @@ typedef struct BDRVQcow2State { * is to convert the image with the desired compression type set. */ Qcow2CompressionType compression_type; + + BlockReqList guest_reqs; } BDRVQcow2State; typedef struct Qcow2COWRegion { @@ -906,14 +909,16 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num, int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, - QCow2SubclusterType *subcluster_type); + QCow2SubclusterType *subcluster_type, + BlockReq **req); int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m); + QCowL2Meta **m, BlockReq **req); int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size, - uint64_t *host_offset); + uint64_t *host_offset, + BlockReq **req); void qcow2_parse_compressed_cluster_descriptor(BDRVQcow2State *s, uint64_t cluster_descriptor, uint64_t *coffset, diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bd0597842f..9887f80dcc 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -567,11 +567,17 @@ static int coroutine_fn do_perform_cow_write(BlockDriverState *bs, * file. The subcluster type is stored in *subcluster_type. * Compressed clusters are always processed one by one. * + * On success if req is non-NULL and resulting subcluster type is + * QCOW2_SUBCLUSTER_NORMAL or QCOW2_SUBCLUSTER_COMPRESSED req is allocated and + * initialized. For other cluster types req is set to NULL. + * On failure req is untouched. + * * Returns 0 on success, -errno in error cases. */ int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, - QCow2SubclusterType *subcluster_type) + QCow2SubclusterType *subcluster_type, + BlockReq **req) { BDRVQcow2State *s = bs->opaque; unsigned int l2_index, sc_index; @@ -721,6 +727,21 @@ out: *subcluster_type = type; + if (req) { + if (type == QCOW2_SUBCLUSTER_COMPRESSED) { + uint64_t coffset; + int csize; + + qcow2_parse_compressed_cluster_descriptor(s, *host_offset, &coffset, + &csize); + *req = reqlist_new_req(&s->guest_reqs, coffset, csize); + } else if (type == QCOW2_SUBCLUSTER_NORMAL) { + *req = reqlist_new_req(&s->guest_reqs, *host_offset, *bytes); + } else { + *req = NULL; + } + } + return 0; fail: @@ -809,11 +830,16 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset, * already allocated at the offset, return an error. * * Return 0 on success and -errno in error cases + * + * On success if req is non-NULL req is allocated and initialized. + * On failure req is untouched. + * */ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size, - uint64_t *host_offset) + uint64_t *host_offset, + BlockReq **req) { BDRVQcow2State *s = bs->opaque; int l2_index, ret; @@ -868,6 +894,11 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, qcow2_cache_put(s->l2_table_cache, (void **) &l2_slice); *host_offset = cluster_offset & s->cluster_offset_mask; + + if (req) { + *req = reqlist_new_req(&s->guest_reqs, *host_offset, compressed_size); + } + return 0; } @@ -1740,10 +1771,14 @@ out: * is queued and will be reentered when the dependency has completed. * * Return 0 on success and -errno in error cases + * + * On success if req is non-NULL req is allocated and initialized. + * On failure req is untouched. + * */ int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m) + QCowL2Meta **m, BlockReq **req) { BDRVQcow2State *s = bs->opaque; uint64_t start, remaining; @@ -1850,6 +1885,10 @@ again: assert(offset_into_cluster(s, *host_offset) == offset_into_cluster(s, offset)); + if (req) { + *req = reqlist_new_req(&s->guest_reqs, *host_offset, *bytes); + } + return 0; } diff --git a/block/qcow2.c b/block/qcow2.c index 7fbcc600da..8aa5679fe9 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1833,6 +1833,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, #endif qemu_co_queue_init(&s->thread_task_queue); + QLIST_INIT(&s->guest_reqs); return ret; @@ -2090,7 +2091,7 @@ static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, } bytes = MIN(INT_MAX, count); - ret = qcow2_get_host_offset(bs, offset, &bytes, &host_offset, &type); + ret = qcow2_get_host_offset(bs, offset, &bytes, &host_offset, &type, NULL); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { return ret; @@ -2335,7 +2336,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); ret = qcow2_get_host_offset(bs, offset, &cur_bytes, - &host_offset, &type); + &host_offset, &type, NULL); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { goto out; @@ -2629,7 +2630,7 @@ static coroutine_fn int qcow2_co_pwritev_part( qemu_co_mutex_lock(&s->lock); ret = qcow2_alloc_host_offset(bs, offset, &cur_bytes, - &host_offset, &l2meta); + &host_offset, &l2meta, NULL); if (ret < 0) { goto out_locked; } @@ -3170,7 +3171,7 @@ static int coroutine_fn preallocate_co(BlockDriverState *bs, uint64_t offset, while (bytes) { cur_bytes = MIN(bytes, QEMU_ALIGN_DOWN(INT_MAX, s->cluster_size)); ret = qcow2_alloc_host_offset(bs, offset, &cur_bytes, - &host_offset, &meta); + &host_offset, &meta, NULL); if (ret < 0) { error_setg_errno(errp, -ret, "Allocating clusters failed"); goto out; @@ -3976,7 +3977,7 @@ static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs, offset -= head; bytes = s->subcluster_size; nr = s->subcluster_size; - ret = qcow2_get_host_offset(bs, offset, &nr, &off, &type); + ret = qcow2_get_host_offset(bs, offset, &nr, &off, &type, NULL); if (ret < 0 || (type != QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN && type != QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC && @@ -4051,7 +4052,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, cur_write_flags = write_flags; ret = qcow2_get_host_offset(bs, src_offset, &cur_bytes, - ©_offset, &type); + ©_offset, &type, NULL); if (ret < 0) { goto out; } @@ -4138,7 +4139,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, * the refcnt, without copying user data. * Or if src->bs == dst->bs->backing->bs, we could copy by discarding. */ ret = qcow2_alloc_host_offset(bs, dst_offset, &cur_bytes, - &host_offset, &l2meta); + &host_offset, &l2meta, NULL); if (ret < 0) { goto fail; } @@ -4593,7 +4594,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); ret = qcow2_alloc_compressed_cluster_offset(bs, offset, out_len, - &cluster_offset); + &cluster_offset, NULL); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); goto fail; From patchwork Sat Sep 4 16:24:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475695 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D09EDC433EF for ; Sat, 4 Sep 2021 16:37:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5031860F3A for ; Sat, 4 Sep 2021 16:37:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5031860F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYfN-0006cn-9A for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:37:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTj-0002vr-4P; Sat, 04 Sep 2021 12:25:15 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTd-0007GP-Nb; Sat, 04 Sep 2021 12:25:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYVT/nvwh3KJZjSX8RXOKXEz/X9vKGTs5uT+j40/nK5zcrJFjZBpY8USpZRKBY4y9/Y5pHfIyF6Rp08+YLUqEFnzmNaagSY5t4gOuM3ssvSrQzuC+ib/ULrEGPJiTFiwloBwViIZKwbvAdYiDipmbi0I2U6wnqioDUgZTFHDvdhwvd5fV1wpeZzJa8yukltjiSQc1KlGoL9spKOnQIsnU9sFRSfPm6Slng9nodGuNQOIMxsAncOHmp1UTOKiSO2TOf8XYFi2kmmg3iShRohcRaQ845JwOl2ZP/3++eETTEHUZ23Bk+6xgIW9BbIpcCPmvqIRIYi4+g6dihptIJO2XQ== 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; bh=PrRiZInqt1ZZmVKT8YYaZm4oCmPuP62IFgAFRHl89b0=; b=fDEaEK6xHbpYWkrswhf9u1xQ/p3IMOt3C1ZhqDPwCf5aNRh1PvHcaG1negnLDvWsrsZhQEVQJWGuNI1zSviDL8XrrarNhpzW3SuQpHNYYgTTh3Vud3KhuIZS1H0B0rfMtis9APQI0zGHgfx+VYkyaWT2kx5KWbKBhyRxIbn1rf5EgHnrVrx6vvZKFQYyqytM/m1SPodpAiXznIy2g2FWwbtBLkkcYTFvoz2Lw3V/Nmh5vasBKFHsFuQ+5ENnFsGQ0u5qKE5zEQlK/x4cMKxhSrn2mlZENTK5WCDtaPcBwLUfGAM6wUDCo8yZ2e59iaYBKs5JFIf6OkZVa4cGxZongQ== 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=PrRiZInqt1ZZmVKT8YYaZm4oCmPuP62IFgAFRHl89b0=; b=OESoKWu05PIoSlTAcPgUmMzH8uEQzjTNPpUeCNO4M31FKpQm8tbUBCMxaJKpHmz6OSBTiEwWxvOYGdsyjhegGX0vftvq6SveG+vFFoFUi0o2HzTVYYEg65/OPUtZ/Bv1Rqi/zyiNPcPe0QcC6q9L4vj/4xPI1AOgCHgEYsTJFoA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:25:01 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:25:01 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 07/11] qcow2: track guest io requests in data_file Date: Sat, 4 Sep 2021 19:24:24 +0300 Message-Id: <20210904162428.222008-8-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:25:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d1c80e5-c593-40a1-9c97-08d96fc08b08 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Oq+Hyfjp1SIQ1zQF8VQoQzVeb3OpkuhXg4t9M+t1IhjuVH7IlYbNRvCjk1A9oXHsrSFvuHlPNWiAv9DG7eesztt/b7pOh1BMx2LGYtz/FbunF/UT0hcL9gQWVKchUEVdOl8WLpkMew+6Oeycc01i3fwA/3ugebyzgItPG7E1hzDtKMNvJ5T+vI316tLxh7+0W/UBSbPw7V6sPTQOpJwsFr2f3uQNcSLRMOn7pF9rO8TJ2E67oThc5eUhdBszsJ1l7LNGSZ/d5AkKGQgf5A4MXAj7g92tmjESVe4gYSomW60yr5vyEUvsAMCa6/c3pL5i8I18c8WF7f0hXKON0pUW691yFOxSj4ABPmm5AY9auMRwjmShFhGRVvjTP73vqWFC3MiiAQQ4TxYJRsS7Q+refe+ch3rYo47zo7DNJt4S/lCUt4izrVGJHoDsSraXNs4A3PRh7MROIB9lsv5cvQSRua5HlKhZWmCyyHLj47nweRrOKXbJH+SwBHS5K9IJrpGAGE7e3gmyasTLc+7iv3CQp4UvZb/+ILtc5txOQK0Hky60n699ZuW+2cbsDaZXyo6mbp3JmMSxExrwWQRjdOra0mty9+IQ65GGAsWxsBGpi/t6YgovEoghrG3vUHI8OehY2OlCj2YeGUZPxEfH9Wc7BLEW7cWQZd+Uaom2pJzd7LBf9bnKUF7IPtZ4tpnzAjq5MV7hqpbVj41ogicxuXNvRA== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(19627235002)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DawuWUaX0CfRcxfIxriKb8wNRu/S0VD63/sdCEVT20Msw+T/NV3Zgm9FqIJCOCLCEx/javyffUBAYT3f3/qvevhizMR2kfWRDUXBuHicblojYKKLUDwYTEEUB58NyT6ABEppjQ6A3g/L2PchzwqWZioLoEoM9Ft6LlmcHfGy4D0Qp2u6EscHKahbllffi/WYy0m7GQtezhfW2uIXtwdgdbCTyMAyQvQGp9el2sv/DjQVyJz39mVhLvmVWnWzy4FI2RqIRF6Km9vD+aUj65ALdaKNgKHM6RsXzg4gmpXLeAoSZnlczGrrndkTdDVAFGzqmDLht6YBY+CpwMFK4zPO48z65DfEZJVNJBebv6pUaLvlyPkSkn9+/UpAGm0X+71F7otFvAvefTF0XUvhbn4kFZvAuLnhSTzLf/IjXirA4wfqV6UY0fGwhVIbi0+i+QPFEKROoWPQqXWeRFD8op4Jr5pjx7pCAOn/z0hQTjdPolPuo5uCBIthgZj5/sPD1FnX0T9+f3Y4Apc55myi2htIdlLvKNWEot/4D0TsSGbsD4gU3FFIh6lynDFtPId4UwX8/iS4wa+PwG2FN2MEPn6G0p+ZBTfAjET+UaYM2FVklM+kyagaGhzk6w3TzQAO59UId/KUZmW1BEoGSGfyM9DWa69f7EEdEB3DPtLog1N4d80a+7nG9Ut5LmuYNAB/TDMVMJTYnUcHUaxLT0+F8zV0+GQDg0wVeIvHru0cuSKc87FbBfjpYisYrn1870Sz75b5LE6AGyVqXrgpOU27qekmEyUwVdV9oKPK2i+iMREoR2KIhElbTrdCxLpG+hCb9c2RYfeTYpiAMniAdyTRhXWFO+R3mZb1KFPio9WMIbp0035nVBPXE/j0cf6TWbrsnYHTvHjm238HRv4ijgMUn8MTOnxizQrns0h8wf3Sis7g9PcpkjnOA3DIGgednALewLRkswhwGP/IJCrvmQ7Via8vitMLVnhscDTCJWBZaLh/yAVkaVhvM0fuq6y1vkBtG7VQy2Z+hS/9x23KFYqIoZENLXJqOZvTrMuacJQjdCRVnaB5DfwtQf7t4v4UhaOnQwGUlKRDcF6p2438MgnujE1SNJyK0kPknykrjtiNFQHVwsJnP/ryM3Urutv0X/UYH+bLHNUhvehSalPSeD8FgQc14XakV4Kbd2hWrksymVjxIB5kLxJOzlS7dtNTEesZCSFqPkIPy0IgamddP5FjoK2P/0ARNZGI3+tOn/thJE5cd0VtQ32P1WBhljp0Qe0jIkPh7MYHqG4cVBp7/X0wCFAgqiJxc0JoEtKdPz2lM0RbQynGNwIa3F5lItXShrWz2YsW X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d1c80e5-c593-40a1-9c97-08d96fc08b08 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:25:01.1565 (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: GwYTMavb9vFW//l/4wMva+tDniWdq+yMdAlNhSq5dcCBl38F9ySSZLoIJapr3lSi5Lcmxz1LnNbp407PZ1AfNcS/dGvOOsbQdLtsqe8PvqA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to fix a bug of reallocating host cluster that are under guest operation. For this we need to track these operations. So, we create BlockReq objects during guest writing and reading data. That's important for synchronization with further host clusters reallocation code that we create BlockReq object in same s->lock critical section where we get an offset. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 58 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 8aa5679fe9..aefe6558b6 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2212,6 +2212,8 @@ typedef struct Qcow2AioTask { QEMUIOVector *qiov; uint64_t qiov_offset; QCowL2Meta *l2meta; /* only for write */ + + BlockReq *req; } Qcow2AioTask; static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task); @@ -2224,7 +2226,8 @@ static coroutine_fn int qcow2_add_task(BlockDriverState *bs, uint64_t bytes, QEMUIOVector *qiov, size_t qiov_offset, - QCowL2Meta *l2meta) + QCowL2Meta *l2meta, + BlockReq *req) { Qcow2AioTask local_task; Qcow2AioTask *task = pool ? g_new(Qcow2AioTask, 1) : &local_task; @@ -2239,6 +2242,7 @@ static coroutine_fn int qcow2_add_task(BlockDriverState *bs, .bytes = bytes, .qiov_offset = qiov_offset, .l2meta = l2meta, + .req = req, }; trace_qcow2_add_task(qemu_coroutine_self(), bs, pool, @@ -2260,7 +2264,8 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs, uint64_t host_offset, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, - size_t qiov_offset) + size_t qiov_offset, + BlockReq *req) { BDRVQcow2State *s = bs->opaque; int ret; @@ -2300,6 +2305,12 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs, g_assert_not_reached(); } + if (req) { + WITH_QEMU_LOCK_GUARD(&s->lock) { + reqlist_free_req(req); + } + } + return ret; } @@ -2311,7 +2322,7 @@ static coroutine_fn int qcow2_co_preadv_task_entry(AioTask *task) return qcow2_co_preadv_task(t->bs, t->subcluster_type, t->host_offset, t->offset, t->bytes, - t->qiov, t->qiov_offset); + t->qiov, t->qiov_offset, t->req); } static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, @@ -2327,6 +2338,8 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, AioTaskPool *aio = NULL; while (bytes != 0 && aio_task_pool_status(aio) == 0) { + BlockReq *req = NULL; + /* prepare next request */ cur_bytes = MIN(bytes, INT_MAX); if (s->crypto) { @@ -2336,7 +2349,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); ret = qcow2_get_host_offset(bs, offset, &cur_bytes, - &host_offset, &type, NULL); + &host_offset, &type, &req); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { goto out; @@ -2354,7 +2367,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, } ret = qcow2_add_task(bs, aio, qcow2_co_preadv_task_entry, type, host_offset, offset, cur_bytes, - qiov, qiov_offset, NULL); + qiov, qiov_offset, NULL, req); if (ret < 0) { goto out; } @@ -2523,7 +2536,8 @@ static coroutine_fn int qcow2_co_pwritev_task(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, uint64_t qiov_offset, - QCowL2Meta *l2meta) + QCowL2Meta *l2meta, + BlockReq *req) { int ret; BDRVQcow2State *s = bs->opaque; @@ -2582,6 +2596,9 @@ out_unlocked: out_locked: qcow2_handle_l2meta(bs, &l2meta, false); + + reqlist_free_req(req); + qemu_co_mutex_unlock(&s->lock); qemu_vfree(crypt_buf); @@ -2597,7 +2614,7 @@ static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task) return qcow2_co_pwritev_task(t->bs, t->host_offset, t->offset, t->bytes, t->qiov, t->qiov_offset, - t->l2meta); + t->l2meta, t->req); } static coroutine_fn int qcow2_co_pwritev_part( @@ -2615,6 +2632,7 @@ static coroutine_fn int qcow2_co_pwritev_part( trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes); while (bytes != 0 && aio_task_pool_status(aio) == 0) { + BlockReq *req; l2meta = NULL; @@ -2630,7 +2648,7 @@ static coroutine_fn int qcow2_co_pwritev_part( qemu_co_mutex_lock(&s->lock); ret = qcow2_alloc_host_offset(bs, offset, &cur_bytes, - &host_offset, &l2meta, NULL); + &host_offset, &l2meta, &req); if (ret < 0) { goto out_locked; } @@ -2638,6 +2656,7 @@ static coroutine_fn int qcow2_co_pwritev_part( ret = qcow2_pre_write_overlap_check(bs, 0, host_offset, cur_bytes, true); if (ret < 0) { + reqlist_free_req(req); goto out_locked; } @@ -2648,7 +2667,7 @@ static coroutine_fn int qcow2_co_pwritev_part( } ret = qcow2_add_task(bs, aio, qcow2_co_pwritev_task_entry, 0, host_offset, offset, - cur_bytes, qiov, qiov_offset, l2meta); + cur_bytes, qiov, qiov_offset, l2meta, req); l2meta = NULL; /* l2meta is consumed by qcow2_co_pwritev_task() */ if (ret < 0) { goto fail_nometa; @@ -4045,6 +4064,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); while (bytes != 0) { + BlockReq *req = NULL; uint64_t copy_offset = 0; QCow2SubclusterType type; /* prepare next request */ @@ -4052,7 +4072,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, cur_write_flags = write_flags; ret = qcow2_get_host_offset(bs, src_offset, &cur_bytes, - ©_offset, &type, NULL); + ©_offset, &type, &req); if (ret < 0) { goto out; } @@ -4080,6 +4100,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, break; case QCOW2_SUBCLUSTER_COMPRESSED: + reqlist_free_req(req); ret = -ENOTSUP; goto out; @@ -4096,6 +4117,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, dst, dst_offset, cur_bytes, read_flags, cur_write_flags); qemu_co_mutex_lock(&s->lock); + reqlist_free_req(req); if (ret < 0) { goto out; } @@ -4129,6 +4151,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); while (bytes != 0) { + BlockReq *req; l2meta = NULL; @@ -4139,7 +4162,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, * the refcnt, without copying user data. * Or if src->bs == dst->bs->backing->bs, we could copy by discarding. */ ret = qcow2_alloc_host_offset(bs, dst_offset, &cur_bytes, - &host_offset, &l2meta, NULL); + &host_offset, &l2meta, &req); if (ret < 0) { goto fail; } @@ -4147,6 +4170,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, ret = qcow2_pre_write_overlap_check(bs, 0, host_offset, cur_bytes, true); if (ret < 0) { + reqlist_free_req(req); goto fail; } @@ -4154,6 +4178,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, ret = bdrv_co_copy_range_to(src, src_offset, s->data_file, host_offset, cur_bytes, read_flags, write_flags); qemu_co_mutex_lock(&s->lock); + reqlist_free_req(req); if (ret < 0) { goto fail; } @@ -4565,6 +4590,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, ssize_t out_len; uint8_t *buf, *out_buf; uint64_t cluster_offset; + BlockReq *req = NULL; assert(bytes == s->cluster_size || (bytes < s->cluster_size && (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))); @@ -4594,7 +4620,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, qemu_co_mutex_lock(&s->lock); ret = qcow2_alloc_compressed_cluster_offset(bs, offset, out_len, - &cluster_offset, NULL); + &cluster_offset, &req); if (ret < 0) { qemu_co_mutex_unlock(&s->lock); goto fail; @@ -4614,6 +4640,11 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, success: ret = 0; fail: + if (req) { + WITH_QEMU_LOCK_GUARD(&s->lock) { + reqlist_free_req(req); + } + } qemu_vfree(buf); g_free(out_buf); return ret; @@ -4676,7 +4707,8 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, } ret = qcow2_add_task(bs, aio, qcow2_co_pwritev_compressed_task_entry, - 0, 0, offset, chunk_size, qiov, qiov_offset, NULL); + 0, 0, offset, chunk_size, qiov, qiov_offset, NULL, + NULL); if (ret < 0) { break; } From patchwork Sat Sep 4 16:24:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475693 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBE87C433EF for ; Sat, 4 Sep 2021 16:34:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52EF160F3A for ; Sat, 4 Sep 2021 16:34:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 52EF160F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:57686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYcq-00030i-FJ for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:34:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTi-0002ui-ND; Sat, 04 Sep 2021 12:25:14 -0400 Received: from mail-vi1eur05on2102.outbound.protection.outlook.com ([40.107.21.102]:64544 helo=EUR05-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 1mMYTh-0007MU-0s; Sat, 04 Sep 2021 12:25:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T+xWVy5l2xUwxqJEbBcKoaPjN7mXd2NxgOHroVSxchnwU+XiqJbh7BzmjBg9ytquVU2QIHmcd1CiyYSQYT+0kj6yGT6DE1oit9Q2+YpcIY4dazlV6PDwkMi2cGAn6NgGs7bJb1P3NBo1uut+5iuJaedfqQ7WCk/V9cb5sUPMN8dpKyKs09EaEtb6q7PhdtxR6qMH+zw4XWDpRzk3ZD6RMQET27X2iyDluRWg5LNWdVKPFneS13hVkApUoa4qO9MF51oSap0VU3jpLQsP91kII1cpj3fzmhUpHzD5btfllVcTLvqGsaZNqt2gR9TTdVxhaEyvDtqIdiFVoPtBh+wO4g== 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; bh=0+oA3kpyQ/yVl7eX0w2zAOAqwYuwkV3Ba0tdWErIV/0=; b=IwZcWWh9ChsAlxtOXLphF6ttAcEg3A7qUBCoxshapWAtXxDMSsVx4fsm+1GwTNc+r03X+l8q+azg1n+hc6+wqjH7GXEbcZILI2yUvGsk+dE2erT82chs1FQj4Eo/4LSuAO+ErqyWAxa097dkr2OTnG1svtzHPCHEcLVU2zOCNE7qVMtlSK9wI1E4PbJkmQuTzRZske2vIAwsN4ko210ebDee5vuwx0NfQGwWn5c/m+QWv4pGOoORMpyeQL5eVqdAR0iJ9E3mpnwGJdgVSjHQCDMSuIBA29M696f4FuyOOvTxWObxr+cv7HX08tW3czeRIWAOmj1tClW0kjzvpD0voQ== 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=0+oA3kpyQ/yVl7eX0w2zAOAqwYuwkV3Ba0tdWErIV/0=; b=wJrdZZSKlvqt6B4+7+KrP8KcOqosQ75aZaMtns0+phXgnc6l2kv8vO04Fvf0/PeT/4Ph+WJl+qKAnvwPpU5B5oF1+QdIOEhm4Mqs+IlS0juFI3hNAV/EV3hCDTlAuCmK/G63yHeL6LhHnOcW4Yiiiek8cuUkN1sFUUhhc0eQIzQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:25:02 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:25:02 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 08/11] qcow2: introduce is_cluster_free() helper Date: Sat, 4 Sep 2021 19:24:25 +0300 Message-Id: <20210904162428.222008-9-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:25:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 22a971c3-d9f2-4e9f-80c2-08d96fc08bd9 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:873; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UbcxU+/k13PQj9Gegl/i6OsYXtA3rCnBeMq45s8mmJr7GesFnUYlbE+Uvh60InDftZw2JJUcjW7iJB9z3vDCsTyE7AAIK/uhbORV4VGymo0uqiO8XIxu2CCLNO6neLxy8Y+yg0+qWP/36O0rJbHLnt0fZrwHwCES93vWZv1thpMcFy+1OyvTN6QXxjl3Nt6Wv/bx5x1jenYoiCXBYo9lx5wnFjVioAE7gYb+6ba5PmHheFU56auzuhOr+PqsZ77ZDsA10pHr+I8E7YccLwpuTEBZMpcGv5EXYgojBSnWAvLTVR+ixuW1nrDYMhIsNW6bsvi1AEatWYPRNJJ7H9AdBN/6ULuAw2JSFY4+JDWjcJsbOCHx8KniQbtT3fLLPTO9+Z/C45DId1vzSCcutk9vMobfZDCxPWyvgKmTHVWScqRPhvX0Bk2eHZgvfApbuP82shNHwS99bqe1WO/NfpnYjz0y6bTqj4P7p/Q1Iec7o+gbmQDxpALNMux67tVm5mrPT/SjoDc0oba2XM161XSj8DAJaV5HflcqVirnQZDLx8/24DZbcdQEyAHKlFUBNLkt1PvpRQvRsF1kqls5rwbVwq4lgO0PGdGuiiBllcoiFUNP5EiWCab00bvLLqQUEF6SOurrb4/EVBZnGh9YLtLpml+WQ6dmkjbQ/LUZS1NrRO9HQiCCUNg4oV/lApJ/msePXwQSW+NuAnJbMDryta7I+Q== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6nB0zn8gATAfAx2K7dalK2G7dAKH6ALJGX0+nBdKIMRr/M460an8cUByAlb3rLTpvwAqV6KIl7VQVlzi2+PSlg22SCDcY+QbU8a52K0Uid073EW3s8dDiDsb4OKO6uJ/L1EXlGDphue1G/B/n93BxXmjDd8X3oy+FGD9gPQMLwgoJsgmMM+ozAcXCRVVQr5eL4Pr0MZjs7e7BSAyOeG5oVfGryPwvL/qkxYywPoQEMMycTRKc+rzK/nAQX36tJky+LHLw08/SWUtBoCxyk9M5NBm6wqvm3hVtFV2iq9YK8yjIGNL4HyCKT33jIp8oHrOotihpPn+Q8BIHH6RfEjZw6zPPuNnFOyC5sD8hdE83ol26/OoOJDLCt/Vw9c4gsfN2r+6Z+Tx2ymyd5Ksd+e5mu/DHubEf0jejsQTTJCU1xfYj1jsIgUBHxrH+F4kRyBRN6W3plnO83/19q2yIUNYx7+ZZrG73WGhRjQVyYnGdfQ6NpyvmAzR7ym49CVUzB/qJa+SUmBa4NadVVfevxTwXjFnKb7veJKRhprxge2NM1OGM2+0bgrZhzBCsnJ5rd0tCjMy5Nk7HSG3WnoOrN5zOUfgbQcSAjNlgSFF3laVMVJaUriG6/M+NV0MXUkrfYHiw/NAj0DvCviH7ceIBtmWIbkg8O1bcjS2KJT8irHr4STnncOKjLKsRfWU0MRVYS66dgAiuDeYyG7EQDkOSz9QuQY5MVIas4pHctg92WOOw7LUMqSx7wjAgNUYaUrSrMiII+xGiguVeiCftae/iBTtK4D5VBeHAHqLNpFQSK0c4YGHYTrUpkIWNczifCc4ZFZp6KkAjAlLOOLxtx6AF1mgUlDBGWTLHdRS2j0shWJQeXzx0J3+oD1qsMDEM5AlJlAeiiNoU7MkXoXeWq8W2NTGsNtrsM9D3o4iLKOtbhdiyx25kbXiV8CHGccoIEY+scxuc6IqdQWhXrnikPnPQCOOBvOf9mfigUpEmQQN9u6zatba/w6viRZ+VqxYXA3ArwgwsCVdFNJPF+aotGlZp8NDc7Ng1RZdgu1dd3zM80qOcMp2irsqj22u45gUfYvDD7yOALlNDGA34mLLujWme2y4G6NbHWhBgELuW2nWBm8/jieeFfwlGFR4cet+PXrHkD38CMsCWLib/hw3yMwzwWIK/bTD41oHKZ8crcHGoHPX+cs8qxgGpmX4+mTwmsHkuSf36cYV9Us5QqTsutxdedUq2KlJhBatlZBjgHirAv8bYBMQTK0YUYFYW0f7sehGAFBA7o8pozqGxL82ictb82JhcXUI9yI3+4lVLjf7xER1zCoGZJRdKXXoBKzBNh8X52lS X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22a971c3-d9f2-4e9f-80c2-08d96fc08bd9 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:25:02.2477 (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: o2scN7evRmKejYKde75cP2ftP6/DhJKnUg6PTbEPbbH89gaqApHJnqd9MEnyVlJNbAKIOieyHG8Mp1C3kXujJKItHG2eXlPmQngfY86MQGI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.102; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We are going to change the concept of "free host cluster", so let's clarify it now and add a helper, which we will modify later. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-refcount.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 8e649b008e..13b1fed43e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -961,13 +961,32 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, /* cluster allocation functions */ +/* + * Cluster is free when its refcount is 0 + * + * Return < 0 if failed to get refcount + * 0 if cluster is not free + * 1 if cluster is free + */ +static int is_cluster_free(BlockDriverState *bs, int64_t cluster_index) +{ + int ret; + uint64_t refcount; + + ret = qcow2_get_refcount(bs, cluster_index, &refcount); + if (ret < 0) { + return ret; + } + + return refcount == 0; +} /* return < 0 if error */ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size, uint64_t max) { BDRVQcow2State *s = bs->opaque; - uint64_t i, nb_clusters, refcount; + uint64_t i, nb_clusters; int ret; /* We can't allocate clusters if they may still be queued for discard. */ @@ -979,11 +998,11 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size, retry: for(i = 0; i < nb_clusters; i++) { uint64_t next_cluster_index = s->free_cluster_index++; - ret = qcow2_get_refcount(bs, next_cluster_index, &refcount); + ret = is_cluster_free(bs, next_cluster_index); if (ret < 0) { return ret; - } else if (refcount != 0) { + } else if (!ret) { goto retry; } } @@ -1030,7 +1049,7 @@ int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int64_t nb_clusters) { BDRVQcow2State *s = bs->opaque; - uint64_t cluster_index, refcount; + uint64_t cluster_index; uint64_t i; int ret; @@ -1043,10 +1062,10 @@ int64_t qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, /* Check how many clusters there are free */ cluster_index = offset >> s->cluster_bits; for(i = 0; i < nb_clusters; i++) { - ret = qcow2_get_refcount(bs, cluster_index++, &refcount); + ret = is_cluster_free(bs, cluster_index++); if (ret < 0) { return ret; - } else if (refcount != 0) { + } else if (!ret) { break; } } From patchwork Sat Sep 4 16:24:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CB3FC433EF for ; Sat, 4 Sep 2021 16:31:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A318960EFD for ; Sat, 4 Sep 2021 16:31:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A318960EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYZh-00050e-Jx for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:31:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTl-0002zF-QY; Sat, 04 Sep 2021 12:25:19 -0400 Received: from mail-vi1eur05on2102.outbound.protection.outlook.com ([40.107.21.102]:64544 helo=EUR05-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 1mMYTj-0007MU-Cu; Sat, 04 Sep 2021 12:25:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NPi5tE6pIl9bw+g4JSzkGVYA27ebQL/rCBWhZX2vuavcxS555/18q6MWXm1wV2n/nmR2QXn2R3TD8Bj4A/ZMi/Cl+kU/XPpod7r4oLr6Zny4S5xcsuC11EIzLsysu9dx3HF5tqP9uY/L6uNqZhbjAbXF/92xNrWxAKoCm8LyRdzbC5UxXoEjtYQld9vWVzm/9G4z3b67qv2L/MZC3GhtgwBnDRXwDtBjGfISYydXoJFVup70hhknNVlY0KW3lp5JjkbGMYGMjdOrXClPLNCuwQ/f37o2gJKBPF6ShstXTSMww1H0/8FlGJF3ypnvln3dlgj3n1LrxT2mrHY2uTu6Bg== 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; bh=2Jm/ALqpAlWR6O0eWv4deHHaO41M0YIuoGhIvVzyi28=; b=KpKAcki2PJmHz9ueCQXSNnVdKd6Abmc7LU9lCWxeh7J7+PDWO5lNZ95JwTwblONdk9DV1mYtRg6yeXbDJylNNjcIwqDto0crtGrMvecTAuFjy3j7CzNliBk4RXqKQhp0p0TgIpYaxLu0fXpZIO7JkvpMh1pIC7Fo7+9PYf7Ifh5cohMrnv6RncyONqymSTQg/swERvtWIFHZCK7hFrYIh4be+WpJB0iO358PQJMLSbAc0RsFDPAxsCHYSdsKT6YU0N9nqog4AAZuxSYoekAq/BPtN8fTmHJznTU7pXLuG/fwx8pVpoSeDt37KC1Egsz3ZBGoB6HrFz3C/T9xkAPR1Q== 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=2Jm/ALqpAlWR6O0eWv4deHHaO41M0YIuoGhIvVzyi28=; b=uQK46hDUomGRv94+XTzZYaKbYyCowl09y9SZllY3Zihyv+XlXh/2lUUwC8Fu5qxQiN3mV8T03jhwGY8qxpd62NTxLMvvdaK9S1pPrBg5diGyqqoGSD5OlnA5aXW2WeTUvxPDfXWbBlvDO0vPrc9Dv47ph9yp4EkY7r4HLSfPY9I= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:25:03 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:25:03 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 09/11] qcow2: don't reallocate host clusters under guest operation Date: Sat, 4 Sep 2021 19:24:26 +0300 Message-Id: <20210904162428.222008-10-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:25:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7af56da5-f192-4f56-6119-08d96fc08c99 X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VoUGl71bORnv1KJ7ZWxac7/jG7rek4s5GiHKHMdI2NYEeedRRl1GpIaawLo0SgQJOIxv4NHHSWC3/84h4ixrCkm6fnrG7UWrb6PJ8RXHzPiGEfgM/7oNDmauqROfj92UPLeOVvPg8zXdF6wwrW510AjRmixAoXGVWP78MBX4msfxPqFhtyORAfYj/n04wDlpuPCmFnvbgDAJiCX7IBuxzpO1wzMUSCNAQpfSLpgMs7xJuzOzjvkQAPiov0srwdAxHNcNcoVo6+p+RzFKXDrIgba6J3y3KAbrv4Y17PW1gSpsQWneIMJZFwe3AaBdoiTrv5410NZl1RXv0qMBTylB2Rcf/T4EHn18y6/r/BykUslrIUf1CM5uLfRfHFsiAxISMg7Nznl4UZny4pvbQs4wdutg3jK+CE6JhuB89RVapHBlsNzLCtsvya1ryQ78Rb9vN61vWju598LTy2CNkI+wgdXQgjksSajWsDFw0VNNgItWpet2fgagblfRDZUgSP8q0izNFq9rMBExLNpIYK7kP81HkZ06oF+3ZaOLGwec5zgPAuv5fMPdkNaT++hS6xnXcbqUFyQcv0O30YOMEvcHscuPz7RdPg7Z6ZifhuH5B+guS2KRKelLVcxeZbZ+mDnHo09GU25ejOXtuKjptkIvDJDp5NggVGFu+j2dYdXVW8gbYl41lGLdbQIcd09GeeK6eyrUlVNc6H9dLapkcEci0A== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PABffIRenxw0lP6K1tT00TNJefO/5T6F3d/ZAk9fGCJchYRKNoeYw9IJC8y0C1lmmmv3pcbT0jmtybIr6rL7zoFLmPWimX6Nz0e3aazTk026BlrMzpWHDXdGuhatuYjPej3E3n42u968MRbSQzrhknrbh8KSAZ0xD11PnhM6nl5+gMbYn/73O41BPR9ojO2Mjs4uLP4vSiIdd4VJpJEasa1HDQ/ieJt1l/T0PXuZGg3nQfY/p7w/XXBD1jywsXZequGia0I4GO0QifkpZiS1leBl1200iIPyZ1BExfVmIoHcaGuirS6fLxx4tHFijqlIE7fmjeSfYBXB3PRDYUewcbAqzMcYo0jZeooT6HF7j6q1baWHA9/dflzvoYHXBW59z5Gba0o7Mjeevh0Z/IZ/wuRG9brE1FNV6tcrxiwsb8BtOSvI71wm+lfBtPWuBoEe+DuFZoAPwax0WLa6xx/f0gYCjjBn72+AP5oIIsxi+wdvm/JCRY2YmYVtd5szotm3x/QA5qH3fy+ADy9bIbjWwZOpEq4ZhKlJwh6P7E0QAgKPPY65TKMlP4IRhx8Ho7jbxE2Vcpssn6LBYi72jZRw5ugfgJo8lxWGCF+7Hjd6YrTydgxYE8K59YTDc4+yWICstOK8o6PzUJDJAGU0UxKRw0bQhf6bl5cdrJbaOR/RorAC/3uNSG/ey3FyC9hAvoJ+qwZmVYslXItz/4Ty4gSFnazeNkg0MW/7yMzNKq3o37tn4lS56Fe6LDjCIZQyuWhWnEyZZz13lTC6+FMMM1z4KL7tqacE5EWa80JAEUoADS6W5ynBOXs+8cFu4FYXTJ3RhEE2Ulw/XnWyfnSsHaYV5Xp5tyE3GYgWcShpS8Aygo5Gs9N4oPkZfX7AwMCu6poUmt+1y8eZMfXR7G0gxBqI2XbHBVkpOFbWyD5kdbDNEsLFfPNc5qdVZLtuHr0R1ZSnIfNryIfL5JAepGb5oyP7meJvXc0+V/T6UVkgJr8UxholXJiOJFWD6tTHph8nW3ojkdaoivSIHk0rt7nHH375ZADJab/EhFijG7wp7h2bgsJk2/L9NnllUMargaixk8prgAQbgmVJrh1szPREjDYnEs8MlUKNEJKGa4Cqm+zE9oUHTGO4Yj0SBW+agDkVuQHfeG45hFVYxpFk6B/yD1dZA/iirOl0bkhe/e0UONm0ThoPJisxuG7rvc6JC8VJuu+JFKvCA7GdU8bm07Fx4YJorIgzSw3oJ7lwA+vWQIwicDO9zN/fDxgthKh/IbfogEot7CBFyRl0GWQqjeex4TqyLKwrgZl5ss+RxR5azZFmIdDUUClO41XbEfk+dTC/eF8J X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7af56da5-f192-4f56-6119-08d96fc08c99 X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:25:03.5878 (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: q8w/VXDZrSQh+1VEbdH+rFtRkxT7IeMa6CqAk3Xx4FB1LFZj7i1bR/TQeK6IAIaWseStK4zUn/aBIwtGWGcaOWnWx1s3W44EqH+RaxksfDk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.102; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We have the following bug: 1. Start write to qcow2. Assume guest cluster G and corresponding host cluster is H. 2. The write requests come to the point of data writing to .file. The write to .file is started and qcow2 mutex is unlocked. 3. At this time refcount of H becomes 0. For example, it may be due to discard operation on qcow2 node, or rewriting compressed data by normal write, or some operation with snapshots.. 4. Next, some operations occurs and leads to allocation of H for some other needs: it may be another write-to-qcow2-node operation, or allocation of L2 table or some other data or metadata cluster allocation. 5. So, at this point H is used for something other. Assume, L2 table is written into H. 6. And now, our write from [2] finishes. And pollutes L2 table in H. That's a bug. To fix the bug we now have guest operations tracking. The remaining thing to do is to handle these in-flight operations in is_cluster_free() function which is the core of allocating host clusters. iotest qcow2-discard-during-rewrite is enabled, as it works now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2-refcount.c | 7 +++++-- tests/qemu-iotests/tests/qcow2-discard-during-rewrite | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 13b1fed43e..e71bb9b089 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -962,7 +962,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, /* - * Cluster is free when its refcount is 0 + * Cluster is free when its refcount is 0 and there is no in-flight writes * * Return < 0 if failed to get refcount * 0 if cluster is not free @@ -970,6 +970,7 @@ int qcow2_update_cluster_refcount(BlockDriverState *bs, */ static int is_cluster_free(BlockDriverState *bs, int64_t cluster_index) { + BDRVQcow2State *s = bs->opaque; int ret; uint64_t refcount; @@ -978,7 +979,9 @@ static int is_cluster_free(BlockDriverState *bs, int64_t cluster_index) return ret; } - return refcount == 0; + return refcount == 0 && + !reqlist_find_conflict(&s->guest_reqs, cluster_index * s->cluster_size, + s->cluster_size); } /* return < 0 if error */ diff --git a/tests/qemu-iotests/tests/qcow2-discard-during-rewrite b/tests/qemu-iotests/tests/qcow2-discard-during-rewrite index 7f0d8a107a..2e2e0d2cb0 100755 --- a/tests/qemu-iotests/tests/qcow2-discard-during-rewrite +++ b/tests/qemu-iotests/tests/qcow2-discard-during-rewrite @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# group: quick disabled +# group: quick # # Test discarding (and reusing) host cluster during writing data to it. # From patchwork Sat Sep 4 16:24:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475697 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5190C433EF for ; Sat, 4 Sep 2021 16:38:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3354160F3A for ; Sat, 4 Sep 2021 16:38:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3354160F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYgf-0000Td-ET for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:38:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTl-0002yX-Dy; Sat, 04 Sep 2021 12:25:19 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTj-0007GP-QG; Sat, 04 Sep 2021 12:25:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eJHkxYeSPCABShQMrlpoSqkrC0FdbJtSvHjarYs5lC8gIgQ6ohLiB8bdhVLzXFJQA5duRF8QlQrL5Eof4r0Kk7ITCXNduzf2rBx39BPgdJEfTgGCTVEamDUgh+a3bWf6UEHMwQ13iHbdPqzCof0OWmCzMCV8LfmMQ/vJBWj8J1iAYufJzzxxMuOc7p+vE3/29XntVUbr2DDXCCUiNOAI56P50yXbXvtoBdzXvnZFBNnU0jkO6o68dJ71Z5OIcMjDOqFmQB7EW6vk/wu6QSoNQk2D+BixQoXFTBPIAcISAhqZuguAuN/L0W9U6rq5hoAo9wOknyJOOOr2ja9oIcHdwA== 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; bh=BQIqyLQHn7c8zKqpQ8Z3De+R/cykjR0/AQ7Zv4NG0/0=; b=jFKUo8oL83McIw7eIAZoz1vL82YnJYraUEu+ZkcykPdm2CicfaiLJBNC8MLhyMLjn7WRAdOyAE676i52gOhnIYnZQC7yN9AKTjyx/oFepJG3fUU65d6c9wRxxVwXK16G1JgnrIoFcib9CC7NVdGdD5BwB1ZO1tocrFKJVzKElSEmjT0JHrKu+mlYQHRAMsW7zN0JL8QzU8hc3hWa47/p/RUPPpKYUShAzy/QQON97Ms304PAGd8HuXbbMa7ERR9DYVesy/SWJyPpv8WYzBUAIlHCaGNBg4NkKJQvjeuYSQaFpQSusb/Y1Imstx5u4ab0CJg7StmBc3KaXTy+acsCaQ== 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=BQIqyLQHn7c8zKqpQ8Z3De+R/cykjR0/AQ7Zv4NG0/0=; b=itb1+2FZGoCoQtxbwbkseBrTwEOj8jN/vVtNC1YGKOPuCU7nsKPC2Hauy29NBD4wpVLR76slGfhS0LuvHuXy8pNOGaJxCRRo50IvCDWd83yMk/QOplb89Aqy2kzgvW5JnyyaP+gUga2sUJDdOrVqBCCdInILzrlkrtLmIcn4LXY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:25:04 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:25:04 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 10/11] block/reqlist: implement reqlist_mark_req_invalid() Date: Sat, 4 Sep 2021 19:24:27 +0300 Message-Id: <20210904162428.222008-11-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:25:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 852aa6e4-2aef-4dbb-2012-08d96fc08d3f X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sQQjyr1W4Cl4gACG4IKbwzZ0zKYmonSFa5zzLNz+/deBlN+VJ38Yg5rSZct/i2i/TutMgaRPgf5Uvo48mxNKhXaSp2KwaRF3UD1wLBLwbWv1y2awluJpxrGdWkcxJYLyQfopt+MPYrsL+qBIA60PqgGgS8pVTpNmBsBMvE7/xnGzIyU8bROz8yMrewsOMEOIvaj3xNvCl3lbtNXbkqrtR/g9e5WnQqAliHVJLPoOw8QHXu2WBU2HWVoJortmc4x3eEC1naul5YLyB6HQ3VdwNOshAXJsGRLfdm788UHGqc39tsHvaKxUgrb8R9p4y5KsoR5Ok4v394u+sn2jYD3VCPAdv3VK2hslzAP98PODSUyCidPYP1/9AUkE7CtO+1RdM7MORdOJ0oAKvZkYzOHGObqpQl1BE/BAR1suM1GwdCZ9O0S+/BRSw2SaBa79Wzk9/Lvb+swZpEFFGnjcWZhiE98uYId9mpHiqebEBaedjVC48/QdC/3Fpeaytb5HaZHLoyU8F+zLtCXBvzEx5mH7RLnkGEF4jQBfEVtPElom+/tzfY5AELD0Pxt8MOr576BrX4ekhK1SuIL9kx1+rqf0LlB7IpxRgx65zi9SL9Ud2NsVSFL/2zwhFvxRzcunXuj8AQlLEBg0fM12Szs1DaVCbbEob7zlocPjJ0NMN/OckPfQ1dhirSvywV83yMLO1Ivo7Hc85VruAYI0tc4b/vk5Mw== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WxnqpQt5fwqlATgqh9tiElh3AGee903LbGw0jhAodRmf6LGmxlQ+hXcJpkD29RZG6LgWCKmyXCNn0dAi4wKQ/1eLCfsKEsjMnkyF9vJWFyXWvOguRJD58d/W0CCYE90qN7pl8ntUUKX6kRz4D01pVLSkzbZKMcf1amKi002tcjWjbzyv3HYHB9ZjV8qLcv70AxI+pxol3Rx+GC+M5ZIEJbf1Cky06eN02Gkdvx8pW3b6JIGMP6q/1kIIjEW1QkNFfpBFG18uAEikjdEYDIaWUji1L3TXyxio817V9I/kXCwFe52bxhd6fmvq30DSkIQ0QCxp6cj06fklJ7B1wIfDCHHueh39GnQ93sCGA4qqL4EfJJqveIyhQusXbBeLJyPj3EYaTlwNJeSsS++a0IDX24SNdCOBp9x6SlQeJFbpM0ftLRUTuCe96kwa7tUgo6j5ISOeKtvUfCupAs5DD4Fb7ffGgk2qSixRJCEPCIrc65nPqGtF0yTtMJme6EEvVVxOP2blfjlHa1lQGBxxC1+S+NhPEePXhE5bRJRMrjPn8Lls5N7084AX4dQ5VweG+etr4KfFEIlX8DwuTCS+vlvBme/uddEsaSmFK0YQrfrutLPqnmjchagg8W914yKhhPlJ8Ny6PNunvWM/RVs5eNs43w/1LRdXuiujJmA06HlOOM5FeMify6BL+PTUCShNfuvq4zHR+k+ftIEqMe1nLYm5zQh001M7/NEnamqSzWX0MpelIHz60OVxwVz87r+DRwX1u3aMJMQxsqaQN5LO6QwAs0byZN6+KWm81H4y/ZSv/2VJjmvSzc+V05Lk3sibsZjXRUvg3VgncNubWHwiP1CM9yigb07E6xuTf1v+xtPhf749raYsn8HIaltzpj4Y2pBU7wfXFP61w0YODGZ3st6NF+KPPi4Zwjfl1n/+WxlxgZfkOq3PjdW6pIBoj/ckrbuEOaBGHxrY4Nw8ou+Ec7SWfIEK4odE2Y09vWWMqQRk4It2qdXU14aq/Vnx90QVck7Jyr5RHvKx9xoIlSzS11ODK1E3mfa4VzkcOz1mA8jCtoT6fT46tLeqUnxlex2Pdhgb5Y+MFwvcBpOjUKHBjdtGkzANbG5/8+OG6S4Uk803yawLJcnnl18PLksKrDJ0vQ8Wa6aCmPupdfWEyATjf5hWC34yOgzkEn1RS1faMb5Lq7Vaq6jjgsDxrvQuLjZnUIL1eF131q8qo4ROcOLBveBQwTlFBrLMahGj/ECvLGh5FFlJni176mcUdKY9deCpK+g2OEUXeF5EnkZlQu0LNRpixqF/bssN72JI/M/KFCbZIsebf/jFOuUFUKSMqc5gSO3y X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 852aa6e4-2aef-4dbb-2012-08d96fc08d3f X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:25:04.5954 (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: VN+JYkdnU841Q+bp6pJXL+GM9EwZGZNiUQ3jauerJ+JkIIe4IUphd+eU8+eMfMMjm5kJLmwAROlxIUrsF/T+dKmwalfKD+fsGfuyZh0845c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We do lock qcow2 s->lock only to remove request from the reqlist. That's quite inefficient. Let's implement atomic operation to avoid extra critical section. So new interface is: 1. Instead of reqlist_free_req() user may call atomic reqlist_mark_req_invalid(). 2. At some moment under mutex user calls reqlist_free_invalid_reqs() to free RAM. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/reqlist.h | 13 +++++++++++++ block/reqlist.c | 23 ++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/block/reqlist.h b/include/block/reqlist.h index 32dc87666f..24d6d93a6e 100644 --- a/include/block/reqlist.h +++ b/include/block/reqlist.h @@ -26,6 +26,7 @@ typedef struct BlockReq { int64_t offset; int64_t bytes; + bool valid; CoQueue wait_queue; /* coroutines blocked on this req */ QLIST_ENTRY(BlockReq) list; @@ -84,4 +85,16 @@ static inline void reqlist_free_req(BlockReq *req) } } +/* + * Invalid request will be ignored when searching for conflicts. + * The function modifies .valid atomically and intended for use when we + * want to avoid using mutex. + * If you use this function don't forget to also call + * reqlist_free_invalid_reqs() sometimes, so that list doesn't grow endlessly. + */ +void reqlist_mark_req_invalid(BlockReq *req); + +/* Remove all invalid requests to free RAM space */ +void reqlist_free_invalid_reqs(BlockReqList *reqs); + #endif /* REQLIST_H */ diff --git a/block/reqlist.c b/block/reqlist.c index c580752db7..641307d80d 100644 --- a/block/reqlist.c +++ b/block/reqlist.c @@ -14,6 +14,8 @@ #include "qemu/osdep.h" +#include "qemu/atomic.h" + #include "block/reqlist.h" void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, @@ -22,6 +24,7 @@ void reqlist_init_req(BlockReqList *reqs, BlockReq *req, int64_t offset, *req = (BlockReq) { .offset = offset, .bytes = bytes, + .valid = true, }; qemu_co_queue_init(&req->wait_queue); QLIST_INSERT_HEAD(reqs, req, list); @@ -33,7 +36,9 @@ BlockReq *reqlist_find_conflict(BlockReqList *reqs, int64_t offset, BlockReq *r; QLIST_FOREACH(r, reqs, list) { - if (offset + bytes > r->offset && offset < r->offset + r->bytes) { + if (r->valid && + offset + bytes > r->offset && offset < r->offset + r->bytes) + { return r; } } @@ -72,3 +77,19 @@ void coroutine_fn reqlist_remove_req(BlockReq *req) QLIST_REMOVE(req, list); qemu_co_queue_restart_all(&req->wait_queue); } + +void reqlist_mark_req_invalid(BlockReq *req) +{ + qatomic_set(&req->valid, false); +} + +void reqlist_free_invalid_reqs(BlockReqList *reqs) +{ + BlockReq *r, *next; + + QLIST_FOREACH_SAFE(r, reqs, list, next) { + if (!r->valid) { + reqlist_free_req(r); + } + } +} From patchwork Sat Sep 4 16:24:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 12475699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7346EC433EF for ; Sat, 4 Sep 2021 16:40:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB1E760F3A for ; Sat, 4 Sep 2021 16:40:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CB1E760F3A Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:41316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMYiK-0002te-SP for qemu-devel@archiver.kernel.org; Sat, 04 Sep 2021 12:40:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMYTn-0002zs-Ln; Sat, 04 Sep 2021 12:25:24 -0400 Received: from mail-vi1eur05on2095.outbound.protection.outlook.com ([40.107.21.95]:18546 helo=EUR05-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 1mMYTm-0007GP-1X; Sat, 04 Sep 2021 12:25:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jKYxJgVHMowtPN38b/QTSY8p4ERd3gRoqsFSwuqEvp+RVxqVqowzV+/FXZNT1yvS9Ln0gqtVyyWOJ46WWsy1v+lrbysHnv3fpeVEAODuDMYE29BcjvAa6MJY7XrgXHkQfJBZ4M6GN0QSiEaOtAB0BtUPpf3wokxLi3I70uZ3ojJ32AnI6mw4VszgM1CQUpibr4rOc2E0aSbESV6E1W4MphKKA5+jzNeCi/Izjy/50gdkRve2B7oOQm8r68QQvBskgzmvpPyXNOR4VnseNjMfkncpSwWJJfVMC9cFJi5Vtdmwksczn6tgeSIlFA2X6S6zDh6X0idUItZpS83GXyrD/g== 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; bh=LMaBfg8VvlNM9Ib/8Ou/neYhEZLhouR0GN9AA8FciwY=; b=fp0R/jQpNOE4Ifhpcp528+vASaZYMyhEXxfHQdPjNiZnjZEJJlJDfH4yYJuQpuB1oWhyYy0zxQVkmjzC75DAf0qevOey18NjlLOw3lYX/wmRPzO0/DVjUGIgKXY6M6ZjlFAHtY/1yeQp5RVLEHzgE/LpiVHS0oG1+idKR11yJWRtR7rBiK7J+4ozNkgvJbAon3YjZlScPO9cX6cQ4babOWync6641mqcG4doPNLa9w5o+6XgOW/LObNfrPn3PaUEHtqTLntaOYftFilxsQj/WXWN7sowDe39eWUVFLtN2+VtDdhLxV6dkfJJeSAl0q1IVAjI7hTSeicWQ8BvyyWUyg== 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=LMaBfg8VvlNM9Ib/8Ou/neYhEZLhouR0GN9AA8FciwY=; b=O/pBgPWaRUI+gHgW+Z8vj+9sDzQQUfF9kvO5bDvpmUgg0eQvpDmm09Z8i8w8p5rEeMUKptyhjD/RDSnmHzfWu1nkEfjDBnVYRPdNG0PlV2DZd6rzD/D3trGnW2DV2Z/P/zSvz9YSC3kc7ytK0z7EiLW9/+8Ua1L7iEeFBMVRNwY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AS8PR08MB6904.eurprd08.prod.outlook.com (2603:10a6:20b:394::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.20; Sat, 4 Sep 2021 16:25:05 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::2817:53b3:f8b4:fe22%8]) with mapi id 15.20.4478.024; Sat, 4 Sep 2021 16:25:05 +0000 From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, vsementsov@virtuozzo.com, hreitz@redhat.com, kwolf@redhat.com Subject: [PATCH v7 11/11] qcow2: use reqlist_mark_req_invalid() Date: Sat, 4 Sep 2021 19:24:28 +0300 Message-Id: <20210904162428.222008-12-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210904162428.222008-1-vsementsov@virtuozzo.com> References: <20210904162428.222008-1-vsementsov@virtuozzo.com> X-ClientProxiedBy: HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (185.215.60.196) by HE1PR05CA0275.eurprd05.prod.outlook.com (2603:10a6:3:fc::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.17 via Frontend Transport; Sat, 4 Sep 2021 16:25:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 082fc503-e653-4414-7e0b-08d96fc08dea X-MS-TrafficTypeDiagnostic: AS8PR08MB6904: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:626; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yc/oA9l7xkGHtc/HaVw3Gq/A16rwvUezRfokFyRniD+0vsqSjFlZ8Yyp0BGBr/8VP+mhPhvKdyvubLVRDdLFsRWmigDt+nSRnRg+NGQU5yUNgPvWq/CoTbGklmWENoWJiGPDUNQkq3Qs7GDwr+Xtkb2U6g/xvrt47QKdDhBTKByRy8YNVyzS6k41AbNrGHrHohIJ0q88Du4rg9AcOXcX9WjLwg1K2DaPO4prqq3DETOSbfUVD2xTfssAXyapIDmU5hHwjtopDDScLX0BOwX9hhOoQTJYxHnUzZK0C6eJQzcY6HfJNSjELLl4bLwDwEES3Rle6jwnRbfoJLDm7nt1hFsUGzyo01i9FRSPh3HuwAuasEXP3lW5RyvbcYo1NTraNu6XLNWkNOZ8sqOA4l715dJgSUjynuEHShQZnS35ZMxEZtTFFXnSCPnvveY6b+O2O+BMYf9lti/XaG9huzXeMAbmHyMjTlmY35Awl7+sWrT06lb7YucFjdtoVqGPgt1snCS0R8cdX1UsimX+B+hARTL33u1a4Tj71M0x1FSnQzw08HahoWw8KuUdBrEc6k5YHfyVTuSIT4XpFeoFVsUUqpkknOVEeR4PQyi15xdl+KK0IO700ZEwo4+SadmLmJmLE61mnVeTZK4MkuLSYtpsukIEXAOG1VgMV8G4ets9bNZqNvgQeUvTiSVNObCiIj0eUyOpsaYAEEh/S+gsx7ElCw== 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; SFS:(4636009)(346002)(136003)(376002)(39840400004)(396003)(366004)(6486002)(66946007)(8936002)(52116002)(6666004)(83380400001)(478600001)(4326008)(38350700002)(186003)(38100700002)(5660300002)(2906002)(1076003)(8676002)(6506007)(86362001)(6916009)(6512007)(66556008)(36756003)(26005)(2616005)(956004)(316002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dYOHVUo4olKKLp51S7yo0EbfPiIEEzqYReWP1KxiRN/imcIAuP3I13MVj7zQ2yhIgLLxPEyPyS57I2+Rt7ZqthtaP7xzYmjycMoV02hMCzeQM7ZbBBkW9n5qBBKUf0bkGIKma1/T8wlrQvIPvSa3nzFX3sTl3cgXl9/sh1QV3hGuQ7i410Oi4S9VvWPvrIeY/19pPPIJwyWLcr+8MmhBh5K3Ezz4soRjLjvGxqvgKgkHaz7urgD5S7QjR5BEB4vcYqW2w3Npwo7QU1j4dJod9E+t82wnYaA3bj9lQvSymsHNrg8xMBBNJ7UfUroDHVQXDY7OrUx440ghhqN4rhnYOL6kkMLY+8z00MtZyxl1LP3T1aVQ0zAMA2bYPklVSPwZV5c8+9o/pYAJlxTmbr8EHYKBmMHhXh8/6AWxYt+4pthmxsY5K4a3hUr2dR0Y6RUXeHckjZnmaysty0EDZcm34uGjoTMtDuWD5SKPmWhUAXmNa2E8637DuX7igHzKZzmqOcaJLrd666CWryddrnW8CfJ/dGyKvNs8pTXOH7nwl0KE3QOxHOqJqOWYIgtW/9rhHLsPaiNvN1elUQJv0wk5hITixxGnBRIrpzxPmz/WS8JLcQa4Z7mYCEXM8+hl3cInPlVmEXYYKoleeabjUinK5YOAIFS0d+6VmWJ5MDpeo6OsldQRn8m6eBTv50GREgtEn89eVMKirFZbtwmsnIk6DUM560c+3XgxjlCVDA4WD73vnSLSGlh9cchyFm3/ibkEdHHtcCxt0qMru42Ysbz71V071cCjMeEGWwTpqOKSDO7xn64mRLA50ensToANq+ZTjio2YYoN2XWzbc2Y73A+0aZ5ADL9KtNj39F1J7sVGeEtaBT5qj3Zb5tW7yI3tZ1fbczSOndcOXybPogx9aMzytGy5y7qpyTQU/BXFXa0GAWr7BX6gq8VQGPrN1SJzipni5brJKOQClzMnViTkbziEggReUh21QXy4ycmoUq8Qo4RnGlnawZiBsSJK6VtR26NkTbN9uRTkIbSe+lbLayU/7MAtugWtSfPy9cLeJCkp6jlOuO8+Mfb9YXrSRygAfzSofh63dsGkRjTpUlS1um/st0qtS0iD7a5zAJLQrOt0fHb2T44QTVqIOsq+65a2o7kDg+jeoCAp1vTl1HouW56n7+zfK/uyUfV9E1dvPczg5bGub+KZFqJhkzYvLNuJro10o49w6EE1zxIomBupLTq9E//aXReshb4JzICeJavMvVIYmDG0dzmZCIKAA+BNfY08/KTxIXcs6C4Sokvq3eDieKF0K4dkY+fpP+9vSmbs1s1Eu/IGVwAkaBvEI5QF4KJ X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 082fc503-e653-4414-7e0b-08d96fc08dea X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2021 16:25:05.6538 (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: EZY2CrU4M1Ry4rLCE1N5qlL85iEJ5QtF9Vxj8wqd2BWJWvKJzn41LrWdqNHGY7kJZyJhXl/E6dMMzQd55Xn1kAGr/Zaq0MFWVBZZXigBqkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6904 Received-SPF: pass client-ip=40.107.21.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of small critical sections which wants only to remove a request from the list let's use new atomic interface. And don't forget to call reqlist_free_invalid_reqs() when we are in a critical section anyway, to not overflow the RAM with invalid requests. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/qcow2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index aefe6558b6..f2094c1ecc 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2306,9 +2306,7 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDriverState *bs, } if (req) { - WITH_QEMU_LOCK_GUARD(&s->lock) { - reqlist_free_req(req); - } + reqlist_mark_req_invalid(req); } return ret; @@ -2348,6 +2346,7 @@ static coroutine_fn int qcow2_co_preadv_part(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); + reqlist_free_invalid_reqs(&s->guest_reqs); ret = qcow2_get_host_offset(bs, offset, &cur_bytes, &host_offset, &type, &req); qemu_co_mutex_unlock(&s->lock); @@ -2769,6 +2768,8 @@ static void qcow2_close(BlockDriverState *bs) qcow2_refcount_close(bs); qcow2_free_snapshots(bs); + + reqlist_free_invalid_reqs(&s->guest_reqs); } static void coroutine_fn qcow2_co_invalidate_cache(BlockDriverState *bs, @@ -4619,6 +4620,7 @@ qcow2_co_pwritev_compressed_task(BlockDriverState *bs, } qemu_co_mutex_lock(&s->lock); + reqlist_free_invalid_reqs(&s->guest_reqs); ret = qcow2_alloc_compressed_cluster_offset(bs, offset, out_len, &cluster_offset, &req); if (ret < 0) { @@ -4641,9 +4643,7 @@ success: ret = 0; fail: if (req) { - WITH_QEMU_LOCK_GUARD(&s->lock) { - reqlist_free_req(req); - } + reqlist_mark_req_invalid(req); } qemu_vfree(buf); g_free(out_buf);