|
|
7711c0 |
From 8c49a93129fc9faf8cdb0eb7599f625a2069a0fd Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Date: Fri, 23 Nov 2018 10:41:50 +0100
|
|
|
7711c0 |
Subject: [PATCH 09/34] gluster: Support auto-read-only option
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-id: <20181123104154.13541-9-kwolf@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 83118
|
|
|
7711c0 |
O-Subject: [RHEL-7.7/7.6.z qemu-kvm-rhev PATCH v2 08/12] gluster: Support auto-read-only option
|
|
|
7711c0 |
Bugzilla: 1623986
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
If read-only=off, but auto-read-only=on is given, open the file
|
|
|
7711c0 |
read-write if we have the permissions, but instead of erroring out for
|
|
|
7711c0 |
read-only files, just degrade to read-only.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Niels de Vos <ndevos@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 54ea21bd16202c4a3e43c67b573b5d1aa2ec1c0c)
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block/gluster.c | 12 ++++++++++--
|
|
|
7711c0 |
1 file changed, 10 insertions(+), 2 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block/gluster.c b/block/gluster.c
|
|
|
7711c0 |
index cecfe09..8c13002 100644
|
|
|
7711c0 |
--- a/block/gluster.c
|
|
|
7711c0 |
+++ b/block/gluster.c
|
|
|
7711c0 |
@@ -849,8 +849,16 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
|
|
7711c0 |
qemu_gluster_parse_flags(bdrv_flags, &open_flags);
|
|
|
7711c0 |
|
|
|
7711c0 |
s->fd = glfs_open(s->glfs, gconf->path, open_flags);
|
|
|
7711c0 |
- if (!s->fd) {
|
|
|
7711c0 |
- ret = -errno;
|
|
|
7711c0 |
+ ret = s->fd ? 0 : -errno;
|
|
|
7711c0 |
+
|
|
|
7711c0 |
+ if (ret == -EACCES || ret == -EROFS) {
|
|
|
7711c0 |
+ /* Try to degrade to read-only, but if it doesn't work, still use the
|
|
|
7711c0 |
+ * normal error message. */
|
|
|
7711c0 |
+ if (bdrv_apply_auto_read_only(bs, NULL, NULL) == 0) {
|
|
|
7711c0 |
+ open_flags = (open_flags & ~O_RDWR) | O_RDONLY;
|
|
|
7711c0 |
+ s->fd = glfs_open(s->glfs, gconf->path, open_flags);
|
|
|
7711c0 |
+ ret = s->fd ? 0 : -errno;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
}
|
|
|
7711c0 |
|
|
|
7711c0 |
s->supports_seek_data = qemu_gluster_test_seek(s->fd);
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|