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 <s...@newdream.net> --- src/parallels/parallels_storage.c | 2 +- src/storage/storage_backend_fs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/parallels/parallels_storage.c b/src/parallels/parallels_storage.c index 1186296..f696fcb 100644 --- a/src/parallels/parallels_storage.c +++ b/src/parallels/parallels_storage.c @@ -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; diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index a582804..c1684f7 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -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; -- 1.7.2.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list