From nobody Sun Nov 24 08:23:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1725881744; cv=none; d=zohomail.com; s=zohoarc; b=mKJ29EYSy7g20InPWHp1PgTrjhfkvFUst3UScxiDutH4ZdI8e+a72nNAZGLr5bKOZzQ+tFgywPNbU7U2S0Cl3/lJmvXVS5wiFB5ZnGbZj7XHPxOVYGZYocsrr9AjfQTW0FdwwOFQ3KFnptoduV1znjUSQASohTKyZ7clOpMWwrs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725881744; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ROim7xG4VeV7okIeoWk1lldyf4YzP1rLfO+fx4YPjhw=; b=k076vetjg6j6KPHI3znFw5dJjGuRhHPSoxJkkBMZLSFfmlzWfKSz8Wnvn5djFPbdTwh7km76CRjkDjrHcogVynjrpQuYLfZbG0n/E+NhQNW2FYobzcVyhuB2Upz1H3sMZGJ7jGeDPy7RFT/1x2840NYeoqQVqghPqBxqx7mZoOU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725881744596868.2323341931198; Mon, 9 Sep 2024 04:35:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sncfz-0001v6-NS; Mon, 09 Sep 2024 07:35:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sncfv-0001n8-3k for qemu-devel@nongnu.org; Mon, 09 Sep 2024 07:35:20 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sncfq-000133-SC for qemu-devel@nongnu.org; Mon, 09 Sep 2024 07:35:16 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-206f9b872b2so20677075ad.3 for ; Mon, 09 Sep 2024 04:35:14 -0700 (PDT) Received: from TF4D9JK212.bytedance.net ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710e328aasm32378605ad.91.2024.09.09.04.35.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Sep 2024 04:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1725881713; x=1726486513; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ROim7xG4VeV7okIeoWk1lldyf4YzP1rLfO+fx4YPjhw=; b=fwo8TRh6WvGpAnKYi0cK1UkQWr5cA57Zb5WRJ2GPnKFoue7kzzissNqGESs68vGeQX WlmZRcZoCi/+BnITrf7VW37kDJaVhwETFJTNqmMDtkQw0biihnrMOUaGhHeJ+H/qGhW8 d+D9pMgHcH114Dda46ndcGPSeG8pRXtxaobvg3ADdSmpymUlnzQECVE9oE3vfRL5gwwR w9hJHsIbjOL9R6Q1RkLniFPDm3mO2Fhg4/71FM2kUgbpvIeI9281+HjAxdEZBl9isxl/ IDh3l16pZnoDOLAzLAusicNdz3untBNO1+d6SClsL1FuIz2S45nC3plXcTb1z5VdjJ+t 9V8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725881713; x=1726486513; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ROim7xG4VeV7okIeoWk1lldyf4YzP1rLfO+fx4YPjhw=; b=s0zPOFmOZmffAPp/A0jyCmM0feRcNWafygevBUq7hMDt35ynHeaRsDuihhY1HpTBoR L9tyG5RbCH8lDl1+MRbbOhunXulI0GAcrIKYgv1KvlD9CZVO9JT7LJQPtYplzfk6bWu6 IoZMk1Anv51NgTMWhZak85xGYOd3kCSy58uV2D8N60cB62yc9gVEiXOFm/Qmg72JWTcN vkAHMbr+l1YPvcxrog0vhyW3C3Lh6SUAyKTZeIXspxNGXeV10vHsCS2QH5+9BD2J9eR7 a85nDaxy9/UymoX+Y82BlGKk2wVdb1Dq9mAsStmtDVEBzf4Ar9+mawhqJVhBg5NjHRfV 5sWA== X-Forwarded-Encrypted: i=1; AJvYcCX+YMAG6eX/bu9Noa4F2ZBTXxBI9Dta3cBbgFHoJhHn5FECyANfJzaHcmTcNlEOP07OjxTqTXq4yuvM@nongnu.org X-Gm-Message-State: AOJu0YyhV+1ZNa9gYYuMY7EKCEiMAxa9RLVbpq4QGqsZiQV8VPKt5KTw b88ItBFDHJgCPOs9BIOc/jycMpkbH8TMBY1mQfCWwlqR9sV21uraWMc0p52y0Ho= X-Google-Smtp-Source: AGHT+IEGr6LjhgAzodRzOvESYoM9h9YlkI6ssX8Pbmu6p28nG+ymxRFIOrGiwqmNP/J6m1rMWq7YDg== X-Received: by 2002:a17:902:ebc4:b0:205:43d8:710f with SMTP id d9443c01a7336-206f0652a75mr106711025ad.58.1725881713431; Mon, 09 Sep 2024 04:35:13 -0700 (PDT) From: Changqi Lu To: qemu-block@nongnu.org, qemu-devel@nongnu.org Cc: kwolf@redhat.com, hreitz@redhat.com, stefanha@redhat.com, fam@euphon.net, ronniesahlberg@gmail.com, pbonzini@redhat.com, pl@dlhnet.de, kbusch@kernel.org, its@irrelevant.dk, foss@defmacro.it, philmd@linaro.org, pizhenwei@bytedance.com, k.jensen@samsung.com, Changqi Lu Subject: [PATCH v11 02/10] block/raw: add persistent reservation in/out driver Date: Mon, 9 Sep 2024 19:34:45 +0800 Message-Id: <20240909113453.64527-3-luchangqi.123@bytedance.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) In-Reply-To: <20240909113453.64527-1-luchangqi.123@bytedance.com> References: <20240909113453.64527-1-luchangqi.123@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=luchangqi.123@bytedance.com; helo=mail-pl1-x62f.google.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bytedance.com) X-ZM-MESSAGEID: 1725881747168116600 Content-Type: text/plain; charset="utf-8" Add persistent reservation in/out operations for raw driver. The following methods are implemented: bdrv_co_pr_read_keys, bdrv_co_pr_read_reservation, bdrv_co_pr_register, bdrv_co_pr_reserve, bdrv_co_pr_release, bdrv_co_pr_clear and bdrv_co_pr_preempt. Signed-off-by: Changqi Lu Signed-off-by: zhenwei pi Reviewed-by: Stefan Hajnoczi --- block/raw-format.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/block/raw-format.c b/block/raw-format.c index ac7e8495f6..3746bc1bd3 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -454,6 +454,55 @@ raw_co_ioctl(BlockDriverState *bs, unsigned long int r= eq, void *buf) return bdrv_co_ioctl(bs->file->bs, req, buf); } =20 +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_read_keys(BlockDriverState *bs, uint32_t *generation, + uint32_t num_keys, uint64_t *keys) +{ + + return bdrv_co_pr_read_keys(bs->file->bs, generation, num_keys, keys); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_read_reservation(BlockDriverState *bs, uint32_t *generation, + uint64_t *key, BlockPrType *type) +{ + return bdrv_co_pr_read_reservation(bs->file->bs, generation, key, type= ); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_register(BlockDriverState *bs, uint64_t old_key, + uint64_t new_key, BlockPrType type, + bool ptpl, bool ignore_key) +{ + return bdrv_co_pr_register(bs->file->bs, old_key, new_key, + type, ptpl, ignore_key); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_reserve(BlockDriverState *bs, uint64_t key, BlockPrType type) +{ + return bdrv_co_pr_reserve(bs->file->bs, key, type); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_release(BlockDriverState *bs, uint64_t key, BlockPrType type) +{ + return bdrv_co_pr_release(bs->file->bs, key, type); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_clear(BlockDriverState *bs, uint64_t key) +{ + return bdrv_co_pr_clear(bs->file->bs, key); +} + +static int coroutine_fn GRAPH_RDLOCK +raw_co_pr_preempt(BlockDriverState *bs, uint64_t old_key, + uint64_t new_key, BlockPrType type, bool abort) +{ + return bdrv_co_pr_preempt(bs->file->bs, old_key, new_key, type, abort); +} + static int GRAPH_RDLOCK raw_has_zero_init(BlockDriverState *bs) { return bdrv_has_zero_init(bs->file->bs); @@ -672,6 +721,13 @@ BlockDriver bdrv_raw =3D { .strong_runtime_opts =3D raw_strong_runtime_opts, .mutable_opts =3D mutable_opts, .bdrv_cancel_in_flight =3D raw_cancel_in_flight, + .bdrv_co_pr_read_keys =3D raw_co_pr_read_keys, + .bdrv_co_pr_read_reservation =3D raw_co_pr_read_reservation, + .bdrv_co_pr_register =3D raw_co_pr_register, + .bdrv_co_pr_reserve =3D raw_co_pr_reserve, + .bdrv_co_pr_release =3D raw_co_pr_release, + .bdrv_co_pr_clear =3D raw_co_pr_clear, + .bdrv_co_pr_preempt =3D raw_co_pr_preempt, }; =20 static void bdrv_raw_init(void) --=20 2.20.1