From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6M0M-0002qX-7r for qemu-devel@nongnu.org; Fri, 27 May 2016 13:57:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6M0C-0000YG-9N for qemu-devel@nongnu.org; Fri, 27 May 2016 13:57:01 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:35854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6M0C-0000YC-2P for qemu-devel@nongnu.org; Fri, 27 May 2016 13:56:52 -0400 Received: by mail-pf0-x244.google.com with SMTP id 62so1212383pfd.3 for ; Fri, 27 May 2016 10:56:51 -0700 (PDT) Date: Fri, 27 May 2016 10:45:39 -0700 From: Stefan Hajnoczi Message-ID: <20160527174539.GH27946@stefanha-x1.localdomain> References: <1463229957-14253-1-git-send-email-den@openvz.org> <1463229957-14253-5-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="zq44+AAfm4giZpo5" Content-Disposition: inline In-Reply-To: <1463229957-14253-5-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 04/10] qcow: add qcow_co_write_compressed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Kevin Wolf , Pavel Butsykin , Jeff Cody , Markus Armbruster , Stefan Hajnoczi , John Snow --zq44+AAfm4giZpo5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, May 14, 2016 at 03:45:52PM +0300, Denis V. Lunev wrote: > + qemu_co_mutex_lock(&s->lock); > + cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, out_len, 0, 0); > + qemu_co_mutex_unlock(&s->lock); > + if (cluster_offset == 0) { > + ret = -EIO; > + goto fail; > + } > + cluster_offset &= s->cluster_offset_mask; > + > + iov = (struct iovec) { > + .iov_base = out_buf, > + .iov_len = out_len, > + }; > + qemu_iovec_init_external(&hd_qiov, &iov, 1); > + ret = bdrv_co_pwritev(bs->file->bs, cluster_offset, out_len, &hd_qiov, 0); Not sure if this has the same race condition as the qcow2 patch. It seems that bdrv_getlength() is used to extend the file on a per-sector basis. That would mean compressed data is not packed inside sectors and no read-write-modify race condition exists, but I haven't fully audited get_cluster_offset(). Stefan --zq44+AAfm4giZpo5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXSIfDAAoJEJykq7OBq3PISxkH/3QiLbcBjzrCOl8QrAcA+blR mFljaPzkR9p7g7nn6oByv2JNwRAU4K0Z7C2SRrAjhB+9bbgQgpu0FdQ6I5nuC1R4 lUdQ76gOg7+N1u3PqUP0D1hZa9djYDBsjw0xrslX6tePEXoW7ISYzKUf7QqpbLp+ 9JulxqT2qQ/ZDQ8NfFo50o6y/NFAI+QKO3dJTEvb4qhgc5PzDOPD0a5iUP8VhsHu Gjxb/8Cuacb/0TOp/v73VJX6XCkN3DsjIrTKCW7jotuuEP1rAf617dmD/L4R2HQd pNc3/l7PslRzGES9UtB+/ZBN/4xexz767mFiHwugqmHiidgUglk+jM3TVy3uk4Y= =HwvJ -----END PGP SIGNATURE----- --zq44+AAfm4giZpo5--