User`s guide

Managing Lustre I/O with the Snapshot Library [6]
While these functions are useful for transferring small quantities of data to or from
arbitrary locations in files but, because they are unable to benefit from parallelism,
they are not useful for bulk data transfer. You should not expect throughput greater
than 100MB/second when using
dslr_pwrite or dslr_pread.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <snapshot/client.h>
const size_t DEFAULT_BUFFER_SIZE = 1024 * 1024; // Relatively short buffer
const char DEFAULT_FILENAME[] = "/mnt/lustre/myusername/snapshot.data";
int main(int argc, char *argv[])
{
void *testBuffer = NULL;]
int64_t err;
int64_t snapError = 0;
uint64_t fsworkerID = dslr_ANY_SW;
off_t fileOffset = 0;
int rc = 0;
// Allocate a small buffer to be transferred.
if (NULL == (testBuffer = malloc(DEFAULT_BUFFER_SIZE)))
{
fprintf(stderr,"Failed to malloc %d byte snapshot buffer.\n",
DEFAULT_BUFFER_SIZE);
return -1;
}
memset(testBuffer, 'a', DEFAULT_BUFFER_SIZE);
// pwrite the testBuffer to disk
fileOffset = 0;
err = dslr_pwrite((char *)DEFAULT_FILENAME,
fsworkerID,
testBuffer, DEFAULT_BUFFER_SIZE,
fileOffset,&snapError );
if (dslr_ERR_OK != err)
{
fprintf(stderr,"Failed to pwrite the dataset. Error %d.\n",err);
free(testBuffer);
return -1;
}
memset(testBuffer, 0, DEFAULT_BUFFER_SIZE);
// pread the testBuffer from disk.
err = dslr_pread ((char *)DEFAULT_FILENAME,
fsworkerID,
testBuffer, DEFAULT_BUFFER_SIZE,
fileOffset, &snapError);
if (dslr_ERR_OK != err)
{
fprintf(stderr,"Failed to pread the dataset. Error %d.\n",err);
free(testBuffer);
return -1;
}
// At this point, the testBuffer should be full of 'a'
free(testBuffer);
return 0;
}
S247920 73