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

Re: [libvirt] [PATCH] Fix sparse volume allocation reporting



On Tue, Mar 24, 2009 at 03:29:21PM -0400, Cole Robinson wrote:
> I have a sparse volume with a capacity of 1000M, and an allocation of a
> little over 750M. 'du' prints the correct sizes, but 'virsh vol-dumpxml'
> shows:
> 
>     <capacity>1048576000</capacity>
>   <allocation>6406307840</allocation>
> 
> This is because we were calculating the allocation size using the
> requested fs block size, instead of what stat actually uses as a block
> size (DEV_BSIZE in sys/params.h). sys/params.h looks to be present in
> mingw32-runtime, so I didn't add a configure check for it.
> 

>  #if HAVE_SELINUX
> @@ -204,8 +205,15 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn,
>      if (allocation) {
>          if (S_ISREG(sb.st_mode)) {
>  #ifndef __MINGW32__
> -            *allocation = (unsigned long long)sb.st_blocks *
> -                (unsigned long long)sb.st_blksize;
> +
> +            unsigned long long blksize;
> +#ifdef DEV_BSIZE
> +            blksize = (unsigned long long) DEV_BSIZE;
> +#else
> +            blksize = (unsigned long long)sb.st_blksize;
> +#endif
> +            *allocation = (unsigned long long)sb.st_blocks * blksize;

Having read the man page again, I'm inclined to say using st_blksize
is always wrong no matter what, because it is quite clear that 'st_blocks'
is always in 512 byte units. So perhaps we might be better of doing

   #ifndef DEV_BSIZE
   #define DEV_BSIZE 512
   #endif

And then always using DEV_BSIZE. 

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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