Skip to content

Commit

Permalink
beegfs: don't fail if output exists
Browse files Browse the repository at this point in the history
Use existing output file if it has the desired stripe settings
(number of targets, chunk size)
  • Loading branch information
osteffen committed Apr 29, 2019
1 parent d49d345 commit e3afdb5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/aiori-POSIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,24 @@ bool beegfs_isOptionSet(int opt) {
return opt != -1;
}

bool beegfs_compatibleFileExists(char* filepath, int numTargets, int chunkSize)
{
int fd = open(filepath, O_RDWR);

if (fd == -1)
return false;

unsigned read_stripePattern = 0;
u_int16_t read_numTargets = 0;
int read_chunkSize = 0;

bool retVal = beegfs_getStripeInfo(fd, &read_stripePattern, &read_chunkSize, &read_numTargets);

close(fd);

return retVal && read_numTargets == numTargets && read_chunkSize == chunkSize;
}

/*
* Create a file on a BeeGFS file system with striping parameters
*/
Expand Down Expand Up @@ -247,8 +265,9 @@ bool beegfs_createFilePath(char* filepath, mode_t mode, int numTargets, int chun

char* filenameTmp = strdup(filepath);
char* filename = basename(filepath);
bool isFileCreated = beegfs_createFile(parentDirFd, filename,
mode, numTargets, chunkSize);
bool isFileCreated = beegfs_compatibleFileExists(filepath, numTargets, chunkSize)
|| beegfs_createFile(parentDirFd, filename,
mode, numTargets, chunkSize);
if (!isFileCreated)
ERR("Could not create file");
retVal = true;
Expand Down

0 comments on commit e3afdb5

Please sign in to comment.