Commit 9a363f0b authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging



Block layer patches:

- file-posix: Ignore unlock failure instead of crashing
- gluster: Limit the transfer size to 512 MiB
- stream: Fix backing chain freezing
- qemu-img: Enable BDRV_REQ_MAY_UNMAP for zero writes in convert
- iotests fixes

# gpg: Signature made Tue 02 Apr 2019 13:47:43 BST
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  tests/qemu-iotests/235: Allow fallback to tcg
  block: test block-stream with a base node that is used by block-commit
  block: freeze the backing chain earlier in stream_start()
  block: continue until base is found in bdrv_freeze_backing_chain() et al
  block/file-posix: do not fail on unlock bytes
  tests/qemu-iotests: Remove redundant COPYING file
  block/gluster: limit the transfer size to 512 MiB
  qemu-img: Enable BDRV_REQ_MAY_UNMAP in convert
  iotests: Fix test 200 on s390x without virtio-pci

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents d61d1a1f f18957b8
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -4218,14 +4218,15 @@ BlockDriverState *bdrv_find_base(BlockDriverState *bs)
/*
 * Return true if at least one of the backing links between @bs and
 * @base is frozen. @errp is set if that's the case.
 * @base must be reachable from @bs, or NULL.
 */
bool bdrv_is_backing_chain_frozen(BlockDriverState *bs, BlockDriverState *base,
                                  Error **errp)
{
    BlockDriverState *i;

    for (i = bs; i != base && i->backing; i = backing_bs(i)) {
        if (i->backing->frozen) {
    for (i = bs; i != base; i = backing_bs(i)) {
        if (i->backing && i->backing->frozen) {
            error_setg(errp, "Cannot change '%s' link from '%s' to '%s'",
                       i->backing->name, i->node_name,
                       backing_bs(i)->node_name);
@@ -4240,6 +4241,7 @@ bool bdrv_is_backing_chain_frozen(BlockDriverState *bs, BlockDriverState *base,
 * Freeze all backing links between @bs and @base.
 * If any of the links is already frozen the operation is aborted and
 * none of the links are modified.
 * @base must be reachable from @bs, or NULL.
 * Returns 0 on success. On failure returns < 0 and sets @errp.
 */
int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base,
@@ -4251,9 +4253,11 @@ int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base,
        return -EPERM;
    }

    for (i = bs; i != base && i->backing; i = backing_bs(i)) {
    for (i = bs; i != base; i = backing_bs(i)) {
        if (i->backing) {
            i->backing->frozen = true;
        }
    }

    return 0;
}
@@ -4261,16 +4265,19 @@ int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base,
/*
 * Unfreeze all backing links between @bs and @base. The caller must
 * ensure that all links are frozen before using this function.
 * @base must be reachable from @bs, or NULL.
 */
void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *base)
{
    BlockDriverState *i;

    for (i = bs; i != base && i->backing; i = backing_bs(i)) {
    for (i = bs; i != base; i = backing_bs(i)) {
        if (i->backing) {
            assert(i->backing->frozen);
            i->backing->frozen = false;
        }
    }
}

/*
 * Drops images above 'base' up to and including 'top', and sets the image
+12 −0
Original line number Diff line number Diff line
@@ -815,6 +815,18 @@ 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 it fail due
             * to some fs-dependent permission-unrelated reasons (which occurs
             * sometimes on NFS and leads to abort in bdrv_replace_child) we
             * can't prevent such errors by any check here. And we ignore them
             * anyway in ABORT and COMMIT.
             */
            return 0;
        }
        ret = raw_apply_lock_bytes(s, s->fd, s->perm | new_perm,
                                   ~s->shared_perm | ~new_shared,
                                   false, errp);
+16 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
 */

#include "qemu/osdep.h"
#include "qemu/units.h"
#include <glusterfs/api/glfs.h>
#include "block/block_int.h"
#include "block/qdict.h"
@@ -41,6 +42,12 @@
#define GLUSTER_DEBUG_MAX           9
#define GLUSTER_OPT_LOGFILE         "logfile"
#define GLUSTER_LOGFILE_DEFAULT     "-" /* handled in libgfapi as /dev/stderr */
/*
 * Several versions of GlusterFS (3.12? -> 6.0.1) fail when the transfer size
 * is greater or equal to 1024 MiB, so we are limiting the transfer size to 512
 * MiB to avoid this rare issue.
 */
#define GLUSTER_MAX_TRANSFER        (512 * MiB)

#define GERR_INDEX_HINT "hint: check in 'server' array index '%d'\n"

@@ -887,6 +894,11 @@ out:
    return ret;
}

static void qemu_gluster_refresh_limits(BlockDriverState *bs, Error **errp)
{
    bs->bl.max_transfer = GLUSTER_MAX_TRANSFER;
}

static int qemu_gluster_reopen_prepare(BDRVReopenState *state,
                                       BlockReopenQueue *queue, Error **errp)
{
@@ -1544,6 +1556,7 @@ static BlockDriver bdrv_gluster = {
    .bdrv_co_pwrite_zeroes        = qemu_gluster_co_pwrite_zeroes,
#endif
    .bdrv_co_block_status         = qemu_gluster_co_block_status,
    .bdrv_refresh_limits          = qemu_gluster_refresh_limits,
    .create_opts                  = &qemu_gluster_create_opts,
    .strong_runtime_opts          = gluster_strong_open_opts,
};
@@ -1574,6 +1587,7 @@ static BlockDriver bdrv_gluster_tcp = {
    .bdrv_co_pwrite_zeroes        = qemu_gluster_co_pwrite_zeroes,
#endif
    .bdrv_co_block_status         = qemu_gluster_co_block_status,
    .bdrv_refresh_limits          = qemu_gluster_refresh_limits,
    .create_opts                  = &qemu_gluster_create_opts,
    .strong_runtime_opts          = gluster_strong_open_opts,
};
@@ -1604,6 +1618,7 @@ static BlockDriver bdrv_gluster_unix = {
    .bdrv_co_pwrite_zeroes        = qemu_gluster_co_pwrite_zeroes,
#endif
    .bdrv_co_block_status         = qemu_gluster_co_block_status,
    .bdrv_refresh_limits          = qemu_gluster_refresh_limits,
    .create_opts                  = &qemu_gluster_create_opts,
    .strong_runtime_opts          = gluster_strong_open_opts,
};
@@ -1640,6 +1655,7 @@ static BlockDriver bdrv_gluster_rdma = {
    .bdrv_co_pwrite_zeroes        = qemu_gluster_co_pwrite_zeroes,
#endif
    .bdrv_co_block_status         = qemu_gluster_co_block_status,
    .bdrv_refresh_limits          = qemu_gluster_refresh_limits,
    .create_opts                  = &qemu_gluster_create_opts,
    .strong_runtime_opts          = gluster_strong_open_opts,
};
+7 −6
Original line number Diff line number Diff line
@@ -238,11 +238,16 @@ void stream_start(const char *job_id, BlockDriverState *bs,
    BlockDriverState *iter;
    bool bs_read_only;

    if (bdrv_freeze_backing_chain(bs, base, errp) < 0) {
        return;
    }

    /* Make sure that the image is opened in read-write mode */
    bs_read_only = bdrv_is_read_only(bs);
    if (bs_read_only) {
        if (bdrv_reopen_set_read_only(bs, false, errp) != 0) {
            return;
            bs_read_only = false;
            goto fail;
        }
    }

@@ -269,11 +274,6 @@ void stream_start(const char *job_id, BlockDriverState *bs,
                           &error_abort);
    }

    if (bdrv_freeze_backing_chain(bs, base, errp) < 0) {
        job_early_fail(&s->common.job);
        goto fail;
    }

    s->base = base;
    s->backing_file_str = g_strdup(backing_file_str);
    s->bs_read_only = bs_read_only;
@@ -288,4 +288,5 @@ fail:
    if (bs_read_only) {
        bdrv_reopen_set_read_only(bs, true, NULL);
    }
    bdrv_unfreeze_backing_chain(bs, base);
}
+2 −1
Original line number Diff line number Diff line
@@ -1756,7 +1756,8 @@ static int coroutine_fn convert_co_write(ImgConvertState *s, int64_t sector_num,
            }
            ret = blk_co_pwrite_zeroes(s->target,
                                       sector_num << BDRV_SECTOR_BITS,
                                       n << BDRV_SECTOR_BITS, 0);
                                       n << BDRV_SECTOR_BITS,
                                       BDRV_REQ_MAY_UNMAP);
            if (ret < 0) {
                return ret;
            }
Loading