On Fri, Oct 11, 2013 at 02:17:31PM -0400, Jeff Cody wrote:
> +            case PAYLOAD_BLOCK_FULLY_PRESENT:
> +                /* if the file offset address is in the header zone,
> +                 * there is a problem */
> +                if (sinfo.file_offset < (1024 * 1024)) {

When a block is allocated we update s->bat[] and changed the file size.
This should be undone so that in-memory and on-disk metadata doesn't get
out of sync.

> +                    ret = -EFAULT;
> +                    goto exit;
> +                }
> +
> +                if (!use_zero_buffers) {
> +                    qemu_iovec_concat(&hd_qiov, qiov,  bytes_done,
> +                                      sinfo.bytes_avail);
> +                }
> +                /* block exists, so we can just overwrite it */
> +                qemu_co_mutex_unlock(&s->lock);
> +                ret = bdrv_co_writev(bs->file,
> +                                    sinfo.file_offset >> BDRV_SECTOR_BITS,
> +                                    sectors_to_write, &hd_qiov);
> +                qemu_co_mutex_lock(&s->lock);
> +                if (ret < 0) {
> +                    goto exit;

Same comment about in-memory and on-disk metadata getting out of sync in
the error case.

> +exit:
> +    qemu_vfree(iov1.iov_base);
> +    qemu_vfree(iov2.iov_base);
> +    qemu_co_mutex_unlock(&s->lock);
> +    return ret;

Missing qemu_iovec_destroy(&hd_qiov).

Reply via email to