From 363b924cc74d3748e2cd4646c2f92297bd97e9dd Mon Sep 17 00:00:00 2001 From: bobijam Date: Wed, 13 Feb 2008 01:55:24 +0000 Subject: [PATCH] Branch b1_6 b=13173 i=shadow make "lctl lov_getconfig" handle the case which "default_stripe_count == -1" by returning -1 instead of 65535. --- lustre/tests/sanity.sh | 2 +- lustre/utils/obd.c | 65 ++++++++++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 6dd97c5..a26a76e 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1836,7 +1836,7 @@ test_44a() { [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \ awk '{print $2}'` - if [ $nstripe -eq 0 ] ; then + if [ $nstripe -eq 0 -o $nstripe -eq -1 ] ; then nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'` fi diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index e0bca93..387897e 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -181,11 +181,11 @@ int lcfg_mgs_ioctl(char *func, int dev_id, struct lustre_cfg *lcfg) rc = l_ioctl(dev_id, OBD_IOC_PARAM, buf); - if (rc == ENODEV) + if (rc == ENODEV) fprintf(stderr, "Is the MGS running on this node?\n"); - if (rc == ENOSYS) + if (rc == ENOSYS) fprintf(stderr, "Make sure cfg_device is set first.\n"); - if (rc == EINVAL) + if (rc == EINVAL) fprintf(stderr, "cfg_device should be of the form " "'lustre-MDT0000'\n"); @@ -245,7 +245,7 @@ int parse_devname(char *func, char *name) if (isdigit(name[0])) { ret = strtoul(name, NULL, 0); } else { - if (name[0] == '$' || name[0] == '%') + if (name[0] == '$' || name[0] == '%') name++; rc = do_name2dev(func, name); if (rc >= N2D_OFF) { @@ -443,12 +443,12 @@ static void shmem_setup(void) } static inline void shmem_lock(void) -{ +{ l_mutex_lock(&shared_data->mutex); } static inline void shmem_unlock(void) -{ +{ l_mutex_unlock(&shared_data->mutex); } @@ -513,7 +513,7 @@ static void shmem_snap(int total_threads, int live_threads) secs = (this_time.tv_sec + this_time.tv_usec / 1000000.0) - (prev_time.tv_sec + prev_time.tv_usec / 1000000.0); - if (prev_valid && + if (prev_valid && live_threads == total_threads && secs > 0.0) /* someone screwed with the time? */ printf("%d/%d Total: %f/second\n", non_zero, total_threads, total / secs); @@ -521,16 +521,16 @@ static void shmem_snap(int total_threads, int live_threads) memcpy(counter_snapshot[1], counter_snapshot[0], total_threads * sizeof(counter_snapshot[0][0])); prev_time = this_time; - if (!prev_valid && + if (!prev_valid && running == total_threads) prev_valid = 1; } -static void shmem_stop(void) +static void shmem_stop(void) { if (shared_data == NULL) return; - + shared_data->stop = 1; } @@ -577,7 +577,7 @@ static int do_device(char *func, char *devname) int dev; dev = parse_devname(func, devname); - if (dev < 0) + if (dev < 0) return -1; lcfg_set_devname(devname); @@ -596,7 +596,7 @@ int jt_obd_device(int argc, char **argv) if (argc > 2) return CMD_HELP; - + if (argc == 1) { printf("current device is %d - %s\n", cur_device, lcfg_get_devname() ? : "not set"); @@ -604,7 +604,7 @@ int jt_obd_device(int argc, char **argv) } rc = do_device("device", argv[1]); return rc; -} +} int jt_opt_device(int argc, char **argv) { @@ -671,11 +671,11 @@ int jt_opt_threads(int argc, char **argv) for (i = 5; i < argc; i++) snprintf(cmdstr + strlen(cmdstr), sizeof(cmdstr), " %s", argv[i]); - + printf("%s: starting %ld threads on device %s running %s\n", argv[0], threads, argv[3], cmdstr); } - + shmem_reset(threads); sigemptyset(&sigset); @@ -684,7 +684,7 @@ int jt_opt_threads(int argc, char **argv) sigprocmask(SIG_BLOCK, &sigset, &saveset); nthreads = threads; - + for (i = 1, next_thread = verbose; i <= threads; i++) { rc = fork(); if (rc < 0) { @@ -710,7 +710,7 @@ int jt_opt_threads(int argc, char **argv) sigemptyset(&sigact.sa_mask); sigact.sa_handler = parent_sighandler; sigact.sa_flags = 0; - + sigaction(SIGALRM, &sigact, &saveact1); sigaction(SIGCHLD, &sigact, &saveact2); @@ -728,7 +728,7 @@ int jt_opt_threads(int argc, char **argv) ret = waitpid(0, &status, WNOHANG); if (ret == 0) break; - + if (ret < 0) { fprintf(stderr, "error: %s: wait - %s\n", argv[0], strerror(errno)); @@ -906,10 +906,10 @@ int jt_obd_list_ioctl(int argc, char **argv) printf("%s\n", (char *)data->ioc_bulk); } if (rc != 0) { - if (errno == ENOENT) + if (errno == ENOENT) /* no device or the last device */ rc = 0; - else + else fprintf(stderr, "Error getting device list: %s: " "check dmesg.\n", strerror(errno)); @@ -948,7 +948,7 @@ int jt_obd_list(int argc, char **argv) * object ids. Use get_stripe on this node to print full lsm and * set_stripe on another node to cut/paste between nodes. */ -/* create [] [q|v|# verbosity] [striping] */ +/* create [] [q|v|# verbosity] [striping] */ int jt_obd_create(int argc, char **argv) { struct obd_ioctl_data data; @@ -1340,7 +1340,7 @@ int jt_obd_test_getattr(int argc, char **argv) mode verbosity blocksize - <[[]t(inc obj by thread#)]obj> object + <[[]t(inc obj by thread#)]obj> object [p|g] batch */ int jt_obd_test_brw(int argc, char **argv) { @@ -1537,7 +1537,7 @@ int jt_obd_test_brw(int argc, char **argv) (int)(pages * getpagesize())); shmem_unlock (); } - + if (!repeat_offset) { #ifdef MAX_THREADS if (stride == len) { @@ -1652,8 +1652,11 @@ repeat: rc = -EINVAL; goto out; } - printf("default_stripe_count: %u\n", - desc.ld_default_stripe_count); + if (desc.ld_default_stripe_count == (__u16)-1) + printf("default_stripe_count: %d\n", -1); + else + printf("default_stripe_count: %u\n", + desc.ld_default_stripe_count); printf("default_stripe_size: "LPU64"\n", desc.ld_default_stripe_size); printf("default_stripe_offset: "LPU64"\n", @@ -1881,7 +1884,7 @@ int jt_llog_info(int argc, char **argv) IOC_INIT(data); data.ioc_inllen1 = strlen(argv[1]) + 1; data.ioc_inlbuf1 = argv[1]; - data.ioc_inllen2 = max - size_round(sizeof(data)) - + data.ioc_inllen2 = max - size_round(sizeof(data)) - size_round(data.ioc_inllen1); IOC_PACK(argv[0], data); @@ -2030,9 +2033,9 @@ int jt_llog_remove(int argc, char **argv) } /* attach a regular file to virtual block device. - * return vaule: + * return vaule: * -1: fatal error - * 1: error, it always means the command run failed + * 1: error, it always means the command run failed * 0: success */ static int jt_blockdev_run_process(const char *file, char *argv[]) @@ -2145,7 +2148,7 @@ int jt_blockdev_attach(int argc, char **argv) if (rc == 0 && (!S_ISBLK(st.st_mode) || st.st_rdev != dev)) { rc = EEXIST; } else if (rc < 0) { - if (errno == ENOENT && + if (errno == ENOENT && !mknod(devname, S_IFBLK|S_IRUSR|S_IWUSR, dev)) rc = 0; else @@ -2177,7 +2180,7 @@ int jt_blockdev_detach(int argc, char **argv) filename = argv[1]; fd = open(filename, O_RDONLY); if (fd < 0) { - fprintf(stderr, "cannot open file %s error %s\n", + fprintf(stderr, "cannot open file %s error %s\n", filename, strerror(errno)); return CMD_HELP; } @@ -2206,7 +2209,7 @@ int jt_blockdev_info(int argc, char **argv) filename = argv[1]; fd = open(filename, O_RDONLY); if (fd < 0) { - fprintf(stderr, "cannot open file %s error: %s\n", + fprintf(stderr, "cannot open file %s error: %s\n", filename, strerror(errno)); return CMD_HELP; } -- 1.8.3.1