Skip to content
This repository has been archived by the owner on Feb 24, 2018. It is now read-only.

add support for tuning BeeGFS parameters #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AX_PROG_CC_MPI
# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([fcntl.h libintl.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/statfs.h sys/statvfs.h sys/time.h unistd.h wchar.h gpfs.h gpfs_fcntl.h])
AC_CHECK_HEADERS([fcntl.h libintl.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/statfs.h sys/statvfs.h sys/time.h unistd.h wchar.h gpfs.h gpfs_fcntl.h beegfs/beegfs.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
Expand Down
8 changes: 8 additions & 0 deletions doc/USER_GUIDE
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ GPFS-SPECIFIC:
all locks. Might help mitigate lock-revocation
traffic when many proceses write/read to same file.

BeeGFS-SPECIFIC (POSIX only):
================
* beegfsNumTargets - set the number of storage targets to use

* beegfsChunkSize - set the striping chunk size. Must be a power of two,
and greater than 64kiB, (e.g.: 256k, 1M, ...)


***********************
* 5. VERBOSITY LEVELS *
***********************
Expand Down
119 changes: 119 additions & 0 deletions src/aiori-POSIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
#include <gpfs_fcntl.h>
#endif

#ifdef HAVE_BEEGFS_BEEGFS_H
#include <beegfs/beegfs.h>
#include <dirent.h>
#include <libgen.h>
#endif

#include "ior.h"
#include "aiori.h"
#include "iordef.h"
Expand Down Expand Up @@ -170,6 +176,101 @@ void gpfs_access_end(int fd, IOR_offset_t length, IOR_param_t *param, int access

#endif

#ifdef HAVE_BEEGFS_BEEGFS_H

int mkTempInDir(char* dirPath)
{
unsigned long len = strlen(dirPath) + 8;
char* tmpfilename = (char*)malloc(sizeof (char)*len+1);
snprintf(tmpfilename, len, "%s/XXXXXX", dirPath);

int fd = mkstemp(tmpfilename);
unlink(tmpfilename);
free(tmpfilename);

return fd;
}

bool beegfs_getStriping(char* dirPath, u_int16_t* numTargetsOut, unsigned* chunkSizeOut)
{
bool retVal = false;

int fd = mkTempInDir(dirPath);
if (fd) {
unsigned stripePattern = 0;
retVal = beegfs_getStripeInfo(fd, &stripePattern, chunkSizeOut, numTargetsOut);
close(fd);
}

return retVal;
}

bool beegfs_isOptionSet(int opt) {
return opt != -1;
}

/*
* Create a file on a BeeGFS file system with striping parameters
*/
bool beegfs_createFilePath(char* filepath, mode_t mode, int numTargets, int chunkSize)
{
bool retVal = false;
char* dirTmp = strdup(filepath);
char* dir = dirname(dirTmp);
DIR* parentDirS = opendir(dir);
if (!parentDirS) {
ERR("Failed to get directory");
}
else
{
int parentDirFd = dirfd(parentDirS);
if (parentDirFd < 0)
{
ERR("Failed to get directory descriptor");
}
else
{
bool isBeegfs = beegfs_testIsBeeGFS(parentDirFd);
if (!isBeegfs)
{
WARN("Not a BeeGFS file system");
}
else
{
if ( !beegfs_isOptionSet(numTargets)
|| !beegfs_isOptionSet(chunkSize)) {
u_int16_t defaultNumTargets = 0;
unsigned defaultChunkSize = 0;
bool haveDefaults = beegfs_getStriping(dir,
&defaultNumTargets,
&defaultChunkSize);
if (!haveDefaults)
ERR("Failed to get default BeeGFS striping values");

numTargets = beegfs_isOptionSet(numTargets) ?
numTargets : defaultNumTargets;
chunkSize = beegfs_isOptionSet(chunkSize) ?
chunkSize : defaultChunkSize;
}

char* filenameTmp = strdup(filepath);
char* filename = basename(filepath);
bool isFileCreated = beegfs_createFile(parentDirFd, filename,
mode, numTargets, chunkSize);
if (!isFileCreated)
ERR("Could not create file");
retVal = true;
free(filenameTmp);
}
}
closedir(parentDirS);
}
free(dirTmp);
return retVal;
}
#endif /* HAVE_BEEGFS_BEEGFS_H */


/*
* Creat and open a file through the POSIX interface.
*/
Expand Down Expand Up @@ -231,10 +332,28 @@ static void *POSIX_Create(char *testFileName, IOR_param_t * param)
}
} else {
#endif /* HAVE_LUSTRE_LUSTRE_USER_H */

fd_oflag |= O_CREAT | O_RDWR;

#ifdef HAVE_BEEGFS_BEEGFS_H
if (beegfs_isOptionSet(param->beegfs_chunkSize)
|| beegfs_isOptionSet(param->beegfs_numTargets)) {
bool result = beegfs_createFilePath(testFileName,
0664,
param->beegfs_numTargets,
param->beegfs_chunkSize);
if (result) {
fd_oflag &= ~O_CREAT;
} else {
EWARN("BeeGFS tuning failed");
}
}
#endif /* HAVE_BEEGFS_BEEGFS_H */

*fd = open64(testFileName, fd_oflag, 0664);
if (*fd < 0)
ERR("open64() failed");

#ifdef HAVE_LUSTRE_LUSTRE_USER_H
}

Expand Down
3 changes: 3 additions & 0 deletions src/ior.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ void init_IOR_Param_t(IOR_param_t * p)
p->testComm = MPI_COMM_WORLD;
p->setAlignment = 1;
p->lustre_start_ost = -1;

p->beegfs_numTargets = -1;
p->beegfs_chunkSize = -1;
}

/*
Expand Down
3 changes: 3 additions & 0 deletions src/ior.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ typedef struct
int gpfs_hint_access; /* use gpfs "access range" hint */
int gpfs_release_token; /* immediately release GPFS tokens after
creating or opening a file */
/* beegfs variables */
int beegfs_numTargets; /* number storage targets to use */
int beegfs_chunkSize; /* srtipe pattern for new files */

int id; /* test's unique ID */
int intraTestBarriers; /* barriers between open/op and op/close */
Expand Down
16 changes: 16 additions & 0 deletions src/parse_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "aiori.h"
#include "parse_options.h"

#define ISPOWEROFTWO(x) ((x != 0) && !(x & (x - 1)))

IOR_param_t initialTestParams;

/*
Expand Down Expand Up @@ -273,6 +275,20 @@ void DecodeDirective(char *line, IOR_param_t *params)
ERR("ior was not compiled with GPFS hint support");
#endif
params->gpfs_release_token = atoi(value);
} else if (strcasecmp(option, "beegfsNumTargets") == 0) {
#ifndef HAVE_BEEGFS_BEEGFS_H
ERR("ior was not compiled with BeeGFS support");
#endif
params->beegfs_numTargets = atoi(value);
if (params->beegfs_numTargets < 1)
ERR("beegfsNumTargets must be >= 1");
} else if (strcasecmp(option, "beegfsChunkSize") == 0) {
#ifndef HAVE_BEEGFS_BEEGFS_H
ERR("ior was not compiled with BeeGFS support");
#endif
params->beegfs_chunkSize = StringToBytes(value);
if (!ISPOWEROFTWO(params->beegfs_chunkSize) || params->beegfs_chunkSize < (1<<16))
ERR("beegfsChunkSize must be a power of two and >64k");
} else if (strcasecmp(option, "numtasks") == 0) {
params->numTasks = atoi(value);
RecalculateExpectedFileSize(params);
Expand Down