23.07.2014 Views

Lustre 1.6 Operations Manual

Lustre 1.6 Operations Manual

Lustre 1.6 Operations Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if (close(fd) < 0) {<br />

fprintf(stderr, "File close failed: %d (%s)\n", errno,<br />

strerror(errno));<br />

return -1;<br />

}<br />

return 0;<br />

}<br />

int write_file(int fd)<br />

{<br />

char *stng = DUMWORD;<br />

int cnt = 0;<br />

for( cnt = 0; cnt < FILESIZE; cnt++) {<br />

write(fd, stng, sizeof(stng));<br />

}<br />

return 0;<br />

}<br />

/* Open a file, set a specific stripe count, size and starting OST<br />

Adjust the parameters to suit */<br />

int open_stripe_file()<br />

{<br />

char *tfile = TESTFILE;<br />

int stripe_size = 65536; /* System default is 4M */<br />

int stripe_offset = -1; /* Start at default */<br />

int stripe_count = MY_STRIPE_WIDTH; /*Single stripe for this<br />

demo*/<br />

int stripe_pattern = 0;<br />

/* only RAID 0 at this time<br />

*/<br />

int rc, fd;<br />

/*<br />

*/<br />

rc = llapi_file_create(tfile,<br />

stripe_size,stripe_offset,stripe_count,stripe_pattern);<br />

/* result code is inverted, we may return -EINVAL or an ioctl error.<br />

We borrow an error message from sanity.c<br />

*/<br />

if (rc) {<br />

fprintf(stderr,"llapi_file_create failed: %d (%s) \n", rc,<br />

strerror(-rc));<br />

return -1;<br />

}<br />

/* llapi_file_create closes the file descriptor, we must re-open */<br />

fd = open(tfile, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);<br />

if (fd < 0) {<br />

fprintf(stderr, "Can't open %s file: %d (%s)\n", tfile, errno,<br />

strerror(errno));<br />

return -1;<br />

}<br />

return fd;<br />

}<br />

/* output a list of uuids for this file */<br />

Chapter 25 Striping and I/O Options 25-13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!