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

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



On Thu, Apr 02, 2009 at 02:39:58PM -0400, Cole Robinson wrote:
> Daniel P. Berrange wrote:
> > On Thu, Mar 26, 2009 at 05:55:00PM +0100, Daniel Veillard wrote:
> >>   So I agree with Dan, we need to drop st_blksize in any volume size
> >> computation, and fallback to 512 if not defined, apparently only
> >> src/storage_backend.c referenced it :-)
> >>
> >>   I still find the "It may differ on a file system basis" to be a bit
> >> frightening considering the sandard doesn't seems to indicate how to
> >> extract that information from the filesystem :-( , oh well ...
> > 
> > I guess if we come across a filesystem where it is not 512, then someone
> > will have created an ioctl() or equivalent to let us find out the true
> > value. Failing that, relying on 512 seems like a good plan.
> > 
> > Daniel
> 
> Okay, updated patch attached.

ACK, looks good to me.


> commit 3f289f7c1ea04cb5d14bf125959ba41b13b64443
> Author: Cole Robinson <crobinso redhat com>
> Date:   Wed Apr 1 16:00:58 2009 -0400
> 
>     Fix sparse volume allocation reporting.
> 
> diff --git a/src/storage_backend.c b/src/storage_backend.c
> index 71b8020..79c070c 100644
> --- a/src/storage_backend.c
> +++ b/src/storage_backend.c
> @@ -36,6 +36,7 @@
>  #include <fcntl.h>
>  #include <stdint.h>
>  #include <sys/stat.h>
> +#include <sys/param.h>
>  #include <dirent.h>
>  
>  #if HAVE_SELINUX
> @@ -64,6 +65,9 @@
>  #include "storage_backend_fs.h"
>  #endif
>  
> +#ifndef DEV_BSIZE
> +#define DEV_BSIZE 512
> +#endif
>  
>  #define VIR_FROM_THIS VIR_FROM_STORAGE
>  
> @@ -211,7 +215,7 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn,
>          if (S_ISREG(sb.st_mode)) {
>  #ifndef __MINGW32__
>              *allocation = (unsigned long long)sb.st_blocks *
> -                (unsigned long long)sb.st_blksize;
> +                          (unsigned long long)DEV_BSIZE;
>  #else
>              *allocation = sb.st_size;
>  #endif


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]