mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
storage: use f_frsize, not f_bsize, for calculating available space
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>
This commit is contained in:
parent
91ffb42c2c
commit
c2092abfb9
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user