From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkuGI-0000Ho-Qb for qemu-devel@nongnu.org; Wed, 22 Apr 2015 09:00:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkuGD-00033N-2U for qemu-devel@nongnu.org; Wed, 22 Apr 2015 09:00:18 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:38566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkuGC-00033F-RE for qemu-devel@nongnu.org; Wed, 22 Apr 2015 09:00:13 -0400 Received: by wiun10 with SMTP id n10so56286285wiu.1 for ; Wed, 22 Apr 2015 06:00:12 -0700 (PDT) Date: Wed, 22 Apr 2015 14:00:09 +0100 From: Stefan Hajnoczi Message-ID: <20150422130009.GH27617@stefanha-thinkpad.redhat.com> References: <1426069701-1405-1-git-send-email-den@openvz.org> <1426069701-1405-9-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dMyqICaxQaaUjrCL" Content-Disposition: inline In-Reply-To: <1426069701-1405-9-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 08/27] block/parallels: _co_writev callback for Parallels format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi --dMyqICaxQaaUjrCL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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; > +} --dMyqICaxQaaUjrCL Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJVN5tZAAoJEJykq7OBq3PI+38H/3ieIDJUipUvJDmtz3butwC+ HJHgt07xFzEckYacgoRFZVE0JompouYTYch3OBMditFTZlGrkg4p7VaLgqM+XHgG cVIEGb572xuc+ZEpWFSJo2127UZmas9PS68Chg/6/FK63qGk7wPYTF19izxDlv0o ImyarcqYWFqWEa1UvTjGpMIUjnR5bJNaIR5FRYjJA+WN9h/grwHi/vktx+ihqcOk YgYRbPNy2Va7Fe9pdk3bwJL1mDCphy9H6qMCt0ROuQkWERdumW9CbQTGhooYmnyy MbykZXPUFLDxLLa3GRFtjhlcxjH91yyPas8z/EcEmuOujAzx+7J1gNYoPHq52fk= =EMfJ -----END PGP SIGNATURE----- --dMyqICaxQaaUjrCL--