qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH v2] block/file-posix: ignore fail on unlock bytes


From: Vladimir Sementsov-Ogievskiy
Subject: [Qemu-block] [PATCH v2] block/file-posix: ignore fail on unlock bytes
Date: Thu, 28 Mar 2019 10:21:39 +0300

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 <address@hidden>
---

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,
 
     switch (op) {
     case RAW_PL_PREPARE:
+        if ((s->perm | new_perm) == s->perm &&
+            (s->shared_perm & new_shared) == 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 = raw_check_lock_bytes(s->fd, new_perm, new_shared, 
&local_err);
+            if (local_err) {
+                error_report_err(local_err);
+            }
+            return 0;
+        }
         ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
                                    ~s->shared_perm | ~new_shared,
                                    false, errp);
-- 
2.18.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]