qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 12/12] Add disk_size field to BlockDriverState s


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 12/12] Add disk_size field to BlockDriverState structure
Date: Mon, 20 Jun 2011 07:08:16 +0100

On Mon, Jun 20, 2011 at 6:37 AM, Fam Zheng <address@hidden> wrote:
> Is there any difference between bdrv_getlength and
> bdrv_get_allocated_file_size for bs-file? If not, I can simplify it by
> reusing it in two raw devices.

Yes, the two functions are different:

POSIX sparse files (files with holes) take up less space on disk than
their file size.  For example a 1 GB file where you've only written
the last byte and never touched any other blocks will only take up one
block - the rest will be unallocated.  So bdrv_getlength() == 1 GB and
bdrv_get_allocated_file_size() == 4 KB (or whatever the file system
block size is).

You can look at this using the stat(1) command and dd(1) to only write
the last byte of a file.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]