(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],
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);
memset(buf, 0, sizeof(rawbuf));
data->ioc_version = OBD_IOCTL_VERSION;
- data->ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(*data));
- data->ioc_inlbuf1 = buf + size_round(sizeof(*data));
+ 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);
goto fail;
got_one:
- fgets(buf, sizeof(buf), fp);
+ /* should not ignore fgets(3)'s return value */
+ if (!fgets(buf, sizeof(buf), fp)) {
+ fprintf(stderr, "reading from %s: %s", buf, strerror(errno));
+ fclose(fp);
+ return;
+ }
fclose(fp);
/* trim trailing newlines */
for (index = 0;; index++) {
memset(buf, 0, sizeof(rawbuf));
data->ioc_version = OBD_IOCTL_VERSION;
- data->ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(*data));
- data->ioc_inlbuf1 = buf + size_round(sizeof(*data));
+ 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);
data->ioc_count = index;
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 {
l_cond_broadcast(&shared_data->cond);
else
l_cond_wait(&shared_data->cond,
- &shared_data->mutex);
+ &shared_data->mutex);
shmem_unlock ();
}
memset(&data, 0x00, sizeof(data));
data.ioc_dev = cur_device;
- data.ioc_inllen1 = sizeof(rawbuf) - size_round(sizeof(data));
+ data.ioc_inllen1 = sizeof(rawbuf) - cfs_size_round(sizeof(data));
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_dev = cur_device;
data.ioc_inllen1 = strlen(argv[1]) + 1;
data.ioc_inlbuf1 = argv[1];
- data.ioc_inllen2 = sizeof(rawbuf) - size_round(sizeof(data)) -
- size_round(data.ioc_inllen1);
+ data.ioc_inllen2 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
+ cfs_size_round(data.ioc_inllen1);
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_inllen3 = strlen(to) + 1;
data.ioc_inlbuf3 = to;
}
- data.ioc_inllen4 = sizeof(rawbuf) - size_round(sizeof(data)) -
- size_round(data.ioc_inllen1) -
- size_round(data.ioc_inllen2) -
- size_round(data.ioc_inllen3);
+ data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
+ cfs_size_round(data.ioc_inllen1) -
+ cfs_size_round(data.ioc_inllen2) -
+ cfs_size_round(data.ioc_inllen3);
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
data.ioc_inllen3 = strlen(to) + 1;
data.ioc_inlbuf3 = to;
}
- data.ioc_inllen4 = sizeof(rawbuf) - size_round(sizeof(data)) -
- size_round(data.ioc_inllen1) -
- size_round(data.ioc_inllen2) -
- size_round(data.ioc_inllen3);
+ data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
+ cfs_size_round(data.ioc_inllen1) -
+ cfs_size_round(data.ioc_inllen2) -
+ cfs_size_round(data.ioc_inllen3);
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
do_disconnect(argv[0], 1);
}
-static int find_target_obdpath(char *fsname, char *path)
-{
- glob_t glob_info;
- char pattern[PATH_MAX + 1];
- int rc;
-
- snprintf(pattern, PATH_MAX,
- "/proc/fs/lustre/lov/%s-*/target_obd",
- fsname);
- rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
- if (rc == GLOB_NOMATCH)
- return -ENODEV;
- else if (rc)
- return -EINVAL;
-
- strcpy(path, glob_info.gl_pathv[0]);
- globfree(&glob_info);
- return 0;
-}
-
-static int find_poolpath(char *fsname, char *poolname, char *poolpath)
-{
- glob_t glob_info;
- char pattern[PATH_MAX + 1];
- int rc;
-
- snprintf(pattern, PATH_MAX,
- "/proc/fs/lustre/lov/%s-*/pools/%s",
- fsname, poolname);
- rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
- /* If no pools, make sure the lov is available */
- if ((rc == GLOB_NOMATCH) &&
- (find_target_obdpath(fsname, poolpath) == -ENODEV))
- return -ENODEV;
- if (rc)
- return -EINVAL;
-
- strcpy(poolpath, glob_info.gl_pathv[0]);
- globfree(&glob_info);
- return 0;
-}
-
-/*
- * if pool is NULL, search ostname in target_obd
- * if pool is no NULL
- * if pool not found returns errno < 0
- * if ostname is NULL, returns 1 if pool is not empty and 0 if pool empty
- * if ostname is not NULL, returns 1 if OST is in pool and 0 if not
- */
-int llapi_search_ost(char *fsname, char *poolname, char *ostname)
-{
- FILE *fd;
- char buffer[PATH_MAX + 1];
- int len = 0, rc;
-
- if (ostname != NULL)
- len = strlen(ostname);
-
- if (poolname == NULL)
- rc = find_target_obdpath(fsname, buffer);
- else
- rc = find_poolpath(fsname, poolname, buffer);
- if (rc)
- return rc;
-
- if ((fd = fopen(buffer, "r")) == NULL)
- return -EINVAL;
-
- while (fgets(buffer, sizeof(buffer), fd) != NULL) {
- if (poolname == NULL) {
- char *ptr;
- /* Search for an ostname in the list of OSTs
- Line format is IDX: fsname-OSTxxxx_UUID STATUS */
- ptr = strchr(buffer, ' ');
- if ((ptr != NULL) &&
- (strncmp(ptr + 1, ostname, len) == 0)) {
- fclose(fd);
- return 1;
- }
- } else {
- /* Search for an ostname in a pool,
- (or an existing non-empty pool if no ostname) */
- if ((ostname == NULL) ||
- (strncmp(buffer, ostname, len) == 0)) {
- fclose(fd);
- return 1;
- }
- }
- }
- fclose(fd);
- return 0;
-}
-
static int check_pool_cmd(enum lcfg_command_type cmd,
char *fsname, char *poolname,
char *ostname)
}
obd_ioctl_unpack(&data, buf, sizeof rawbuf);
- printf("0x%llx\n", version);
+ printf(LPX64"\n", version);
return 0;
}