From nobody Tue May 7 05:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553757788055305.5548103174267; Thu, 28 Mar 2019 00:23:08 -0700 (PDT) Received: from localhost ([127.0.0.1]:60541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9PNE-00070Y-Vq for importer@patchew.org; Thu, 28 Mar 2019 03:22:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9PME-0006eq-EK for qemu-devel@nongnu.org; Thu, 28 Mar 2019 03:21:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9PMC-0001gt-7b for qemu-devel@nongnu.org; Thu, 28 Mar 2019 03:21:50 -0400 Received: from relay.sw.ru ([185.231.240.75]:43020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9PMA-0001fv-33; Thu, 28 Mar 2019 03:21:46 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h9PM4-0004ca-Cx; Thu, 28 Mar 2019 10:21:40 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 28 Mar 2019 10:21:39 +0300 Message-Id: <20190328072139.14064-1-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2] block/file-posix: ignore fail on unlock bytes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, kwolf@redhat.com, vsementsov@virtuozzo.com, mreitz@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" bdrv_replace_child() calls bdrv_check_perm() with error_abort on loosening permissions. However file-locking operations may fail even in this case, for example on NFS. And this leads to Qemu crash. Let's ignore such errors, as we do already on permission update commit and abort. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- v2: - simplify expression [Eric] - fix bug s/new_perm/new_shared block/file-posix.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index db4cccbe51..736b4851e3 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -815,6 +815,20 @@ static int raw_handle_perm_lock(BlockDriverState *bs, =20 switch (op) { case RAW_PL_PREPARE: + if ((s->perm | new_perm) =3D=3D s->perm && + (s->shared_perm & new_shared) =3D=3D s->shared_perm) + { + /* + * We are going to unlock bytes, it should not fail. If fail, + * just report it and ignore, like we do for ABORT and COMMIT + * anyway. + */ + ret =3D raw_check_lock_bytes(s->fd, new_perm, new_shared, &loc= al_err); + if (local_err) { + error_report_err(local_err); + } + return 0; + } ret =3D raw_apply_lock_bytes(s, s->fd, s->perm | new_perm, ~s->shared_perm | ~new_shared, false, errp); --=20 2.18.0