提交 c2092abf 编写于 作者: S Sage Weil 提交者: Eric Blake

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 e266ded2 (2008) and aa296e6c, when the code
was originally introduced (the latter via cut and paste).
Signed-off-by: NSage Weil <sage@newdream.net>
上级 91ffb42c
...@@ -709,7 +709,7 @@ parallelsStoragePoolGetAlloc(virStoragePoolDefPtr def) ...@@ -709,7 +709,7 @@ parallelsStoragePoolGetAlloc(virStoragePoolDefPtr def)
def->capacity = ((unsigned long long)sb.f_frsize * def->capacity = ((unsigned long long)sb.f_frsize *
(unsigned long long)sb.f_blocks); (unsigned long long)sb.f_blocks);
def->available = ((unsigned long long)sb.f_bfree * 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; def->allocation = def->capacity - def->available;
return 0; return 0;
......
...@@ -910,7 +910,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -910,7 +910,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
pool->def->capacity = ((unsigned long long)sb.f_frsize * pool->def->capacity = ((unsigned long long)sb.f_frsize *
(unsigned long long)sb.f_blocks); (unsigned long long)sb.f_blocks);
pool->def->available = ((unsigned long long)sb.f_bfree * 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; pool->def->allocation = pool->def->capacity - pool->def->available;
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册