X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fmultiop.c;h=7a21869eb79db5af5a856b1c57a7f288b731086c;hb=20544bd96269dbda51a76d31c2d09935637e8b2d;hp=ab360c411e1a45901efb8bfcbbaffeb007d20d1a;hpb=5517eab06eb99e4ecb66be251a10e70c37547610;p=fs%2Flustre-release.git diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index ab360c4..7a21869 100644 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -52,6 +52,7 @@ #include #include +#include #include #define T1 "write data before unlink\n" @@ -60,23 +61,27 @@ char msg[] = "yabba dabba doo, I'm coming for you, I live in a shoe, I don't kno char *buf, *buf_align; int bufsize = 0; sem_t sem; -#define ALIGN 65535 +#define ALIGN_LEN 65535 char usage[] = -"Usage: %s filename command-sequence\n" +"Usage: %s filename command-sequence [path...]\n" " command-sequence items:\n" " c close\n" +" B[num] call setstripe ioctl to create stripes\n" " C[num] create with optional stripes\n" " d mkdir\n" " D open(O_DIRECTORY)\n" " f statfs\n" +" F print FID\n" " G gid get grouplock\n" " g gid put grouplock\n" -" L link\n" -" l symlink\n" +" K link path to filename\n" +" L link filename to path\n" +" l symlink filename to path\n" " m mknod\n" " M rw mmap to EOF (must open and stat prior)\n" -" N rename\n" +" n rename path to filename\n" +" N rename filename to path\n" " o open(O_RDONLY)\n" " O open(O_CREAT|O_RDWR)\n" " r[num] read [optional length]\n" @@ -88,6 +93,7 @@ char usage[] = " u unlink\n" " U munmap\n" " v verbose\n" +" V open a volatile file\n" " w[num] write optional length\n" " W write entire mmap-ed region\n" " y fsync\n" @@ -122,27 +128,28 @@ pop_arg(int argc, char *argv[]) } struct flag_mapping { - const char *string; - const int flag; + const char *string; + const int flag; } flag_table[] = { - {"O_RDONLY", O_RDONLY}, - {"O_WRONLY", O_WRONLY}, - {"O_RDWR", O_RDWR}, - {"O_CREAT", O_CREAT}, - {"O_EXCL", O_EXCL}, - {"O_NOCTTY", O_NOCTTY}, - {"O_TRUNC", O_TRUNC}, - {"O_APPEND", O_APPEND}, - {"O_NONBLOCK", O_NONBLOCK}, - {"O_NDELAY", O_NDELAY}, - {"O_SYNC", O_SYNC}, + {"O_RDONLY", O_RDONLY}, + {"O_WRONLY", O_WRONLY}, + {"O_RDWR", O_RDWR}, + {"O_CREAT", O_CREAT}, + {"O_EXCL", O_EXCL}, + {"O_NOCTTY", O_NOCTTY}, + {"O_TRUNC", O_TRUNC}, + {"O_APPEND", O_APPEND}, + {"O_NONBLOCK", O_NONBLOCK}, + {"O_NDELAY", O_NDELAY}, + {"O_SYNC", O_SYNC}, #ifdef O_DIRECT - {"O_DIRECT", O_DIRECT}, + {"O_DIRECT", O_DIRECT}, #endif - {"O_LARGEFILE", O_LARGEFILE}, - {"O_DIRECTORY", O_DIRECTORY}, - {"O_NOFOLLOW", O_NOFOLLOW}, - {"", -1} + {"O_LARGEFILE", O_LARGEFILE}, + {"O_DIRECTORY", O_DIRECTORY}, + {"O_NOFOLLOW", O_NOFOLLOW}, + {"O_LOV_DELAY_CREATE", O_LOV_DELAY_CREATE}, + {"", -1} }; int get_flags(char *data, int *rflags) @@ -188,18 +195,21 @@ int get_flags(char *data, int *rflags) int main(int argc, char **argv) { - char *fname, *commands; - const char *newfile; - struct stat st; - struct statfs stfs; - size_t mmap_len = 0, i; - unsigned char *mmap_ptr = NULL, junk = 0; - int rc, len, fd = -1; - int flags; - int save_errno; - int verbose = 0; - int gid = 0; - struct timespec ts; + char *fname, *commands; + const char *newfile; + const char *oldpath; + struct stat st; + struct statfs stfs; + size_t mmap_len = 0, i; + unsigned char *mmap_ptr = NULL, junk = 0; + int rc, len, fd = -1; + int flags; + int save_errno; + int verbose = 0; + int gid = 0; + lustre_fid fid; + struct timespec ts; + struct lov_user_md_v3 lum; if (argc < 3) { fprintf(stderr, usage, argv[0]); @@ -236,6 +246,18 @@ int main(int argc, char **argv) } fd = -1; break; + case 'B': + lum = (struct lov_user_md_v3) { + .lmm_magic = LOV_USER_MAGIC_V3, + .lmm_stripe_count = atoi(commands + 1), + }; + + if (ioctl(fd, LL_IOC_LOV_SETSTRIPE, &lum) < 0) { + save_errno = errno; + perror("LL_IOC_LOV_SETSTRIPE"); + exit(save_errno); + } + break; case 'C': len = atoi(commands+1); fd = llapi_file_open(fname, O_CREAT | O_WRONLY, 0644, @@ -268,6 +290,18 @@ int main(int argc, char **argv) exit(save_errno); } break; + case 'F': + if (fd == -1) + rc = llapi_path2fid(fname, &fid); + else + rc = llapi_fd2fid(fd, &fid); + if (rc != 0) + fprintf(stderr, + "llapi_path/fd2fid() on %d, rc=%d\n", + fd, rc); + else + printf(DFID"\n", PFID(&fid)); + break; case 'G': gid = atoi(commands+1); if (ioctl(fd, LL_IOC_GROUP_LOCK, gid) == -1) { @@ -284,6 +318,17 @@ int main(int argc, char **argv) exit(save_errno); } break; + case 'K': + oldpath = POP_ARG(); + if (oldpath == NULL) + oldpath = fname; + + if (link(oldpath, fname)) { + save_errno = errno; + perror("link()"); + exit(save_errno); + } + break; case 'l': newfile = POP_ARG(); if (!newfile) @@ -294,16 +339,17 @@ int main(int argc, char **argv) exit(save_errno); } break; - case 'L': - newfile = POP_ARG(); - if (!newfile) - newfile = fname; - if (link(fname, newfile)) { - save_errno = errno; - perror("symlink()"); - exit(save_errno); - } - break; + case 'L': + newfile = POP_ARG(); + if (newfile == NULL) + newfile = fname; + + if (link(fname, newfile)) { + save_errno = errno; + perror("link()"); + exit(save_errno); + } + break; case 'm': if (mknod(fname, S_IFREG | 0644, 0) == -1) { save_errno = errno; @@ -326,6 +372,17 @@ int main(int argc, char **argv) exit(save_errno); } break; + case 'n': + oldpath = POP_ARG(); + if (oldpath == NULL) + oldpath = fname; + + if (rename(oldpath, fname) < 0) { + save_errno = errno; + perror("rename()"); + exit(save_errno); + } + break; case 'N': newfile = POP_ARG(); if (!newfile) @@ -357,39 +414,39 @@ int main(int argc, char **argv) exit(save_errno); } break; - case 'r': - len = atoi(commands+1); - if (len <= 0) - len = 1; - if (bufsize < len) { - buf = realloc(buf, len + ALIGN); - if (buf == NULL) { - save_errno = errno; - perror("allocating buf for read\n"); - exit(save_errno); - } - bufsize = len; - buf_align = (char *)((long)(buf + ALIGN) & - ~ALIGN); - } - while (len > 0) { - rc = read(fd, buf_align, len); - if (rc == -1) { - save_errno = errno; - perror("read"); - exit(save_errno); - } + case 'r': + len = atoi(commands+1); + if (len <= 0) + len = 1; + if (bufsize < len) { + buf = realloc(buf, len + ALIGN_LEN); + if (buf == NULL) { + save_errno = errno; + perror("allocating buf for read\n"); + exit(save_errno); + } + bufsize = len; + buf_align = (char *)((long)(buf + ALIGN_LEN) & + ~ALIGN_LEN); + } + while (len > 0) { + rc = read(fd, buf_align, len); + if (rc == -1) { + save_errno = errno; + perror("read"); + exit(save_errno); + } if (rc < len) { fprintf(stderr, "short read: %u/%u\n", rc, len); if (rc == 0) exit(ENODATA); } - len -= rc; - if (verbose >= 2) - printf("%.*s\n", rc, buf_align); - } - break; + len -= rc; + if (verbose >= 2) + printf("%.*s\n", rc, buf_align); + } + break; case 'R': for (i = 0; i < mmap_len && mmap_ptr; i += 4096) junk += mmap_ptr[i]; @@ -441,35 +498,44 @@ int main(int argc, char **argv) case 'v': verbose++; break; - case 'w': - len = atoi(commands+1); - if (len <= 0) - len = 1; - if (bufsize < len) { - buf = realloc(buf, len + ALIGN); - if (buf == NULL) { - save_errno = errno; - perror("allocating buf for write\n"); - exit(save_errno); - } - bufsize = len; - buf_align = (char *)((long)(buf + ALIGN) & - ~ALIGN); - strncpy(buf_align, msg, bufsize); - } - while (len > 0) { - rc = write(fd, buf_align, len); - if (rc == -1) { - save_errno = errno; - perror("write"); - exit(save_errno); - } - if (rc < len) - fprintf(stderr, "short write: %u/%u\n", - rc, len); - len -= rc; - } - break; + case 'V': + len = get_flags(commands + 1, &flags); + commands += len; + fd = llapi_create_volatile(fname, flags); + if (fd < 0) { + perror("llapi_create_volatile"); + exit(fd); + } + break; + case 'w': + len = atoi(commands+1); + if (len <= 0) + len = 1; + if (bufsize < len) { + buf = realloc(buf, len + ALIGN_LEN); + if (buf == NULL) { + save_errno = errno; + perror("allocating buf for write\n"); + exit(save_errno); + } + bufsize = len; + buf_align = (char *)((long)(buf + ALIGN_LEN) & + ~ALIGN_LEN); + strncpy(buf_align, msg, bufsize); + } + while (len > 0) { + rc = write(fd, buf_align, len); + if (rc == -1) { + save_errno = errno; + perror("write"); + exit(save_errno); + } + if (rc < len) + fprintf(stderr, "short write: %u/%u\n", + rc, len); + len -= rc; + } + break; case 'W': for (i = 0; i < mmap_len && mmap_ptr; i += 4096) mmap_ptr[i] += junk++; @@ -495,6 +561,7 @@ int main(int argc, char **argv) exit(save_errno); } break; + case '-': case '0': case '1': case '2':