Commit 019bb9ac authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-02-09' into staging



nbd patches for 2018-02-09

- Vladimir Sementsov-Ogievskiy: iotests: 205: support luks format
- Eric Blake: block: Simplify bdrv_can_write_zeroes_with_unmap()

# gpg: Signature made Fri 09 Feb 2018 18:34:20 GMT
# gpg:                using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <eblake@redhat.com>"
# gpg:                 aka "Eric Blake (Free Software Programmer) <ebb9@byu.net>"
# gpg:                 aka "[jpeg image of size 6874]"
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2018-02-09:
  block: Simplify bdrv_can_write_zeroes_with_unmap()
  iotests: 205: support luks format

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents c7b02d7d e24d813b
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -4010,17 +4010,11 @@ bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)

bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
{
    BlockDriverInfo bdi;

    if (!(bs->open_flags & BDRV_O_UNMAP)) {
        return false;
    }

    if (bdrv_get_info(bs, &bdi) == 0) {
        return bdi.can_write_zeroes_with_unmap;
    }

    return false;
    return bs->supported_zero_flags & BDRV_REQ_MAY_UNMAP;
}

const char *bdrv_get_encrypted_filename(BlockDriverState *bs)
+0 −1
Original line number Diff line number Diff line
@@ -576,7 +576,6 @@ static int block_crypto_get_info_luks(BlockDriverState *bs,
    }

    bdi->unallocated_blocks_are_zero = false;
    bdi->can_write_zeroes_with_unmap = false;
    bdi->cluster_size = subbdi.cluster_size;

    return 0;
+1 −2
Original line number Diff line number Diff line
@@ -549,7 +549,6 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,

    s->has_discard = true;
    s->has_write_zeroes = true;
    bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
    if ((bs->open_flags & BDRV_O_NOCACHE) != 0) {
        s->needs_alignment = true;
    }
@@ -599,6 +598,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
    }
#endif

    bs->supported_zero_flags = s->discard_zeroes ? BDRV_REQ_MAY_UNMAP : 0;
    ret = 0;
fail:
    if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) {
@@ -2223,7 +2223,6 @@ static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
    BDRVRawState *s = bs->opaque;

    bdi->unallocated_blocks_are_zero = s->discard_zeroes;
    bdi->can_write_zeroes_with_unmap = s->discard_zeroes;
    return 0;
}

+4 −2
Original line number Diff line number Diff line
@@ -1877,7 +1877,6 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
    if (iscsilun->dpofua) {
        bs->supported_write_flags = BDRV_REQ_FUA;
    }
    bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;

    /* Check the write protect flag of the LUN if we want to write */
    if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) &&
@@ -1961,6 +1960,10 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags,
        }
    }

    if (iscsilun->lbprz && iscsilun->lbp.lbpws) {
        bs->supported_zero_flags = BDRV_REQ_MAY_UNMAP;
    }

out:
    qemu_opts_del(opts);
    g_free(initiator_name);
@@ -2160,7 +2163,6 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
    IscsiLun *iscsilun = bs->opaque;
    bdi->unallocated_blocks_are_zero = iscsilun->lbprz;
    bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws;
    bdi->cluster_size = iscsilun->cluster_sectors * BDRV_SECTOR_SIZE;
    return 0;
}
+0 −11
Original line number Diff line number Diff line
@@ -566,14 +566,6 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options)
    bs->full_open_options = opts;
}

static int nbd_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
    if (bs->supported_zero_flags & BDRV_REQ_MAY_UNMAP) {
        bdi->can_write_zeroes_with_unmap = true;
    }
    return 0;
}

static BlockDriver bdrv_nbd = {
    .format_name                = "nbd",
    .protocol_name              = "nbd",
@@ -591,7 +583,6 @@ static BlockDriver bdrv_nbd = {
    .bdrv_detach_aio_context    = nbd_detach_aio_context,
    .bdrv_attach_aio_context    = nbd_attach_aio_context,
    .bdrv_refresh_filename      = nbd_refresh_filename,
    .bdrv_get_info              = nbd_get_info,
};

static BlockDriver bdrv_nbd_tcp = {
@@ -611,7 +602,6 @@ static BlockDriver bdrv_nbd_tcp = {
    .bdrv_detach_aio_context    = nbd_detach_aio_context,
    .bdrv_attach_aio_context    = nbd_attach_aio_context,
    .bdrv_refresh_filename      = nbd_refresh_filename,
    .bdrv_get_info              = nbd_get_info,
};

static BlockDriver bdrv_nbd_unix = {
@@ -631,7 +621,6 @@ static BlockDriver bdrv_nbd_unix = {
    .bdrv_detach_aio_context    = nbd_detach_aio_context,
    .bdrv_attach_aio_context    = nbd_attach_aio_context,
    .bdrv_refresh_filename      = nbd_refresh_filename,
    .bdrv_get_info              = nbd_get_info,
};

static void bdrv_nbd_init(void)
Loading