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

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