Merge pull request #31159 from snar/freebsd-disk-space

correct disk space calculations
This commit is contained in:
alexey-milovidov 2021-11-10 02:48:29 +03:00 committed by GitHub
commit 7006147268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -206,8 +206,8 @@ static void getNoSpaceLeftInfoMessage(std::filesystem::path path, String & msg)
fmt::format_to(std::back_inserter(msg),
"\nTotal space: {}\nAvailable space: {}\nTotal inodes: {}\nAvailable inodes: {}\nMount point: {}",
ReadableSize(fs.f_blocks * fs.f_bsize),
ReadableSize(fs.f_bavail * fs.f_bsize),
ReadableSize(fs.f_blocks * fs.f_frsize),
ReadableSize(fs.f_bavail * fs.f_frsize),
formatReadableQuantity(fs.f_files),
formatReadableQuantity(fs.f_favail),
mount_point);

View File

@ -172,7 +172,7 @@ UInt64 DiskLocal::getTotalSpace() const
fs = getStatVFS((fs::path(disk_path) / "data/").string());
else
fs = getStatVFS(disk_path);
UInt64 total_size = fs.f_blocks * fs.f_bsize;
UInt64 total_size = fs.f_blocks * fs.f_frsize;
if (total_size < keep_free_space_bytes)
return 0;
return total_size - keep_free_space_bytes;
@ -187,7 +187,7 @@ UInt64 DiskLocal::getAvailableSpace() const
fs = getStatVFS((fs::path(disk_path) / "data/").string());
else
fs = getStatVFS(disk_path);
UInt64 total_size = fs.f_bavail * fs.f_bsize;
UInt64 total_size = fs.f_bavail * fs.f_frsize;
if (total_size < keep_free_space_bytes)
return 0;
return total_size - keep_free_space_bytes;

View File

@ -1222,9 +1222,9 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
{
auto stat = getStatVFS(getContext()->getPath());
new_values["FilesystemMainPathTotalBytes"] = stat.f_blocks * stat.f_bsize;
new_values["FilesystemMainPathAvailableBytes"] = stat.f_bavail * stat.f_bsize;
new_values["FilesystemMainPathUsedBytes"] = (stat.f_blocks - stat.f_bavail) * stat.f_bsize;
new_values["FilesystemMainPathTotalBytes"] = stat.f_blocks * stat.f_frsize;
new_values["FilesystemMainPathAvailableBytes"] = stat.f_bavail * stat.f_frsize;
new_values["FilesystemMainPathUsedBytes"] = (stat.f_blocks - stat.f_bavail) * stat.f_frsize;
new_values["FilesystemMainPathTotalINodes"] = stat.f_files;
new_values["FilesystemMainPathAvailableINodes"] = stat.f_favail;
new_values["FilesystemMainPathUsedINodes"] = stat.f_files - stat.f_favail;
@ -1234,9 +1234,9 @@ void AsynchronousMetrics::update(std::chrono::system_clock::time_point update_ti
/// Current working directory of the server is the directory with logs.
auto stat = getStatVFS(".");
new_values["FilesystemLogsPathTotalBytes"] = stat.f_blocks * stat.f_bsize;
new_values["FilesystemLogsPathAvailableBytes"] = stat.f_bavail * stat.f_bsize;
new_values["FilesystemLogsPathUsedBytes"] = (stat.f_blocks - stat.f_bavail) * stat.f_bsize;
new_values["FilesystemLogsPathTotalBytes"] = stat.f_blocks * stat.f_frsize;
new_values["FilesystemLogsPathAvailableBytes"] = stat.f_bavail * stat.f_frsize;
new_values["FilesystemLogsPathUsedBytes"] = (stat.f_blocks - stat.f_bavail) * stat.f_frsize;
new_values["FilesystemLogsPathTotalINodes"] = stat.f_files;
new_values["FilesystemLogsPathAvailableINodes"] = stat.f_favail;
new_values["FilesystemLogsPathUsedINodes"] = stat.f_files - stat.f_favail;