Commit 5fc0fe38 authored by Kevin Wolf's avatar Kevin Wolf
Browse files

Merge remote-tracking branch 'mreitz/tags/pull-block-2017-04-28' into queue-block



Block patches for the block queue

# gpg: Signature made Fri Apr 28 20:50:48 2017 CEST
# gpg:                using RSA key 0xF407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* mreitz/tags/pull-block-2017-04-28:
  progress: Show current progress on SIGINFO
  iotests: fix exclusion option
  iotests: clarify help text
  qemu-img: use blk_co_pwrite_zeroes for zero sectors when compressed
  qemu-img: improve convert_iteration_sectors()
  block: assert no image modification under BDRV_O_INACTIVE
  block: fix obvious coding style mistakes in block_int.h
  qcow2: Allow discard of final unaligned cluster
  block: Add .bdrv_truncate() error messages
  block: Add errp to BD.bdrv_truncate()
  block: Add errp to b{lk,drv}_truncate()
  block/vhdx: Make vhdx_create() always set errp

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parents 2b4c0a20 262fbae6
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -3307,7 +3307,7 @@ exit:
/**
 * Truncate file to 'offset' bytes (needed only for file protocols)
 */
int bdrv_truncate(BdrvChild *child, int64_t offset)
int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp)
{
    BlockDriverState *bs = child->bs;
    BlockDriver *drv = bs->drv;
@@ -3315,14 +3315,22 @@ int bdrv_truncate(BdrvChild *child, int64_t offset)

    assert(child->perm & BLK_PERM_RESIZE);

    if (!drv)
    if (!drv) {
        error_setg(errp, "No medium inserted");
        return -ENOMEDIUM;
    if (!drv->bdrv_truncate)
    }
    if (!drv->bdrv_truncate) {
        error_setg(errp, "Image format driver does not support resize");
        return -ENOTSUP;
    if (bs->read_only)
    }
    if (bs->read_only) {
        error_setg(errp, "Image is read-only");
        return -EACCES;
    }

    assert(!(bs->open_flags & BDRV_O_INACTIVE));

    ret = drv->bdrv_truncate(bs, offset);
    ret = drv->bdrv_truncate(bs, offset, errp);
    if (ret == 0) {
        ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
        bdrv_dirty_bitmap_truncate(bs);
+2 −2
Original line number Diff line number Diff line
@@ -659,9 +659,9 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
    return bdrv_getlength(bs->file->bs);
}

static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
static int blkdebug_truncate(BlockDriverState *bs, int64_t offset, Error **errp)
{
    return bdrv_truncate(bs->file, offset);
    return bdrv_truncate(bs->file, offset, errp);
}

static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options)
+3 −2
Original line number Diff line number Diff line
@@ -1746,13 +1746,14 @@ int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf,
                   BDRV_REQ_WRITE_COMPRESSED);
}

int blk_truncate(BlockBackend *blk, int64_t offset)
int blk_truncate(BlockBackend *blk, int64_t offset, Error **errp)
{
    if (!blk_is_available(blk)) {
        error_setg(errp, "No medium inserted");
        return -ENOMEDIUM;
    }

    return bdrv_truncate(blk->root, offset);
    return bdrv_truncate(blk->root, offset, errp);
}

static void blk_pdiscard_entry(void *opaque)
+3 −2
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static void coroutine_fn commit_run(void *opaque)
    }

    if (base_len < s->common.len) {
        ret = blk_truncate(s->base, s->common.len);
        ret = blk_truncate(s->base, s->common.len, NULL);
        if (ret) {
            goto out;
        }
@@ -511,8 +511,9 @@ int bdrv_commit(BlockDriverState *bs)
     * grow the backing file image if possible.  If not possible,
     * we must return an error */
    if (length > backing_length) {
        ret = blk_truncate(backing, length);
        ret = blk_truncate(backing, length, &local_err);
        if (ret < 0) {
            error_report_err(local_err);
            goto ro_cleanup;
        }
    }
+3 −2
Original line number Diff line number Diff line
@@ -381,7 +381,8 @@ static int block_crypto_create_generic(QCryptoBlockFormat format,
    return ret;
}

static int block_crypto_truncate(BlockDriverState *bs, int64_t offset)
static int block_crypto_truncate(BlockDriverState *bs, int64_t offset,
                                 Error **errp)
{
    BlockCrypto *crypto = bs->opaque;
    size_t payload_offset =
@@ -389,7 +390,7 @@ static int block_crypto_truncate(BlockDriverState *bs, int64_t offset)

    offset += payload_offset;

    return bdrv_truncate(bs->file, offset);
    return bdrv_truncate(bs->file, offset, errp);
}

static void block_crypto_close(BlockDriverState *bs)
Loading