From nobody Fri Mar 29 11:15:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642085229786597.2060990135557; Thu, 13 Jan 2022 06:47:09 -0800 (PST) Received: from localhost ([::1]:44982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n81NX-0004vd-7f for importer@patchew.org; Thu, 13 Jan 2022 09:47:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n81LB-0002qE-1q for qemu-devel@nongnu.org; Thu, 13 Jan 2022 09:44:37 -0500 Received: from kerio.kamp.de ([195.62.97.192]:47258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n81L7-0000ue-2X for qemu-devel@nongnu.org; Thu, 13 Jan 2022 09:44:34 -0500 Received: from submission.kamp.de ([195.62.97.28]) by kerio.kamp.de with ESMTPS (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) for qemu-devel@nongnu.org; Thu, 13 Jan 2022 15:44:27 +0100 Received: (qmail 29074 invoked from network); 13 Jan 2022 14:44:27 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 13 Jan 2022 14:44:27 -0000 Received: by lieven-pc (Postfix, from userid 1060) id D642313D99A; Thu, 13 Jan 2022 15:44:27 +0100 (CET) X-Footer: a2FtcC5kZQ== From: Peter Lieven To: qemu-block@nongnu.org Subject: [PATCH V2 for-6.2 1/2] block/rbd: fix handling of holes in .bdrv_co_block_status Date: Thu, 13 Jan 2022 15:44:25 +0100 Message-Id: <20220113144426.4036493-2-pl@kamp.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113144426.4036493-1-pl@kamp.de> References: <20220113144426.4036493-1-pl@kamp.de> 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=195.62.97.192; envelope-from=pl@kamp.de; helo=kerio.kamp.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Cc: kwolf@redhat.com, idryomov@redhat.com, berrange@redhat.com, qemu-stable@nongnu.org, Peter Lieven , qemu-devel@nongnu.org, ct@flyingcircus.io, pbonzini@redhat.com, idryomov@gmail.com, mreitz@redhat.com, dillaman@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1642085231376100001 Content-Type: text/plain; charset="utf-8" the assumption that we can't hit a hole if we do not diff against a snapsho= t was wrong. We can see a hole in an image if we diff against base if there exists an ol= der snapshot of the image and we have discarded blocks in the image where the snapshot h= as data. Fix this by simply handling a hole like an unallocated area. There are no c= allbacks for unallocated areas so just bail out if we hit a hole. Fixes: 0347a8fd4c3faaedf119be04c197804be40a384b Suggested-by: Ilya Dryomov Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Reviewed-by: Ilya Dryomov Reviewed-by: Stefano Garzarella --- block/rbd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index def96292e0..20bb896c4a 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1279,11 +1279,11 @@ static int qemu_rbd_diff_iterate_cb(uint64_t offs, = size_t len, RBDDiffIterateReq *req =3D opaque; =20 assert(req->offs + req->bytes <=3D offs); - /* - * we do not diff against a snapshot so we should never receive a call= back - * for a hole. - */ - assert(exists); + + /* treat a hole like an unallocated area and bail out */ + if (!exists) { + return 0; + } =20 if (!req->exists && offs > req->offs) { /* --=20 2.25.1 From nobody Fri Mar 29 11:15:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642085497803310.96910151405154; Thu, 13 Jan 2022 06:51:37 -0800 (PST) Received: from localhost ([::1]:49316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n81Rw-0007wG-QF for importer@patchew.org; Thu, 13 Jan 2022 09:51:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n81LE-0002z7-Jj for qemu-devel@nongnu.org; Thu, 13 Jan 2022 09:44:40 -0500 Received: from kerio.kamp.de ([195.62.97.192]:47234) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n81LB-0000u4-T6 for qemu-devel@nongnu.org; Thu, 13 Jan 2022 09:44:40 -0500 Received: from submission.kamp.de ([195.62.97.28]) by kerio.kamp.de with ESMTPS (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256 bits)) for qemu-devel@nongnu.org; Thu, 13 Jan 2022 15:44:28 +0100 Received: (qmail 29079 invoked from network); 13 Jan 2022 14:44:27 -0000 Received: from lieven-pc.kamp-intra.net (HELO lieven-pc) (relay@kamp.de@::ffff:172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPA; 13 Jan 2022 14:44:27 -0000 Received: by lieven-pc (Postfix, from userid 1060) id D93BB13D9A0; Thu, 13 Jan 2022 15:44:27 +0100 (CET) X-Footer: a2FtcC5kZQ== From: Peter Lieven To: qemu-block@nongnu.org Subject: [PATCH V2 for-6.2 2/2] block/rbd: workaround for ceph issue #53784 Date: Thu, 13 Jan 2022 15:44:26 +0100 Message-Id: <20220113144426.4036493-3-pl@kamp.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220113144426.4036493-1-pl@kamp.de> References: <20220113144426.4036493-1-pl@kamp.de> 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=195.62.97.192; envelope-from=pl@kamp.de; helo=kerio.kamp.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Cc: kwolf@redhat.com, idryomov@redhat.com, berrange@redhat.com, qemu-stable@nongnu.org, Peter Lieven , qemu-devel@nongnu.org, ct@flyingcircus.io, pbonzini@redhat.com, idryomov@gmail.com, mreitz@redhat.com, dillaman@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1642085499073100001 Content-Type: text/plain; charset="utf-8" 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. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Lieven Reviewed-by: Ilya Dryomov Reviewed-by: Stefano Garzarella Tested-by: Stefano Garzarella --- block/rbd.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 20bb896c4a..d174d51659 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.25.1