User`s guide

Managing Lustre I/O with the Snapshot Library [6]
If the underlying file system is naturally serial (NFS, for example) its performance
is constrained by the serial performance of the file system and any contention
introduced by trying to use the file system in parallel. Again, the throughput of
the snapshot library is bounded by the file system performance, so when using a
serial file system a single
fsworker provides the best throughput for the snapshot
library. Note that fsworkers are not resilient. If a transaction fails, all involved
fsworkers must be terminated and restarted. If the file system is full a snapshot
function may return success even though the file was not written, or was only
partially written.
6.4 Examples
Example 14. Using dslr_snapshot and dslr_restore to save and restore
data in a file.
Note that this example waits for the call to dslr_snapshot to complete before
calling dslr_restore. While this is logical in this example, it is also crucial for
correct operation. (See the caution about using snapshot library functions in parallel
above.)
#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 * 1024;
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;
// Allocate a large 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);
// Snapshot the testBuffer to disk
// All file system workers must be able to access the specified path.
err = dslr_snapshot ((char *)DEFAULT_FILENAME, testBuffer,
DEFAULT_BUFFER_SIZE, &snapError );
if (dslr_ERR_OK != err)
{
fprintf(stderr,"Failed to snapshot the dataset. Error %d.\n",err);free(testBuffer);
return -1;
}
S247920 71