aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-09-06 09:28:31 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-09-06 09:28:31 +0100
commit019217c3b34f22b1c14cdf652d87dbf54cdc43a2 (patch)
treeb9778fb763af5f8abe5e52a1a759e0d3beb304c8 /block
parent90b1e3afd33226b6078fec6d77a18373712a975c (diff)
parentb491dbb7f8e09ef864770c205a3b5bce6c5c1881 (diff)
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-09-05-v2' into staging
nbd patches for 2019-09-05 - Advertise NBD_FLAG_CAN_MULTI_CONN on readonly images - Tolerate larger set of server error responses during handshake - More precision on handling fallocate() failures due to alignment - Better documentation of NBD connection URIs - Implement new extension NBD_CMD_FLAG_FAST_ZERO to benefit qemu-img convert # gpg: Signature made Thu 05 Sep 2019 22:08:17 BST # gpg: using RSA key 71C2CC22B1C4602927D2F3AAA7A16B4A2527436A # gpg: Good signature from "Eric Blake <eblake@redhat.com>" [full] # gpg: aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>" [full] # gpg: aka "[jpeg image of size 6874]" [full] # Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2 F3AA A7A1 6B4A 2527 436A * remotes/ericb/tags/pull-nbd-2019-09-05-v2: nbd: Implement server use of NBD FAST_ZERO nbd: Implement client use of NBD FAST_ZERO nbd: Prepare for NBD_CMD_FLAG_FAST_ZERO nbd: Improve per-export flag handling in server docs: Update preferred NBD device syntax block: workaround for unaligned byte range in fallocate() nbd: Tolerate more errors to structured reply request nbd: Use g_autofree in a few places nbd: Advertise multi-conn for shared read-only connections Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block')
-rw-r--r--block/file-posix.c7
-rw-r--r--block/io.c2
-rw-r--r--block/nbd.c18
3 files changed, 19 insertions, 8 deletions
diff --git a/block/file-posix.c b/block/file-posix.c
index 71f168ee2f..87c5a4ccbd 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1588,6 +1588,13 @@ static int handle_aiocb_write_zeroes(void *opaque)
if (s->has_write_zeroes) {
int ret = do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE,
aiocb->aio_offset, aiocb->aio_nbytes);
+ if (ret == -EINVAL) {
+ /*
+ * Allow falling back to pwrite for file systems that
+ * do not support fallocate() for an unaligned byte range.
+ */
+ return -ENOTSUP;
+ }
if (ret == 0 || ret != -ENOTSUP) {
return ret;
}
diff --git a/block/io.c b/block/io.c
index 0fa10831ed..16a598fd08 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1746,7 +1746,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
assert(!bs->supported_zero_flags);
}
- if (ret < 0 && !(flags & BDRV_REQ_NO_FALLBACK)) {
+ if (ret == -ENOTSUP && !(flags & BDRV_REQ_NO_FALLBACK)) {
/* Fall back to bounce buffer if write zeroes is unsupported */
BdrvRequestFlags write_flags = flags & ~BDRV_REQ_ZERO_WRITE;
diff --git a/block/nbd.c b/block/nbd.c
index beed46fb34..813c40d8f0 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1044,6 +1044,10 @@ static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
if (!(flags & BDRV_REQ_MAY_UNMAP)) {
request.flags |= NBD_CMD_FLAG_NO_HOLE;
}
+ if (flags & BDRV_REQ_NO_FALLBACK) {
+ assert(s->info.flags & NBD_FLAG_SEND_FAST_ZERO);
+ request.flags |= NBD_CMD_FLAG_FAST_ZERO;
+ }
if (!bytes) {
return 0;
@@ -1239,6 +1243,9 @@ static int nbd_client_connect(BlockDriverState *bs, Error **errp)
}
if (s->info.flags & NBD_FLAG_SEND_WRITE_ZEROES) {
bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
+ if (s->info.flags & NBD_FLAG_SEND_FAST_ZERO) {
+ bs->supported_zero_flags |= BDRV_REQ_NO_FALLBACK;
+ }
}
s->sioc = sioc;
@@ -1374,7 +1381,7 @@ static bool nbd_has_filename_options_conflict(QDict *options, Error **errp)
static void nbd_parse_filename(const char *filename, QDict *options,
Error **errp)
{
- char *file;
+ g_autofree char *file = NULL;
char *export_name;
const char *host_spec;
const char *unixpath;
@@ -1396,7 +1403,7 @@ static void nbd_parse_filename(const char *filename, QDict *options,
export_name = strstr(file, EN_OPTSTR);
if (export_name) {
if (export_name[strlen(EN_OPTSTR)] == 0) {
- goto out;
+ return;
}
export_name[0] = 0; /* truncate 'file' */
export_name += strlen(EN_OPTSTR);
@@ -1407,11 +1414,11 @@ static void nbd_parse_filename(const char *filename, QDict *options,
/* extract the host_spec - fail if it's not nbd:... */
if (!strstart(file, "nbd:", &host_spec)) {
error_setg(errp, "File name string for NBD must start with 'nbd:'");
- goto out;
+ return;
}
if (!*host_spec) {
- goto out;
+ return;
}
/* are we a UNIX or TCP socket? */
@@ -1431,9 +1438,6 @@ static void nbd_parse_filename(const char *filename, QDict *options,
out_inet:
qapi_free_InetSocketAddress(addr);
}
-
-out:
- g_free(file);
}
static bool nbd_process_legacy_socket_options(QDict *output_options,