From d01e488b626eefd067b5ec9b1b9a99fd55a9f894 Mon Sep 17 00:00:00 2001 From: adilger Date: Tue, 29 Oct 2002 09:59:33 +0000 Subject: [PATCH] Allow a count for lctl "destroy" to allow easy destroying of a sequence of objects created by "create". --- lustre/utils/lctl.c | 4 ++-- lustre/utils/obd.c | 50 ++++++++++++++++++++++++++++++++++++++++++-------- lustre/utils/obdctl.c | 2 +- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index c06ecb4..cd7be22 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -153,8 +153,8 @@ command_t cmdlist[] = { "create OST objects (with )\n" "usage: create [num [mode [verbose]]]"}, {"destroy", jt_obd_destroy, 0, - "destroy OST object \n" - "usage: destroy "}, + "destroy OST object [num [verbose]]\n" + "usage: destroy objects, starting at objid "}, {"test_getattr", jt_obd_test_getattr, 0, "do getattrs (on OST object (objid+1 on each thread))\n" "usage: test_getattr [verbose [[t]objid]]"}, diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index d3fdb58..4919992 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -878,25 +878,59 @@ int jt_obd_setattr(int argc, char **argv) int jt_obd_destroy(int argc, char **argv) { struct obd_ioctl_data data; + struct timeval next_time; + __u64 count = 1, next_count; + int verbose = 1; + __u64 id; char *end; - int rc; + int rc = 0, i; IOCINIT(data); - if (argc != 2) + if (argc < 2 || argc > 4) return CMD_HELP; - data.ioc_obdo1.o_id = strtoull(argv[1], &end, 0); + id = strtoull(argv[1], &end, 0); if (*end) { fprintf(stderr, "error: %s: invalid objid '%s'\n", cmdname(argv[0]), argv[1]); return CMD_HELP; } - data.ioc_obdo1.o_mode = S_IFREG | 0644; + if (argc > 2) { + count = strtoull(argv[2], &end, 0); + if (*end) { + fprintf(stderr, + "error: %s: invalid iteration count '%s'\n", + cmdname(argv[0]), argv[2]); + return CMD_HELP; + } + } - rc = ioctl(fd, OBD_IOC_DESTROY, &data); - if (rc < 0) - fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]), - strerror(rc = errno)); + if (argc > 3) { + verbose = get_verbose(argv[0], argv[3]); + if (verbose == BAD_VERBOSE) + return CMD_HELP; + } + + printf("%s: "LPD64" objects\n", cmdname(argv[0]), count); + gettimeofday(&next_time, NULL); + next_time.tv_sec -= verbose; + + for (i = 1, next_count = verbose; i <= count; i++, id++) { + data.ioc_obdo1.o_id = id; + data.ioc_obdo1.o_mode = S_IFREG | 0644; + + rc = ioctl(fd, OBD_IOC_DESTROY, &data); + SHMEM_BUMP(); + if (rc < 0) { + fprintf(stderr, "error: %s: objid "LPX64": %s\n", + cmdname(argv[0]), id, strerror(rc = errno)); + break; + } + + if (be_verbose(verbose, &next_time, i, &next_count, count)) + printf("%s: #%d is object id 0x%Lx\n", cmdname(argv[0]), + i, (long long)data.ioc_obdo1.o_id); + } return rc; } diff --git a/lustre/utils/obdctl.c b/lustre/utils/obdctl.c index b34504d..4e934f9 100644 --- a/lustre/utils/obdctl.c +++ b/lustre/utils/obdctl.c @@ -65,7 +65,7 @@ command_t cmdlist[] = { /* Session operations */ {"create", jt_obd_create, 0, "create [count [mode [verbose]]]"}, - {"destroy", jt_obd_destroy, 0, "destroy "}, + {"destroy", jt_obd_destroy, 0, "destroy [count [verbose]]"}, {"getattr", jt_obd_getattr, 0, "getattr "}, {"setattr", jt_obd_setattr, 0, "setattr "}, {"newconn", jt_obd_newconn, 0, "newconn [newuuid]"}, -- 1.8.3.1