From nobody Tue May 7 20:27:43 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 1553857621779746.4261855134679; Fri, 29 Mar 2019 04:07:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:50776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9pLd-0000oS-5b for importer@patchew.org; Fri, 29 Mar 2019 07:06:57 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9pJt-0008K8-Rl for qemu-devel@nongnu.org; Fri, 29 Mar 2019 07:05:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9pJi-0002OS-DK for qemu-devel@nongnu.org; Fri, 29 Mar 2019 07:05:09 -0400 Received: from relay.sw.ru ([185.231.240.75]:46036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h9pJi-0002Br-3a; Fri, 29 Mar 2019 07:04:58 -0400 Received: from [10.28.8.145] (helo=kvm.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h9pJe-0004ao-2i; Fri, 29 Mar 2019 14:04:54 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Fri, 29 Mar 2019 14:04:54 +0300 Message-Id: <20190329110454.82409-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 v3] block/file-posix: do not 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: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, jsnow@redhat.com, mreitz@redhat.com, den@openvz.org 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 avoid such errors. Note, that we ignore such things anyway on permission update commit and abort. Signed-off-by: Vladimir Sementsov-Ogievskiy --- block/file-posix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block/file-posix.c b/block/file-posix.c index db4cccbe51..1cf4ee49eb 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -815,6 +815,18 @@ 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 it fai= l due + * to some fs-dependent permission-unrelated reasons (which oc= curs + * sometimes on NFS and leads to abort in bdrv_replace_child) = we + * can't prevent such errors by any check here. And we ignore = them + * anyway in ABORT and COMMIT. + */ + 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