Call backend statfs() instead of only POSIX-specific variant.

master
Julian M. Kunkel 2020-05-31 13:30:31 +01:00
parent 5663593919
commit 8fa8ef0c02
7 changed files with 99 additions and 139 deletions

View File

@ -154,27 +154,48 @@ void aiori_supported_apis(char * APIs, char * APIs_legacy, enum bench_type type)
*/
int aiori_posix_statfs (const char *path, ior_aiori_statfs_t *stat_buf, aiori_mod_opt_t * module_options)
{
int ret;
// find the parent directory
char * fileName = strdup(path);
int i;
int directoryFound = FALSE;
/* get directory for outfile */
i = strlen(fileName);
while (i-- > 0) {
if (fileName[i] == '/') {
fileName[i] = '\0';
directoryFound = TRUE;
break;
}
}
/* if no directory/, use '.' */
if (directoryFound == FALSE) {
strcpy(fileName, ".");
}
int ret;
#if defined(HAVE_STATVFS)
struct statvfs statfs_buf;
struct statvfs statfs_buf;
ret = statvfs (path, &statfs_buf);
ret = statvfs (fileName, &statfs_buf);
#else
struct statfs statfs_buf;
struct statfs statfs_buf;
ret = statfs (path, &statfs_buf);
ret = statfs (fileName, &statfs_buf);
#endif
if (-1 == ret) {
return -1;
}
if (-1 == ret) {
perror("POSIX couldn't call statvfs");
return -1;
}
stat_buf->f_bsize = statfs_buf.f_bsize;
stat_buf->f_blocks = statfs_buf.f_blocks;
stat_buf->f_bfree = statfs_buf.f_bfree;
stat_buf->f_files = statfs_buf.f_files;
stat_buf->f_ffree = statfs_buf.f_ffree;
stat_buf->f_bsize = statfs_buf.f_bsize;
stat_buf->f_blocks = statfs_buf.f_blocks;
stat_buf->f_bfree = statfs_buf.f_bfree;
stat_buf->f_files = statfs_buf.f_files;
stat_buf->f_ffree = statfs_buf.f_ffree;
return 0;
free(fileName);
return 0;
}
int aiori_posix_mkdir (const char *path, mode_t mode, aiori_mod_opt_t * module_options)

View File

@ -17,7 +17,6 @@ void PrintShortSummary(IOR_test_t * test);
void PrintLongSummaryAllTests(IOR_test_t *tests_head);
void PrintLongSummaryHeader();
void PrintLongSummaryOneTest(IOR_test_t *test);
void DisplayFreespace(IOR_param_t * test);
void GetTestFileName(char *, IOR_param_t *);
void PrintRemoveTiming(double start, double finish, int rep);
void PrintReducedResult(IOR_test_t *test, int access, double bw, double iops, double latency,

View File

@ -322,11 +322,8 @@ void ShowTestStart(IOR_param_t *test)
PrintStartSection();
PrintKeyValInt("TestID", test->id);
PrintKeyVal("StartTime", CurrentTimeString());
/* if pvfs2:, then skip */
if (strcasecmp(test->api, "DFS") &&
Regex(test->testFileName, "^[a-z][a-z].*:") == 0) {
DisplayFreespace(test);
}
ShowFileSystemSize(test);
if (verbose >= VERBOSE_3 || outputFormat == OUTPUT_JSON) {
char* data_packets[] = {"g","t","o","i"};
@ -724,38 +721,6 @@ void PrintShortSummary(IOR_test_t * test)
}
}
/*
* Display freespace (df).
*/
void DisplayFreespace(IOR_param_t * test)
{
char fileName[MAX_STR] = { 0 };
int i;
int directoryFound = FALSE;
/* get outfile name */
GetTestFileName(fileName, test);
/* get directory for outfile */
i = strlen(fileName);
while (i-- > 0) {
if (fileName[i] == '/') {
fileName[i] = '\0';
directoryFound = TRUE;
break;
}
}
/* if no directory/, use '.' */
if (directoryFound == FALSE) {
strcpy(fileName, ".");
}
ShowFileSystemSize(fileName);
}
void PrintRemoveTiming(double start, double finish, int rep)
{
if (rank != 0 || verbose < VERBOSE_0)

View File

@ -82,13 +82,14 @@ static void ior_set_xfer_hints(IOR_param_t * p){
static void test_initialize(IOR_test_t * test){
verbose = test->params.verbose;
backend = test->params.backend;
if (rank == 0 && verbose >= VERBOSE_0) {
ShowTestStart(& test->params);
}
if(backend->initialize){
backend->initialize(test->params.backend_options);
}
ior_set_xfer_hints(& test->params);
if (rank == 0 && verbose >= VERBOSE_0) {
ShowTestStart(& test->params);
}
}
static void test_finalize(IOR_test_t * test){
@ -1807,7 +1808,7 @@ static IOR_offset_t WriteOrReadSingle(IOR_offset_t pairCnt, IOR_offset_t *offset
void *checkBuffer = ioBuffers->checkBuffer;
void *readCheckBuffer = ioBuffers->readCheckBuffer;
test->offset = offsetArray[pairCnt];
test->hints.offset = offsetArray[pairCnt]; // this looks inappropriate
transfer = test->transferSize;
if (access == WRITE) {
@ -1816,8 +1817,7 @@ static IOR_offset_t WriteOrReadSingle(IOR_offset_t pairCnt, IOR_offset_t *offset
if (test->storeFileOffset == TRUE) {
FillBuffer(buffer, test, test->offset, pretendRank);
}
amtXferred =
backend->xfer(access, fd, buffer, transfer, test->backend_options);
amtXferred = backend->xfer(access, fd, buffer, transfer, test->backend_options);
if (amtXferred != transfer)
ERR("cannot write to file");
if (test->fsyncPerWrite)

View File

@ -89,7 +89,6 @@ typedef struct
char * apiVersion; /* API version */
char * platform; /* platform type */
char * testFileName; /* full name for test */
char * testFileName_fppReadCheck;/* filename for fpp read check */
char * options; /* options string */
// intermediate options
int collective; /* collective I/O */

View File

@ -47,6 +47,7 @@
#include "utilities.h"
#include "aiori.h"
#include "ior.h"
#include "ior-internal.h"
/************************** D E C L A R A T I O N S ***************************/
@ -565,91 +566,66 @@ IOR_offset_t StringToBytes(char *size_str)
/*
* Displays size of file system and percent of data blocks and inodes used.
*/
void ShowFileSystemSize(char *fileSystem) // this might be converted to an AIORI call
void ShowFileSystemSize(IOR_param_t * test) // this might be converted to an AIORI call
{
#ifndef _WIN32 /* FIXME */
char realPath[PATH_MAX];
char *fileSystemUnitStr;
long long int totalFileSystemSize;
long long int freeFileSystemSize;
long long int totalInodes;
long long int freeInodes;
double totalFileSystemSizeHR;
double usedFileSystemPercentage;
double usedInodePercentage;
#ifdef __sun /* SunOS does not support statfs(), instead uses statvfs() */
struct statvfs statusBuffer;
#else /* !__sun */
struct statfs statusBuffer;
#endif /* __sun */
ior_aiori_statfs_t stat;
if(! test->backend->statfs){
WARN("Backend doesn't implement statfs");
return;
}
char filename[MAX_PATHLEN];
GetTestFileName(filename, test);
int ret = test->backend->statfs(filename, & stat, test->backend_options);
if( ret != 0 ){
WARN("Backend returned error during statfs");
return;
}
long long int totalFileSystemSize;
long long int freeFileSystemSize;
long long int totalInodes;
long long int freeInodes;
double totalFileSystemSizeHR;
double usedFileSystemPercentage;
double usedInodePercentage;
char *fileSystemUnitStr;
#ifdef __sun
if (statvfs(fileSystem, &statusBuffer) != 0) {
WARN("unable to statvfs() file system");
return;
}
#else /* !__sun */
if (statfs(fileSystem, &statusBuffer) != 0) {
WARN("unable to statfs() file system");
return;
}
#endif /* __sun */
totalFileSystemSize = stat.f_blocks * stat.f_bsize;
freeFileSystemSize = stat.f_bfree * stat.f_bsize;
usedFileSystemPercentage = (1 - ((double)freeFileSystemSize / (double)totalFileSystemSize)) * 100;
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)(1<<30);
/* data blocks */
#ifdef __sun
totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_frsize;
freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_frsize;
#else /* !__sun */
totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_bsize;
freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_bsize;
#endif /* __sun */
/* inodes */
totalInodes = stat.f_files;
freeInodes = stat.f_ffree;
usedInodePercentage = (1 - ((double)freeInodes / (double)totalInodes)) * 100;
usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
/ (double)totalFileSystemSize)) * 100;
totalFileSystemSizeHR =
(double)totalFileSystemSize / (double)(1<<30);
fileSystemUnitStr = "GiB";
if (totalFileSystemSizeHR > 1024) {
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)((long long)1<<40);
fileSystemUnitStr = "TiB";
}
fileSystemUnitStr = "GiB";
if (totalFileSystemSizeHR > 1024) {
totalFileSystemSizeHR = (double)totalFileSystemSize / (double)((long long)1<<40);
fileSystemUnitStr = "TiB";
}
if(outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%-20s: %s\n", "Path", filename);
fprintf(out_resultfile, "%-20s: %.1f %s Used FS: %2.1f%% ",
"FS", totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(out_resultfile, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n",
(double)totalInodes / (double)(1<<20),
usedInodePercentage);
fflush(out_logfile);
}else if(outputFormat == OUTPUT_JSON){
fprintf(out_resultfile, " , \"Path\": \"%s\",", filename);
fprintf(out_resultfile, "\"Capacity\": \"%.1f %s\", \"Used Capacity\": \"%2.1f%%\",",
totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(out_resultfile, "\"Inodes\": \"%.1f Mi\", \"Used Inodes\" : \"%2.1f%%\"\n",
(double)totalInodes / (double)(1<<20),
usedInodePercentage);
}else if(outputFormat == OUTPUT_CSV){
/* inodes */
totalInodes = statusBuffer.f_files;
freeInodes = statusBuffer.f_ffree;
usedInodePercentage =
(1 - ((double)freeInodes / (double)totalInodes)) * 100;
}
/* show results */
if (realpath(fileSystem, realPath) == NULL) {
WARN("unable to use realpath()");
return;
}
if(outputFormat == OUTPUT_DEFAULT){
fprintf(out_resultfile, "%-20s: %s\n", "Path", realPath);
fprintf(out_resultfile, "%-20s: %.1f %s Used FS: %2.1f%% ",
"FS", totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(out_resultfile, "Inodes: %.1f Mi Used Inodes: %2.1f%%\n",
(double)totalInodes / (double)(1<<20),
usedInodePercentage);
fflush(out_logfile);
}else if(outputFormat == OUTPUT_JSON){
fprintf(out_resultfile, " , \"Path\": \"%s\",", realPath);
fprintf(out_resultfile, "\"Capacity\": \"%.1f %s\", \"Used Capacity\": \"%2.1f%%\",",
totalFileSystemSizeHR, fileSystemUnitStr,
usedFileSystemPercentage);
fprintf(out_resultfile, "\"Inodes\": \"%.1f Mi\", \"Used Inodes\" : \"%2.1f%%\"\n",
(double)totalInodes / (double)(1<<20),
usedInodePercentage);
}else if(outputFormat == OUTPUT_CSV){
}
#endif /* !_WIN32 */
return;
return;
}
/*

View File

@ -47,7 +47,7 @@ void set_o_direct_flag(int *fd);
char *CurrentTimeString(void);
int Regex(char *, char *);
void ShowFileSystemSize(char *);
void ShowFileSystemSize(IOR_param_t * test);
void DumpBuffer(void *, size_t);
void SeedRandGen(MPI_Comm);
void SetHints (MPI_Info *, char *);