1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-4328 MCS avoids chown() calls for files that are on S3

MCS now chowns created directories hierarchy not only files and
immediate parent directories

Minor changes to cpimport's help printout

cpimport's -f option is now mandatory with mode 2
This commit is contained in:
Roman Nozdrin
2020-10-08 13:21:22 +00:00
parent d85fc579ba
commit 6f120d2637
9 changed files with 97 additions and 84 deletions

View File

@ -791,8 +791,7 @@ int FileOp::extendFile(
{
// We presume the path will contain /
std::string filePath(fileName);
std::ostringstream ossChown;
if (chownDataFileDir(ossChown, filePath))
if (chownDataPath(filePath))
return ERR_FILE_CHOWN;
}
@ -2365,57 +2364,27 @@ int FileOp::oid2FileName( FID fid,
return ERR_FILE_NOT_EXIST;
}
/*
char dirName[FILE_NAME_SIZE];
sprintf( dirName, "%s/%s", Config::getDBRootByNum(dbRoot).c_str(),
dbDir[0] );
if( !isDir( dirName ) )
RETURN_ON_ERROR( createDir( dirName ));
sprintf( dirName, "%s/%s", dirName, dbDir[1] );
if( !isDir( dirName ) )
RETURN_ON_ERROR( createDir( dirName ));
sprintf( dirName, "%s/%s", dirName, dbDir[2] );
if( !isDir( dirName ) )
RETURN_ON_ERROR( createDir( dirName ));
sprintf( dirName, "%s/%s", dirName, dbDir[3] );
if( !isDir( dirName ) )
RETURN_ON_ERROR( createDir( dirName ));
sprintf( dirName, "%s/%s", dirName, dbDir[4] );
if( !isDir( dirName ) )
RETURN_ON_ERROR( createDir( dirName ));
*/
std::stringstream aDirName;
for (size_t i = 0; i < MaxDirLevels; i++)
{
if (i == 0)
{
aDirName << Config::getDBRootByNum(dbRoot).c_str()
<< "/" << dbDir[i];
}
else
{
aDirName << "/" << dbDir[i];
}
if (!isDir(aDirName.str().c_str()))
RETURN_ON_ERROR( createDir(aDirName.str().c_str()) );
aDirName << Config::getDBRootByNum(dbRoot).c_str() << "/" << dbDir[0];
if (!isDir((aDirName.str()).c_str()))
RETURN_ON_ERROR( createDir((aDirName.str()).c_str()) );
aDirName << "/" << dbDir[1];
if (!isDir(aDirName.str().c_str()))
RETURN_ON_ERROR( createDir(aDirName.str().c_str()) );
aDirName << "/" << dbDir[2];
if (!isDir(aDirName.str().c_str()))
RETURN_ON_ERROR( createDir(aDirName.str().c_str()) );
aDirName << "/" << dbDir[3];
if (!isDir(aDirName.str().c_str()))
RETURN_ON_ERROR( createDir(aDirName.str().c_str()) );
aDirName << "/" << dbDir[4];
if (!isDir(aDirName.str().c_str()))
RETURN_ON_ERROR( createDir(aDirName.str().c_str()) );
{
std::ostringstream ossChown;
if (chownDataPath(aDirName.str()))
return ERR_FILE_CHOWN;
}
}
return NO_ERROR;
}
@ -2932,11 +2901,13 @@ void FileOp::setFixFlag(bool isFix)
m_isFix = isFix;
}
bool FileOp::chownDataFileDir(std::ostringstream& error,
const std::string& fileName)
// Small note. We call chownFileDir in couple places to chown of the
// target file and call in oid2Filename() chowns directories created
bool FileOp::chownDataPath(const std::string& fileName) const
{
std::string dirName = fileName.substr(0, fileName.find_last_of('/'));
if (chownFileDir(error, fileName, dirName))
std::ostringstream error;
idbdatafile::IDBFileSystem& fs = IDBPolicy::getFs(fileName);
if (chownPath(error, fileName, fs))
{
logging::Message::Args args;
logging::Message message(1);