From 84aeabb1f0051989d5d7cc16db5743510cb77e62 Mon Sep 17 00:00:00 2001 From: pschwan Date: Fri, 27 Dec 2002 05:41:46 +0000 Subject: [PATCH] - show the useful cookie instead of the useless addr in ldlm_lock_dump - return ENOENT instead of crash in mds_getattr_name - teach statmany how to do pure lookup ioctls, as well as stats and EAs --- lustre/tests/statmany.c | 122 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 106 insertions(+), 16 deletions(-) diff --git a/lustre/tests/statmany.c b/lustre/tests/statmany.c index 6d70e10..e17e2e3 100644 --- a/lustre/tests/statmany.c +++ b/lustre/tests/statmany.c @@ -7,27 +7,50 @@ #include #include #include +#include + +#if 0 +#include +#endif +#include +#include + +static int usage(char *name) +{ + printf("Usage: %s <-s|-e|-l> filenamebase file_count iterations\n" + "-s : regular stat() calls\n" + "-e : open then GET_EA ioctl\n" + "-l : lookup ioctl only\n", name); + exit(1); +} int main(int argc, char ** argv) { - int i, count, iter; + int i, count, iter, mode, offset; long int start, end, last, rc = 0; + char parent[4096], *t; - if (argc != 4) { - printf("Usage %s filenamebase file_count iterations\n", - argv[0]); - exit(1); - } + if (argc != 5) + usage(argv[0]); + + if (strcmp(argv[1], "-s") == 0) + mode = 's'; + else if (strcmp(argv[1], "-e") == 0) + mode = 'e'; + else if (strcmp(argv[1], "-l") == 0) + mode = 'l'; + else + usage(argv[0]); - if (strlen(argv[1]) > 4080) { + if (strlen(argv[2]) > 4080) { printf("name too long\n"); exit(1); } srand(time(0)); - count = strtoul(argv[2], NULL, 0); - iter = strtoul(argv[3], NULL, 0); + count = strtoul(argv[3], NULL, 0); + iter = strtoul(argv[4], NULL, 0); start = last = time(0); @@ -38,21 +61,88 @@ int main(int argc, char ** argv) end = -1UL >> 1; } + t = strrchr(argv[2], '/'); + if (t == NULL) { + strcpy(parent, "."); + offset = -1; + } else { + strncpy(parent, argv[2], t - argv[2]); + offset = t - argv[2] + 1; + } + for (i = 0; i < iter && last < end; i++) { - struct stat buf; char filename[4096]; - int tmp; + int tmp, fd; tmp = random() % count; - sprintf(filename, "%s-%d", argv[1], tmp); + sprintf(filename, "%s-%d", argv[2], tmp); + + switch(mode) { + case 'e': +#if 0 + fd = open(filename, O_RDWR|O_LARGEFILE); + if (fd < 0) { + printf("open(%s) error: %s\n", filename, + strerror(errno)); + break; + } + rc = ioctl(fd, EXTN_IOC_GETEA, NULL); + if (rc < 0) { + printf("ioctl(%s) error: %s\n", filename, + strerror(errno)); + break; + } + close(fd); + break; +#endif + case 's': { + struct stat buf; - rc = stat(filename, &buf); - if (rc) { - printf("stat(%s) error: %s\n", filename, - strerror(errno)); + rc = stat(filename, &buf); + if (rc < 0) { + printf("stat(%s) error: %s\n", filename, + strerror(errno)); + break; + } break; } + case 'l': { + struct obd_ioctl_data data; + char rawbuf[8192]; + char *buf = rawbuf; + int max = sizeof(rawbuf); + + fd = open(parent, O_RDONLY); + if (fd < 0) { + printf("open(%s) error: %s\n", filename, + strerror(errno)); + break; + } + + memset(&data, 0, sizeof(data)); + data.ioc_version = OBD_IOCTL_VERSION; + data.ioc_len = sizeof(data); + if (offset >= 0) + data.ioc_inlbuf1 = filename + offset; + else + data.ioc_inlbuf1 = filename; + data.ioc_inllen1 = strlen(data.ioc_inlbuf1) + 1; + if (obd_ioctl_pack(&data, &buf, max)) { + printf("ioctl_pack failed.\n"); + break; + } + + rc = ioctl(fd, IOC_MDC_LOOKUP, buf); + if (rc < 0) { + printf("ioctl(%s) error: %s\n", filename, + strerror(errno)); + break; + } + close(fd); + break; + } + } if ((i % 10000) == 0) { printf(" - stat %d (time %ld ; total %ld ; last %ld)\n", i, time(0), time(0) - start, time(0) - last); -- 1.8.3.1