Merge pull request #9257 from millb/disk_scheme_4

Space check from path/data/ for default disk
This commit is contained in:
alexey-milovidov 2020-02-22 00:27:49 +03:00 committed by GitHub
commit 49b46fd897
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@
namespace DB
{
namespace ErrorCodes
{
extern const int UNKNOWN_ELEMENT_IN_CONFIG;
@ -106,7 +107,11 @@ bool DiskLocal::tryReserve(UInt64 bytes)
UInt64 DiskLocal::getTotalSpace() const
{
auto fs = getStatVFS(disk_path);
struct statvfs fs;
if (name == "default") /// for default disk we get space from path/data/
fs = getStatVFS(disk_path + "data/");
else
fs = getStatVFS(disk_path);
UInt64 total_size = fs.f_blocks * fs.f_bsize;
if (total_size < keep_free_space_bytes)
return 0;
@ -117,7 +122,11 @@ UInt64 DiskLocal::getAvailableSpace() const
{
/// we use f_bavail, because part of b_free space is
/// available for superuser only and for system purposes
auto fs = getStatVFS(disk_path);
struct statvfs fs;
if (name == "default") /// for default disk we get space from path/data/
fs = getStatVFS(disk_path + "data/");
else
fs = getStatVFS(disk_path);
UInt64 total_size = fs.f_bavail * fs.f_bsize;
if (total_size < keep_free_space_bytes)
return 0;