yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

Pablo Greco e6a3ae
From 87240c5fcfb3e3ba68c5c87d2175f2dd98921a7e Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Date: Wed, 3 Apr 2019 17:13:15 +0100
Pablo Greco e6a3ae
Subject: [PATCH 08/11] block/file-posix: do not fail on unlock bytes
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190403171315.20841-9-mreitz@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 85406
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1 qemu-kvm PATCH 8/8] block/file-posix: do not fail on unlock bytes
Pablo Greco e6a3ae
Bugzilla: 1694148
Pablo Greco e6a3ae
RH-Acked-by: John Snow <jsnow@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
bdrv_replace_child() calls bdrv_check_perm() with error_abort on
Pablo Greco e6a3ae
loosening permissions. However file-locking operations may fail even
Pablo Greco e6a3ae
in this case, for example on NFS. And this leads to Qemu crash.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Let's avoid such errors. Note, that we ignore such things anyway on
Pablo Greco e6a3ae
permission update commit and abort.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Pablo Greco e6a3ae
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 696aaaed579ac5bf5fa336216909b46d3d8f07a8)
Pablo Greco e6a3ae
Signed-off-by: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 block/file-posix.c | 12 ++++++++++++
Pablo Greco e6a3ae
 1 file changed, 12 insertions(+)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/block/file-posix.c b/block/file-posix.c
Pablo Greco e6a3ae
index deecf58..5fb5a9a 100644
Pablo Greco e6a3ae
--- a/block/file-posix.c
Pablo Greco e6a3ae
+++ b/block/file-posix.c
Pablo Greco e6a3ae
@@ -800,6 +800,18 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
     switch (op) {
Pablo Greco e6a3ae
     case RAW_PL_PREPARE:
Pablo Greco e6a3ae
+        if ((s->perm | new_perm) == s->perm &&
Pablo Greco e6a3ae
+            (s->shared_perm & new_shared) == s->shared_perm)
Pablo Greco e6a3ae
+        {
Pablo Greco e6a3ae
+            /*
Pablo Greco e6a3ae
+             * We are going to unlock bytes, it should not fail. If it fail due
Pablo Greco e6a3ae
+             * to some fs-dependent permission-unrelated reasons (which occurs
Pablo Greco e6a3ae
+             * sometimes on NFS and leads to abort in bdrv_replace_child) we
Pablo Greco e6a3ae
+             * can't prevent such errors by any check here. And we ignore them
Pablo Greco e6a3ae
+             * anyway in ABORT and COMMIT.
Pablo Greco e6a3ae
+             */
Pablo Greco e6a3ae
+            return 0;
Pablo Greco e6a3ae
+        }
Pablo Greco e6a3ae
         ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
Pablo Greco e6a3ae
                                    ~s->shared_perm | ~new_shared,
Pablo Greco e6a3ae
                                    false, errp);
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae