qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 08/27] block/parallels: _co_writev callback for


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 08/27] block/parallels: _co_writev callback for Parallels format
Date: Wed, 22 Apr 2015 14:00:09 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Wed, Mar 11, 2015 at 01:28:02PM +0300, Denis V. Lunev wrote:
> +static coroutine_fn int parallels_co_writev(BlockDriverState *bs,
> +        int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
> +{
> +    BDRVParallelsState *s = bs->opaque;
> +    uint64_t bytes_done = 0;
> +    QEMUIOVector hd_qiov;
> +    int ret = 0;
> +
> +    qemu_iovec_init(&hd_qiov, qiov->niov);
> +
> +    qemu_co_mutex_lock(&s->lock);
> +    while (nb_sectors > 0) {
> +        int64_t position = allocate_cluster(bs, sector_num);
> +        int n = cluster_remainder(s, sector_num, nb_sectors);
> +        int nbytes = n << BDRV_SECTOR_BITS;
> +
> +        if (position < 0) {
> +            ret = (int)position;
> +            break;
> +        }
> +
> +        qemu_iovec_reset(&hd_qiov);
> +        qemu_iovec_concat(&hd_qiov, qiov, bytes_done, nbytes);
> +
> +        qemu_co_mutex_unlock(&s->lock);
> +        ret = bdrv_co_writev(bs->file, position, n, &hd_qiov);
> +        qemu_co_mutex_lock(&s->lock);
> +
> +        if (ret < 0) {
> +            goto fail;

Missing unlock if goto is taken.  I'd suggest dropping the 'fail' label
and using break.

> +        }
> +
> +        nb_sectors -= n;
> +        sector_num += n;
> +        bytes_done += nbytes;
> +    }
> +    qemu_co_mutex_unlock(&s->lock);
> +
> +fail:
> +    qemu_iovec_destroy(&hd_qiov);
> +    return ret;
> +}

Attachment: pgp1IgmdugoOj.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]