+ } else if (be_verbose(verbose, &next_time, i,&next_count,count))
+ printf("%s: got attr #%d\n", cmdname(argv[0]), i);
+ }
+
+ if (!rc) {
+ struct timeval end;
+ double diff;
+
+ gettimeofday(&end, NULL);
+
+ diff = difftime(&end, &start);
+
+ --i;
+ printf("%s: %d attrs in %.4gs (%.4g attr/s): %s",
+ cmdname(argv[0]), i, diff, (double)i / diff,
+ ctime(&end.tv_sec));
+ }
+ return rc;
+}
+
+static int jt_test_brw(int argc, char **argv)
+{
+ struct obd_ioctl_data data;
+ struct timeval start, next_time;
+ char *bulk, *b;
+ int pages = 1, obdos = 1, count, next_count;
+ int verbose = 1, write = 0, rw;
+ int i, o, p;
+ int len;
+ int rc;
+
+ if (argc < 2 || argc > 6) {
+ fprintf(stderr,
+ "usage: %s count [write [verbose [pages [obdos]]]]\n",
+ cmdname(argv[0]));
+ return -1;
+ }
+
+ count = strtoul(argv[1], NULL, 0);
+
+ if (argc >= 3) {
+ if (argv[2][0] == 'w' || argv[2][0] == '1')
+ write = 1;
+ else if (argv[2][0] == 'r' || argv[2][0] == '0')
+ write = 0;
+
+ verbose = get_verbose(argv[3]);
+ }
+
+ if (argc >= 5)
+ pages = strtoul(argv[4], NULL, 0);
+ if (argc >= 6)
+ obdos = strtoul(argv[5], NULL, 0);
+
+ if (obdos != 1 && obdos != 2) {
+ fprintf(stderr, "error: %s: only 1 or 2 obdos supported\n",
+ cmdname(argv[0]));
+ return -2;
+ }
+
+ len = pages * PAGE_SIZE;
+
+ bulk = calloc(obdos, len);
+ if (!bulk) {
+ fprintf(stderr, "error: %s: no memory allocating %dx%d pages\n",
+ cmdname(argv[0]), obdos, pages);
+ return -2;
+ }
+ IOCINIT(data);
+ data.ioc_conn2 = connid;
+ data.ioc_obdo1.o_id = 2;
+ data.ioc_count = len;
+ data.ioc_offset = 0;
+ data.ioc_plen1 = len;
+ data.ioc_pbuf1 = bulk;
+ if (obdos > 1) {
+ data.ioc_obdo2.o_id = 2;
+ data.ioc_plen2 = len;
+ data.ioc_pbuf2 = bulk + len;
+ }
+
+ gettimeofday(&start, NULL);
+ next_time.tv_sec = start.tv_sec - verbose;
+ next_time.tv_usec = start.tv_usec;
+
+ printf("%s: %s %d (%dx%d pages) (testing only): %s",
+ cmdname(argv[0]), write ? "writing" : "reading",
+ count, obdos, pages, ctime(&start.tv_sec));
+
+ /*
+ * We will put in the start time (and loop count inside the loop)
+ * at the beginning of each page so that we will be able to validate
+ * (at some later time) whether the data actually made it or not.
+ */
+ for (o = 0, b = bulk; o < obdos; o++)
+ for (p = 0; p < pages; p++, b += PAGE_SIZE)
+ memcpy(b, &start, sizeof(start));
+
+ rw = write ? OBD_IOC_BRW_WRITE : OBD_IOC_BRW_READ;
+ for (i = 1, next_count = verbose; i <= count; i++) {
+ if (write) {
+ b = bulk + sizeof(struct timeval);
+ for (o = 0; o < obdos; o++)
+ for (p = 0; p < pages; p++, b += PAGE_SIZE)
+ memcpy(b, &count, sizeof(count));