X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fobd.c;h=4f104041e71658c53160b4330b9ffdb7ed853062;hp=77e16a4d481d84ceb08aced82830ae29d9674b64;hb=9b62cf1f91bf50eaf5e1ef63024b2b6f78f28794;hpb=6e3ec5812ebd1b5ecf7cae584f429b013ffe7431 diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 77e16a4..4f10404 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -26,7 +26,7 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. */ /* @@ -41,35 +41,35 @@ * Author: Robert Read */ -#include #include -#include #include +#include +#include #include +#include #include -#include -#include -#include -#include + #include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include "obdctl.h" #include /* for struct lov_stripe_md */ #include -#include -#include -#include -#include -#include -#include - #include #include #include -#include #include #define MAX_STRING_SIZE 128 @@ -207,7 +207,7 @@ char *obdo_print(struct obdo *obd) "\nctime: "LPU64"\nsize: "LPU64"\nblocks: "LPU64 "\nblksize: %u\nmode: %o\nuid: %d\ngid: %d\nflags: %x\n" "misc: %x\nnlink: %d,\nvalid "LPX64"\n", - obd->o_id, obd->o_gr, obd->o_atime, obd->o_mtime, obd->o_ctime, + obd->o_id, obd->o_seq, obd->o_atime, obd->o_mtime, obd->o_ctime, obd->o_size, obd->o_blocks, obd->o_blksize, obd->o_mode, obd->o_uid, obd->o_gid, obd->o_flags, obd->o_misc, obd->o_nlink, obd->o_valid); @@ -486,17 +486,18 @@ static inline void shmem_reset(int total_threads) static inline void shmem_bump(void) { - static int bumped_running; + static bool running_not_bumped = true; if (shared_data == NULL || thread <= 0 || thread > MAX_THREADS) return; shmem_lock(); shared_data->counters[thread - 1]++; - if (!bumped_running) + if (running_not_bumped) { shared_data->running++; + running_not_bumped = false; + } shmem_unlock(); - bumped_running = 1; } static void shmem_snap(int total_threads, int live_threads) @@ -533,8 +534,7 @@ static void shmem_snap(int total_threads, int live_threads) (prev_time.tv_sec + prev_time.tv_usec / 1000000.0); if (prev_valid && - live_threads == total_threads && - secs > 0.0) /* someone screwed with the time? */ + secs > 1.0) /* someone screwed with the time? */ printf("%d/%d Total: %f/second\n", non_zero, total_threads, total / secs); memcpy(counter_snapshot[1], counter_snapshot[0], @@ -715,7 +715,7 @@ int jt_opt_threads(int argc, char **argv) thread = i; argv[2] = "--device"; - return jt_opt_device(argc - 2, argv + 2); + exit(jt_opt_device(argc - 2, argv + 2)); } else if (be_verbose(verbose, NULL, i, &next_thread, threads)) printf("%s: thread #%d (PID %d) started\n", argv[0], i, rc); @@ -901,25 +901,18 @@ int jt_obd_abort_recovery(int argc, char **argv) int jt_get_version(int argc, char **argv) { int rc; - char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; - struct obd_ioctl_data *data = (struct obd_ioctl_data *)buf; + char rawbuf[MAX_IOC_BUFLEN]; + char *version; if (argc != 1) return CMD_HELP; - memset(buf, 0, sizeof(rawbuf)); - data->ioc_version = OBD_IOCTL_VERSION; - data->ioc_inllen1 = sizeof(rawbuf) - cfs_size_round(sizeof(*data)); - data->ioc_inlbuf1 = buf + cfs_size_round(sizeof(*data)); - data->ioc_len = obd_ioctl_packlen(data); - - rc = l2_ioctl(OBD_DEV_ID, OBD_GET_VERSION, buf); - if (rc < 0) + rc = llapi_get_version(rawbuf, MAX_IOC_BUFLEN, &version); + if (rc) fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]), - strerror(rc = errno)); - else { - printf("Lustre version: %s\n", data->ioc_bulk); - } + strerror(-rc)); + else + printf("Lustre version: %s\n", version); printf("lctl version: %s\n", BUILD_VERSION); return rc; @@ -1090,9 +1083,9 @@ int jt_obd_create(int argc, char **argv) return CMD_HELP; } - if (argc < 5) + if (argc < 5) { reset_lsmb (&lsm_buffer); /* will set default */ - else { + } else { rc = parse_lsm (&lsm_buffer, argv[4]); if (rc != 0) { fprintf(stderr, "error: %s: invalid lsm '%s'\n", @@ -1636,7 +1629,7 @@ int jt_obd_test_brw(int argc, char **argv) obj_idx = (thread - 1)/nthr_per_obj; objid += obj_idx; stride *= nthr_per_obj; - if (thread == 1) + if ((thread - 1) % nthr_per_obj == 0) shared_data->offsets[obj_idx] = stride + thr_offset; thr_offset += ((thread - 1) % nthr_per_obj) * len; } else { @@ -2463,7 +2456,7 @@ int jt_blockdev_info(int argc, char **argv) { char *filename; int rc, fd; - __u64 ino; + struct lu_fid fid; if (argc != 2) return CMD_HELP; @@ -2476,17 +2469,17 @@ int jt_blockdev_info(int argc, char **argv) return CMD_HELP; } - rc = ioctl(fd, LL_IOC_LLOOP_INFO, &ino); + rc = ioctl(fd, LL_IOC_LLOOP_INFO, &fid); if (rc < 0) { rc = errno; fprintf(stderr, "error: %s\n", strerror(errno)); goto out; } fprintf(stdout, "lloop device info: "); - if (ino == 0ULL) + if (fid_is_zero(&fid)) fprintf(stdout, "Not attached\n"); else - fprintf(stdout, "attached to inode "LPU64"\n", ino); + fprintf(stdout, "attached to inode "DFID"\n", PFID(&fid)); out: close(fd); return -rc; @@ -3091,7 +3084,7 @@ int jt_get_obj_version(int argc, char **argv) } obd_ioctl_unpack(&data, buf, sizeof rawbuf); - printf("0x%llx\n", version); + printf(LPX64"\n", version); return 0; } @@ -3115,12 +3108,12 @@ void llapi_ping_target(char *obd_type, char *obd_name, if (rc) rc = errno; if (rc == ENOTCONN || rc == ESHUTDOWN) { - printf("%s inactive.\n", obd_name); + printf("%s: INACTIVE\n", obd_name); } else if (rc) { - fprintf(stderr, "error: check '%s' %s\n", + printf("%s: check error: %s\n", obd_name, strerror(errno)); } else { - printf("%s active.\n", obd_name); + printf("%s: active\n", obd_name); } }