* Author: Robert Read <rread@clusterfs.com>
*/
-#include <stdlib.h>
#include <sys/ioctl.h>
-#include <fcntl.h>
#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/types.h>
+#include <sys/un.h>
#include <sys/wait.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <signal.h>
+
#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
#include <glob.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
#include "obdctl.h"
#include <obd.h> /* for struct lov_stripe_md */
#include <lustre/lustre_build_version.h>
-#include <unistd.h>
-#include <sys/un.h>
-#include <time.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <string.h>
-
#include <obd_class.h>
#include <lnet/lnetctl.h>
#include <libcfs/libcfsutil.h>
-#include <stdio.h>
#include <lustre/liblustreapi.h>
#define MAX_STRING_SIZE 128
#define DEVICES_LIST "/proc/fs/lustre/devices"
-#if HAVE_PTHREAD
+#if HAVE_LIBPTHREAD
#include <sys/ipc.h>
#include <sys/shm.h>
#include <pthread.h>
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)
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;
{
char *filename;
int rc, fd;
- __u64 ino;
+ struct lu_fid fid;
if (argc != 2)
return CMD_HELP;
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;
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);
}
}