Received: from eggs.gnu.org ([2001:4830:134:3::10]:44693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VX8ui-0002yJ-UF for qemu-devel@nongnu.org; Fri, 18 Oct 2013 08:12:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VX8ua-00018R-Gc for qemu-devel@nongnu.org; Fri, 18 Oct 2013 08:12:20 -0400 Received: from mail-ea0-x234.google.com ([2a00:1450:4013:c01::234]:64915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VX8ua-00018G-7a for qemu-devel@nongnu.org; Fri, 18 Oct 2013 08:12:12 -0400 Received: by mail-ea0-f180.google.com with SMTP id h10so1911258eaj.39 for ; Fri, 18 Oct 2013 05:12:10 -0700 (PDT) Date: Fri, 18 Oct 2013 14:12:08 +0200 From: Stefan Hajnoczi Message-ID: <20131018121208.GA18405@stefanha-thinkpad.redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH v7 11/19] block: vhdx write support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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).