mirror of https://gitee.com/bigwinds/arangodb
try using fallocate to zero out file
This commit is contained in:
parent
ddd0c0877b
commit
49515f1f02
|
@ -174,6 +174,17 @@ static int CreateDatafile(std::string const& filename, TRI_voc_size_t maximalSiz
|
|||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// try fallocate first
|
||||
int res = fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, maximalSize);
|
||||
#else
|
||||
// no fallocate present, or at least pretend it's not there...
|
||||
int res = TRI_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
// either fallocate failed or it is not there...
|
||||
|
||||
// fill file with zeros from FileNullBuffer
|
||||
size_t writeSize = TRI_GetNullBufferSizeFiles();
|
||||
size_t written = 0;
|
||||
|
@ -209,6 +220,7 @@ static int CreateDatafile(std::string const& filename, TRI_voc_size_t maximalSiz
|
|||
|
||||
written += static_cast<size_t>(writeResult);
|
||||
}
|
||||
}
|
||||
|
||||
// go back to offset 0
|
||||
TRI_lseek_t offset = TRI_LSEEK(fd, (TRI_lseek_t)0, SEEK_SET);
|
||||
|
|
Loading…
Reference in New Issue