11 /****************** Custom includes ********************/
12 #include <linux/lustre_lite.h>
13 #include <linux/lustre_idl.h>
16 /****************** Functions ******************/
20 fprintf(stderr, "\nIncorrect parameters! Correct usage:\n\n" );
21 fprintf(stderr, "%s <output filename> <stripe size> <OST #> <stripe #>\n", pgm);
23 fprintf(stderr, "\n\nArgument explanations:\n---------------------\n\n");
24 fprintf(stderr, "<output filename> = the full name and path of the output file to create\n");
25 fprintf(stderr, "<stripe size> = the number of bytes to have in each stripe.\n");
26 fprintf(stderr, "<OST #> = the OST number to start the striping on.\n");
27 fprintf(stderr, "<stripe #> = the number of stripes to use.\n");
29 fprintf(stderr, "\n\nExamples:\n---------\n\n");
31 fprintf(stderr, "%s /mnt/lustre/ost1 131072 0 1\n", pgm);
32 fprintf(stderr, "\t\tcreates a file only on ost1.\n\n");
34 fprintf(stderr, "%s /mnt/lustre/ost2 131072 1 1\n", pgm);
35 fprintf(stderr, "\t\tcreates a file only on ost2.\n\n");
37 fprintf(stderr, "%s /mnt/lustre/ost1and2 131072 0 2\n", pgm);
38 fprintf(stderr, "\t\tcreates a 128k file with 2 stripes, on ost1 and ost2.\n");
40 fprintf(stderr, "%s /mnt/lustre/ost1and2 131072 1 2\n", pgm);
41 fprintf(stderr, "\t\tcreates a 128k file with 2 stripes, on ost2 and ost1.\n");
44 int create_file(char *name, long stripe_size, int stripe_offset,
47 struct lov_mds_md a_striping;
50 /* Initialize IOCTL striping pattern structure */
51 a_striping.lmm_magic = LOV_MAGIC;
52 a_striping.lmm_stripe_pattern = 0;
53 a_striping.lmm_stripe_size = stripe_size;
54 a_striping.lmm_stripe_offset = stripe_offset;
55 a_striping.lmm_stripe_count = stripe_count;
57 fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
59 fprintf(stderr, "\nUnable to open '%s': %s\n",
60 name, strerror(errno));
62 } else if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &a_striping)) {
63 fprintf(stderr, "\nError on ioctl for '%s' (%d): %s\n",
64 name, fd, strerror(errno));
66 } else if (close(fd) < 0) {
67 fprintf(stderr, "\nError on close for '%s' (%d): %s\n",
68 name, fd, strerror(errno));
75 int main(int argc, char *argv[])
82 /* Check to make sure we have enough parameters */
88 /* Get the stripe size */
89 st_size = atol(argv[2]);
91 /* Get the stripe offset*/
92 st_offset = atoi(argv[3]);
94 /* Get the stripe count */
95 st_count = atoi(argv[4]);
97 /* Create the file, as specified. Return and display any errors. */
98 result = create_file(argv[1], st_size, st_offset, st_count);