From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXy4N-0001ek-Cc for qemu-devel@nongnu.org; Tue, 06 Dec 2011 11:40:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXy4L-00007F-Us for qemu-devel@nongnu.org; Tue, 06 Dec 2011 11:40:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXy4L-000071-JB for qemu-devel@nongnu.org; Tue, 06 Dec 2011 11:40:37 -0500 Message-ID: <4EDE4641.6010305@redhat.com> Date: Tue, 06 Dec 2011 17:43:45 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1321334931-26087-1-git-send-email-wdongxu@linux.vnet.ibm.com> <20111206124843.GA14426@amt.cnet> <4EDE11C4.2040202@redhat.com> <20111206145316.GA17987@amt.cnet> <20111206150610.GA18056@amt.cnet> <4EDE32D7.307@redhat.com> <20111206163503.GA18350@amt.cnet> In-Reply-To: <20111206163503.GA18350@amt.cnet> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5] block:add-cow file format List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: shuming@linux.vnet.ibm.com, Dong Xu Wang , qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com Am 06.12.2011 17:35, schrieb Marcelo Tosatti: > On Tue, Dec 06, 2011 at 04:20:55PM +0100, Kevin Wolf wrote: >> Am 06.12.2011 16:06, schrieb Marcelo Tosatti: >>> On Tue, Dec 06, 2011 at 12:53:16PM -0200, Marcelo Tosatti wrote: >>>> On Tue, Dec 06, 2011 at 01:59:48PM +0100, Kevin Wolf wrote: >>>>>>> + >>>>>>> + ret = bdrv_pread(bs->file, sizeof(header), state->bitmap, >>>>>>> + state->bitmap_size); >>>>>>> + if (ret != state->bitmap_size) { >>>>>>> + goto fail; >>>>>>> + } >>>>>> >>>>>> Reading the entire bitmap in memory is not acceptable, it may be huge. >>>>>> Better mmap it and use msync(MS_SYNC) when writing it back. This way the >>>>>> host can free memory easily upon pressure. >>>>> >>>>> You can't use mmap in block drivers. It would only work with raw-posix >>>>> backends, if at all. >>>>> >>>>> Kevin >>>> >>>> This is just the bitmap, a plain file. Why would you want to use >>>> anything other than a plain file to use as storage for the bitmap? >>> >>> Well, mmap'ing would make life much simpler, but it has limitations such >>> as portability. >>> >>> Then what is necessary is a cache similar to qcow2's metadata cache. >> >> Right, we can probably generalise the qcow2 code and make it available >> for other drivers as well. > > Hum, generalising sounds overly complicated (and there is a time > constraint to this). IMHO a cache internal to add-cow.c just to avoid > reading the entire bitmap would do the trick. The cache is mostly self-contained. But maybe we should get the locking right (instead of always locking the whole BlockDriverState) before using it in more drivers. I think this might need some change to it. Kevin