|
|
7711c0 |
From 02778d4e42af5fa6c9dd985bee2ae04b2646bbcd Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Date: Fri, 23 Nov 2018 10:41:47 +0100
|
|
|
7711c0 |
Subject: [PATCH 06/34] nbd: Support auto-read-only option
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Message-id: <20181123104154.13541-6-kwolf@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 83121
|
|
|
7711c0 |
O-Subject: [RHEL-7.7/7.6.z qemu-kvm-rhev PATCH v2 05/12] nbd: 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 a read-write NBD
|
|
|
7711c0 |
connection if the server provides a read-write export, but instead of
|
|
|
7711c0 |
erroring out for read-only exports, just degrade to read-only.
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 6c2e581d4d7751f035e9bac0384703879c8a1538)
|
|
|
7711c0 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
block/nbd-client.c | 10 +++++-----
|
|
|
7711c0 |
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/block/nbd-client.c b/block/nbd-client.c
|
|
|
7711c0 |
index 98637c0..80d3625 100644
|
|
|
7711c0 |
--- a/block/nbd-client.c
|
|
|
7711c0 |
+++ b/block/nbd-client.c
|
|
|
7711c0 |
@@ -988,11 +988,11 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
7711c0 |
logout("Failed to negotiate with the NBD server\n");
|
|
|
7711c0 |
return ret;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
- if (client->info.flags & NBD_FLAG_READ_ONLY &&
|
|
|
7711c0 |
- !bdrv_is_read_only(bs)) {
|
|
|
7711c0 |
- error_setg(errp,
|
|
|
7711c0 |
- "request for write access conflicts with read-only export");
|
|
|
7711c0 |
- return -EACCES;
|
|
|
7711c0 |
+ if (client->info.flags & NBD_FLAG_READ_ONLY) {
|
|
|
7711c0 |
+ ret = bdrv_apply_auto_read_only(bs, "NBD export is read-only", errp);
|
|
|
7711c0 |
+ if (ret < 0) {
|
|
|
7711c0 |
+ return ret;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
}
|
|
|
7711c0 |
if (client->info.flags & NBD_FLAG_SEND_FUA) {
|
|
|
7711c0 |
bs->supported_write_flags = BDRV_REQ_FUA;
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|