qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] copy on write-but-no-change
@ 2007-09-06 22:55 Lapo Luchini
  2007-09-07 15:40 ` Luke -Jr
  0 siblings, 1 reply; 3+ messages in thread
From: Lapo Luchini @ 2007-09-06 22:55 UTC (permalink / raw)
  To: qemu-devel

I noticed that cow adds space also if the written data is the same as
the one it was there already.
Is there a reason why checking it would be bad/difficult/slow/other?
Simply no one had the will to code the check?

I ask because for shrinking drives I usually create big zero-filled
files... and this grows the qcow2 image like mad, and only a compressed
convert can properly shrink it back. OK, it is not to be done very very
often, but not copying those writes that don't actually change the data
seems like a good idea... don't know about the speed hit, though.

Another idea would be to detect "only zero" write blocks and simply
interpret them as "put a hole in the sparse file" instead of actually
writing data to disk.

Just the first idea that hit me after a few hours of qemu usage, don't
hit me with a brick if it has already been discussed to death: I
searched it in the gmane.org archives to no avail ;-)

-- 
Lapo Luchini
lapo@lapo.it (OpenPGP & X.509)
www.lapo.it (Jabber, ICQ, MSN)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] copy on write-but-no-change
  2007-09-06 22:55 [Qemu-devel] copy on write-but-no-change Lapo Luchini
@ 2007-09-07 15:40 ` Luke -Jr
  2007-09-11  6:47   ` Rob Landley
  0 siblings, 1 reply; 3+ messages in thread
From: Luke -Jr @ 2007-09-07 15:40 UTC (permalink / raw)
  To: qemu-devel

On Thursday 06 September 2007, Lapo Luchini wrote:
> I noticed that cow adds space also if the written data is the same as
> the one it was there already.
> Is there a reason why checking it would be bad/difficult/slow/other?
> Simply no one had the will to code the check?

Simply that your operation is not very common, and checking every time would 
put read overhead on top of write overhead. If you want to check, feel free 
to check prior to issuing the write. ;)

> I ask because for shrinking drives I usually create big zero-filled
> files... and this grows the qcow2 image like mad, and only a compressed
> convert can properly shrink it back. OK, it is not to be done very very
> often, but not copying those writes that don't actually change the data
> seems like a good idea... don't know about the speed hit, though.

I think it's logical to require an explicit conversion when you want to 
shrink.

> Another idea would be to detect "only zero" write blocks and simply
> interpret them as "put a hole in the sparse file" instead of actually
> writing data to disk.

I don't believe it's possible to make holes in sparse files explicitly.
The libc/OS only support it transparently when you jump to the end of a file 
and begin writing there.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] copy on write-but-no-change
  2007-09-07 15:40 ` Luke -Jr
@ 2007-09-11  6:47   ` Rob Landley
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Landley @ 2007-09-11  6:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: Luke -Jr

On Friday 07 September 2007 10:40:15 am Luke -Jr wrote:
> I don't believe it's possible to make holes in sparse files explicitly.
> The libc/OS only support it transparently when you jump to the end of a
> file and begin writing there.

Actually, I believe it should finally show up in the 2.6.23 kernel.  Look for 
fadvise(FA_DEALLOCATE)

http://lwn.net/Articles/226710/

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-11  6:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-06 22:55 [Qemu-devel] copy on write-but-no-change Lapo Luchini
2007-09-07 15:40 ` Luke -Jr
2007-09-11  6:47   ` Rob Landley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).