From nobody Thu Dec 18 13:25:04 2025 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643735884; cv=none; d=zohomail.com; s=zohoarc; b=c2yPCsww28hshRI3Y+906Bskc6FxirrdsCEePbctco51y0qXSqknofe+KXRG0hQ51h/g2kb+cjDQxm1G6KTg+wT/2MpjPeBtngRHTBVIpqyHIfXkXyqogQ6wzIjarV+Kp/AKYtzbDAI04AWXkc3NT4bkM387EGoMsWsSfydnns4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643735884; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eQK+3U52XZ6l1GTnpFZywTk78EoaRBZzHQS8RCJGM8Q=; b=SVY6G62IeOerMQ92PaM6P+NmfsKLk30phtjWlwqdbJO3d3iEsrxjiq22LorMMkXIqpu7yazjbdFjo2ImaXpT71/WF5hMzZg5tuVikv0S7sDDK5ACA5Gf+wXP81xqlAABbZ+32RIJWNKwQCh0SMO2NibcDnYhvC3vkUgMcaaeTXA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1643735884915160.8122397357174; Tue, 1 Feb 2022 09:18:04 -0800 (PST) Received: from localhost ([::1]:45534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEwn5-0000RN-Rs for importer@patchew.org; Tue, 01 Feb 2022 12:18:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEuyQ-0002jn-3Q for qemu-devel@nongnu.org; Tue, 01 Feb 2022 10:21:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEuyN-00041c-Ez for qemu-devel@nongnu.org; Tue, 01 Feb 2022 10:21:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-47-ey5geFvzP-y6JTRGxaqr7Q-1; Tue, 01 Feb 2022 10:21:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75D5984DA47; Tue, 1 Feb 2022 15:21:29 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EFD874E98; Tue, 1 Feb 2022 15:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643728895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eQK+3U52XZ6l1GTnpFZywTk78EoaRBZzHQS8RCJGM8Q=; b=I9z7kSziAW3az1aHweBTK84Pwht9G0FaCSqqmB/kvsfGnxrIhz3MznYUlw8p0rYw30HlT+ uXYw1GhrD4ZpE/JhV3FSpwW0DRbBY8qZZtJobyedgDtw/9khfoqU5SBsTdObE1Jn01iy48 hexvjHMHzSssd103ACH4nqVMTuPFX34= X-MC-Unique: ey5geFvzP-y6JTRGxaqr7Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 10/10] block/rbd: workaround for ceph issue #53784 Date: Tue, 1 Feb 2022 16:21:08 +0100 Message-Id: <20220201152108.171898-11-kwolf@redhat.com> In-Reply-To: <20220201152108.171898-1-kwolf@redhat.com> References: <20220201152108.171898-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.081, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643735886929100001 Content-Type: text/plain; charset="utf-8" From: Peter Lieven librbd had a bug until early 2022 that affected all versions of ceph that supported fast-diff. This bug results in reporting of incorrect offsets if the offset parameter to rbd_diff_iterate2 is not object aligned. This patch works around this bug for pre Quincy versions of librbd. Fixes: 0347a8fd4c3faaedf119be04c197804be40a384b Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Message-Id: <20220113144426.4036493-3-pl@kamp.de> Reviewed-by: Ilya Dryomov Reviewed-by: Stefano Garzarella Tested-by: Stefano Garzarella Signed-off-by: Kevin Wolf --- block/rbd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 20bb896c4a..8f183eba2a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1320,6 +1320,7 @@ static int coroutine_fn qemu_rbd_co_block_status(Bloc= kDriverState *bs, int status, r; RBDDiffIterateReq req =3D { .offs =3D offset }; uint64_t features, flags; + uint64_t head =3D 0; =20 assert(offset + bytes <=3D s->image_size); =20 @@ -1347,7 +1348,43 @@ static int coroutine_fn qemu_rbd_co_block_status(Blo= ckDriverState *bs, return status; } =20 - r =3D rbd_diff_iterate2(s->image, NULL, offset, bytes, true, true, +#if LIBRBD_VERSION_CODE < LIBRBD_VERSION(1, 17, 0) + /* + * librbd had a bug until early 2022 that affected all versions of cep= h that + * supported fast-diff. This bug results in reporting of incorrect off= sets + * if the offset parameter to rbd_diff_iterate2 is not object aligned. + * Work around this bug by rounding down the offset to object boundari= es. + * This is OK because we call rbd_diff_iterate2 with whole_object =3D = true. + * However, this workaround only works for non cloned images with defa= ult + * striping. + * + * See: https://tracker.ceph.com/issues/53784 + */ + + /* check if RBD image has non-default striping enabled */ + if (features & RBD_FEATURE_STRIPINGV2) { + return status; + } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* + * check if RBD image is a clone (=3D has a parent). + * + * rbd_get_parent_info is deprecated from Nautilus onwards, but the + * replacement rbd_get_parent is not present in Luminous and Mimic. + */ + if (rbd_get_parent_info(s->image, NULL, 0, NULL, 0, NULL, 0) !=3D -ENO= ENT) { + return status; + } +#pragma GCC diagnostic pop + + head =3D req.offs & (s->object_size - 1); + req.offs -=3D head; + bytes +=3D head; +#endif + + r =3D rbd_diff_iterate2(s->image, NULL, req.offs, bytes, true, true, qemu_rbd_diff_iterate_cb, &req); if (r < 0 && r !=3D QEMU_RBD_EXIT_DIFF_ITERATE2) { return status; @@ -1366,7 +1403,8 @@ static int coroutine_fn qemu_rbd_co_block_status(Bloc= kDriverState *bs, status =3D BDRV_BLOCK_ZERO | BDRV_BLOCK_OFFSET_VALID; } =20 - *pnum =3D req.bytes; + assert(req.bytes > head); + *pnum =3D req.bytes - head; return status; } =20 --=20 2.31.1