From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYXek-0001J4-GL for qemu-devel@nongnu.org; Mon, 20 Jun 2011 02:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QYXej-000428-Mf for qemu-devel@nongnu.org; Mon, 20 Jun 2011 02:08:18 -0400 Received: from mail-gy0-f173.google.com ([209.85.160.173]:49111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QYXej-000424-IN for qemu-devel@nongnu.org; Mon, 20 Jun 2011 02:08:17 -0400 Received: by gyg10 with SMTP id 10so588395gyg.4 for ; Sun, 19 Jun 2011 23:08:17 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Mon, 20 Jun 2011 07:08:16 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH 12/12] Add disk_size field to BlockDriverState structure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , qemu-devel@nongnu.org, Christoph Hellwig On Mon, Jun 20, 2011 at 6:37 AM, Fam Zheng 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