Blame SOURCES/kvm-block-file-posix-do-not-fail-on-unlock-bytes.patch

7711c0
From 82d4a912b8b197d9d2f56ffc54ca89c535a0f47c Mon Sep 17 00:00:00 2001
7711c0
From: Max Reitz <mreitz@redhat.com>
7711c0
Date: Wed, 3 Apr 2019 18:43:30 +0200
7711c0
Subject: [PATCH 153/163] block/file-posix: do not fail on unlock bytes
7711c0
7711c0
RH-Author: Max Reitz <mreitz@redhat.com>
7711c0
Message-id: <20190403184330.1210-2-mreitz@redhat.com>
7711c0
Patchwork-id: 85432
7711c0
O-Subject: [RHV-7.7 qemu-kvm-rhev PATCH 1/1] block/file-posix: do not fail on unlock bytes
7711c0
Bugzilla: 1603104
7711c0
RH-Acked-by: John Snow <jsnow@redhat.com>
7711c0
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
7711c0
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
7711c0
bdrv_replace_child() calls bdrv_check_perm() with error_abort on
7711c0
loosening permissions. However file-locking operations may fail even
7711c0
in this case, for example on NFS. And this leads to Qemu crash.
7711c0
7711c0
Let's avoid such errors. Note, that we ignore such things anyway on
7711c0
permission update commit and abort.
7711c0
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
(cherry picked from commit 696aaaed579ac5bf5fa336216909b46d3d8f07a8)
7711c0
Signed-off-by: Max Reitz <mreitz@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/file-posix.c | 12 ++++++++++++
7711c0
 1 file changed, 12 insertions(+)
7711c0
7711c0
diff --git a/block/file-posix.c b/block/file-posix.c
7711c0
index 0cf7261..518f16b 100644
7711c0
--- a/block/file-posix.c
7711c0
+++ b/block/file-posix.c
7711c0
@@ -795,6 +795,18 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
7711c0
 
7711c0
     switch (op) {
7711c0
     case RAW_PL_PREPARE:
7711c0
+        if ((s->perm | new_perm) == s->perm &&
7711c0
+            (s->shared_perm & new_shared) == s->shared_perm)
7711c0
+        {
7711c0
+            /*
7711c0
+             * We are going to unlock bytes, it should not fail. If it fail due
7711c0
+             * to some fs-dependent permission-unrelated reasons (which occurs
7711c0
+             * sometimes on NFS and leads to abort in bdrv_replace_child) we
7711c0
+             * can't prevent such errors by any check here. And we ignore them
7711c0
+             * anyway in ABORT and COMMIT.
7711c0
+             */
7711c0
+            return 0;
7711c0
+        }
7711c0
         ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
7711c0
                                    ~s->shared_perm | ~new_shared,
7711c0
                                    false, errp);
7711c0
-- 
7711c0
1.8.3.1
7711c0