]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: use f_frsize, not f_bsize, for calculating available space
authorSage Weil <sage@newdream.net>
Fri, 22 Feb 2013 23:43:00 +0000 (15:43 -0800)
committerEric Blake <eblake@redhat.com>
Sat, 23 Feb 2013 00:01:25 +0000 (17:01 -0700)
The bfree and blocks fields are supposed to be in units of frsize.  We were
calculating capacity correctly using those units, but the available
calculation was using bsize instead.  Most file systems report these as the
same value specifically because many programs are buggy, but that is no
reason to rely on that behavior, or to behave inconsistently.

This bug has been present since e266ded (2008) and aa296e6c, when the code
was originally introduced (the latter via cut and paste).

Signed-off-by: Sage Weil <sage@newdream.net>
src/parallels/parallels_storage.c
src/storage/storage_backend_fs.c

index 1186296348530c313538adcefa584247f0b42421..f696fcb2ac2e3e13469846221e5396bab421638e 100644 (file)
@@ -709,7 +709,7 @@ parallelsStoragePoolGetAlloc(virStoragePoolDefPtr def)
     def->capacity = ((unsigned long long)sb.f_frsize *
                      (unsigned long long)sb.f_blocks);
     def->available = ((unsigned long long)sb.f_bfree *
-                            (unsigned long long)sb.f_bsize);
+                      (unsigned long long)sb.f_frsize);
     def->allocation = def->capacity - def->available;
 
     return 0;
index a58280468cd3ceb45e4b74a5b646130bbdf4b415..c1684f77cb487c2b095d8b133824755ca9a21903 100644 (file)
@@ -910,7 +910,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
     pool->def->capacity = ((unsigned long long)sb.f_frsize *
                            (unsigned long long)sb.f_blocks);
     pool->def->available = ((unsigned long long)sb.f_bfree *
-                            (unsigned long long)sb.f_bsize);
+                            (unsigned long long)sb.f_frsize);
     pool->def->allocation = pool->def->capacity - pool->def->available;
 
     return 0;