Lines Matching +full:async +full:- +full:io
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 * doio - a general purpose io initiator with system call and
39 * For disk io, if the O_SSD flag is set doio will allocate
40 * the appropriate amount of ssd and do the transfer - thus, doio
41 * can handle all of the primitive types of file io.
45 * -----------
105 #define MEMF_FILE 01000 /* regular file -- unlink on close */
140 * Name-To-Value map
167 /* ---------------------------------------------------------------------------
172 * the syscall return checking, async I/O wait, iosw check, etc.
175 * WRITE, ASYNC, SSD/SDS,
182 int *aioid; /* list of async I/O structures */
214 #define PPID_CHECK_INTERVAL 5 /* check ppid every <-- iterations */
215 #define MAX_AIO 256 /* maximum number of async I/O ops */
217 #define MPP_BUMP 16 /* page un-alignment for MPP */
248 int V_opt = 0; /* over-ride default validation fd type */
257 int Upanic_Conditions; /* set by args to -U */
258 int Release_Interval; /* arg to -r */
259 int Nprocs; /* arg to -n */
260 char *Write_Log; /* arg to -w */
267 int Npes = 0; /* non-zero if built as an mpp multi-pe app */
268 int Vpe = -1; /* Virtual pe number if Npes >= 0 */
269 int Reqno = 1; /* request # - used in some error messages */
275 int delayop = 0; /* delay between operations - type of delay */
276 int delaytime = 0; /* delay between operations - how long */
284 #define SKIP_REQ -2 /* skip I/O request */
290 int Wfd_Append; /* for appending to the write-log */
291 int Wfd_Random; /* for overlaying write-log entries */
484 /* -C data-fill/check type */
491 /* -d option delay types */
546 * If this is a re-exec of doio, jump directly into the doio function. in main()
609 * to -1. in main()
614 Children[i] = -1; in main()
624 * child procs get cleaned up. If the -e option was used, we will also in main()
625 * re-exec. This is mostly for unicos/mk on mpp's, to ensure that not in main()
628 * Note - if Nprocs is 1, or this doio is a multi-pe app (Npes > 1), in main()
629 * jump directly to doio(). multi-pe apps can't fork(), and there is in main()
638 if ((pid = fork()) == -1) { in main()
654 sprintf(argv[0], "-%s", exec_path); in main()
675 if ((pid = wait(&stat)) == -1) { in main()
682 Children[i] = -1; in main()
684 Nprocs--; in main()
767 * Initialize the Pattern - write-type syscalls will replace Pattern[1] in doio()
777 Pattern_Length = sprintf(Pattern, "-:%d:%s:%s*", getpid(), Host, Prog); in doio()
780 Pattern_Length = sprintf(Pattern, "-:%d:%s:%s**", in doio()
785 * Open a couple of descriptors for the write-log file. One descriptor in doio()
788 * doing corruption detection based on a doio write-log. in doio()
795 if (wlog_open(&Wlog, 0, 0666) == -1) { in doio()
804 * Open the input stream - either a file or stdin in doio()
810 if ((infd = open(Infile, O_RDWR)) == -1) { in doio()
914 * Main loop - each doio proc does this until the read returns eof (0). in doio()
915 * Call the appropriate io function based on the request type. in doio()
930 alloc_mem(-1); in doio()
935 if (nbytes == -1) { in doio()
939 alloc_mem(-1); in doio()
947 alloc_mem(-1); in doio()
955 alloc_mem(-1); in doio()
967 sbrk(-1 * Memsize); in doio()
969 alloc_mem(-1); in doio()
974 ssbreak(-1 * btoc(Sdssize)); in doio()
1046 "Don't know how to handle io request type %d\n", in doio()
1048 alloc_mem(-1); in doio()
1055 alloc_mem(-1); in doio()
1077 alloc_mem(-1); in doio()
1121 * Format IO requests, returning a pointer to the formatted text.
1123 * format_strat - formats the async i/o completion strategy
1124 * format_rw - formats a read[a]/write[a] request
1125 * format_sds - formats a ssread/sswrite request
1126 * format_listio- formats a listio request
1128 * ioreq is the doio io request structure.
1169 {"unknown", -1},
1181 {"unknown", -1},
1286 struct read_req *readp = &ioreq->r_data.read; in format_rw()
1287 struct write_req *writep = &ioreq->r_data.write; in format_rw()
1288 struct read_req *readap = &ioreq->r_data.read; in format_rw()
1289 struct write_req *writeap = &ioreq->r_data.write; in format_rw()
1297 switch (ioreq->r_type) { in format_rw()
1300 fd, (unsigned long)buffer, readp->r_nbytes); in format_rw()
1303 " fd %d is file %s - open flags are %#o\n", in format_rw()
1304 fd, readp->r_file, readp->r_oflags); in format_rw()
1307 readp->r_offset); in format_rw()
1312 fd, (unsigned long)buffer, writep->r_nbytes); in format_rw()
1315 " fd %d is file %s - open flags are %#o\n", in format_rw()
1316 fd, writep->r_file, writep->r_oflags); in format_rw()
1319 " write done at file offset %d - pattern is %s\n", in format_rw()
1320 writep->r_offset, pattern); in format_rw()
1324 aio_strat = format_strat(readap->r_aio_strat); in format_rw()
1327 fd, (unsigned long)buffer, readap->r_nbytes, in format_rw()
1331 " fd %d is file %s - open flags are %#o\n", in format_rw()
1332 fd, readap->r_file, readp->r_oflags); in format_rw()
1335 readap->r_offset); in format_rw()
1338 " async io completion strategy is %s\n", in format_rw()
1343 aio_strat = format_strat(writeap->r_aio_strat); in format_rw()
1346 fd, (unsigned long)buffer, writeap->r_nbytes, in format_rw()
1350 " fd %d is file %s - open flags are %#o\n", in format_rw()
1351 fd, writeap->r_file, writeap->r_oflags); in format_rw()
1354 " writea done at file offset %d - pattern is %s\n", in format_rw()
1355 writeap->r_offset, pattern); in format_rw()
1358 " async io completion strategy is %s\n", in format_rw()
1374 struct ssread_req *ssreadp = &ioreq->r_data.ssread; in format_sds()
1375 struct sswrite_req *sswritep = &ioreq->r_data.sswrite; in format_sds()
1383 switch (ioreq->r_type) { in format_sds()
1386 buffer, sds, ssreadp->r_nbytes); in format_sds()
1392 "syscall: sswrite(%#o, %#o, %d) - pattern was %s\n", in format_sds()
1393 buffer, sds, sswritep->r_nbytes, pattern); in format_sds()
1417 * Initialize common fields - assumes r_oflags, r_file, r_offset, and in do_read()
1422 file = req->r_data.read.r_file; in do_read()
1423 oflags = req->r_data.read.r_oflags; in do_read()
1424 offset = req->r_data.read.r_offset; in do_read()
1425 nbytes = req->r_data.read.r_nbytes; in do_read()
1435 if ((fd = alloc_fd(file, oflags)) == -1) in do_read()
1436 return -1; in do_read()
1439 * Allocate core or sds - based on the O_SSD flag in do_read()
1448 if (alloc_sds(nbytes) == -1) in do_read()
1449 return -1; in do_read()
1462 * if io is not raw, bump the offset by a random amount in do_read()
1463 * to generate non-word-aligned io. in do_read()
1465 if (!(req->r_data.read.r_uflags & F_WORD_ALIGNED)) { in do_read()
1466 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_read()
1474 if ((rval = alloc_mem(nbytes + wtob(1) * 2 + fdc->c_memalign)) < 0) { in do_read()
1480 if ((req->r_data.read.r_uflags & F_WORD_ALIGNED)) { in do_read()
1484 if ((oflags & O_DIRECT) && ((long)addr % fdc->c_memalign != 0)) { in do_read()
1486 fdc->c_memalign - ((long)addr % fdc->c_memalign); in do_read()
1489 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_read()
1501 switch (req->r_type) { in do_read()
1504 if (lseek(fd, offset, SEEK_SET) == -1) { in do_read()
1508 return -1; in do_read()
1511 if ((rval = read(fd, addr, nbytes)) == -1) { in do_read()
1515 format_rw(req, fd, addr, -1, NULL, NULL)); in do_read()
1517 return -1; in do_read()
1520 "read() request returned wrong # of bytes - expected %d, got %d\n%s\n", in do_read()
1522 format_rw(req, fd, addr, -1, NULL, NULL)); in do_read()
1524 return -1; in do_read()
1531 * Async read in do_read()
1535 if (lseek(fd, offset, SEEK_SET) == -1) { in do_read()
1539 return -1; in do_read()
1542 aio_strat = req->r_data.read.r_aio_strat; in do_read()
1548 if (reada(fd, addr, nbytes, &aiop->iosw, signo) == -1) { in do_read()
1552 &aiop->iosw)); in do_read()
1555 rval = -1; in do_read()
1558 * Wait for io to complete in do_read()
1564 * make sure the io completed without error in do_read()
1567 if (aiop->iosw.sw_count != nbytes) { in do_read()
1571 aiop->iosw.sw_flag, in do_read()
1572 aiop->iosw.sw_error, in do_read()
1573 aiop->iosw.sw_count, in do_read()
1575 NULL, &aiop->iosw)); in do_read()
1578 rval = -1; in do_read()
1585 if (rval == -1) in do_read()
1600 static int pid = -1; in do_write()
1621 nbytes = req->r_data.write.r_nbytes; in do_write()
1622 offset = req->r_data.write.r_offset; in do_write()
1623 pattern = req->r_data.write.r_pattern; in do_write()
1624 file = req->r_data.write.r_file; in do_write()
1625 oflags = req->r_data.write.r_oflags; in do_write()
1637 * Get a descriptor to do the io on in do_write()
1640 if ((fd = alloc_fd(file, oflags)) == -1) in do_write()
1641 return -1; in do_write()
1660 if (alloc_sds(nbytes) == -1) in do_write()
1661 return -1; in do_write()
1663 if (sswrite((long)Memptr, Sdsptr, btoc(nbytes)) == -1) { in do_write()
1669 return -1; in do_write()
1677 return -1; in do_write()
1687 * if io is not raw, bump the offset by a random amount in do_write()
1688 * to generate non-word-aligned io. in do_write()
1691 if (!(req->r_data.write.r_uflags & F_WORD_ALIGNED)) { in do_write()
1692 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_write()
1704 if ((rval = alloc_mem(nbytes + wtob(1) * 2 + fdc->c_memalign)) < 0) { in do_write()
1710 if ((req->r_data.write.r_uflags & F_WORD_ALIGNED)) { in do_write()
1714 if ((oflags & O_DIRECT) && ((long)addr % fdc->c_memalign != 0)) { in do_write()
1716 fdc->c_memalign - ((long)addr % fdc->c_memalign); in do_write()
1719 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_write()
1739 rval = -1; in do_write()
1745 alloc_mem(-1); in do_write()
1753 * Write a preliminary write-log entry. This is done so that in do_write()
1756 * re-creates the file extents as if the write completed, but does not in do_write()
1757 * do any checking - see comments in doio_check for more details. in do_write()
1761 if (pid == -1) { in do_write()
1764 wrec.w_async = (req->r_type == WRITEA) ? 1 : 0; in do_write()
1779 if ((woffset = wlog_record_write(&Wlog, &wrec, -1)) == -1) { in do_write()
1781 "Could not append to write-log: %s (%d)\n", in do_write()
1788 switch (req->r_type) { in do_write()
1794 if (lseek(fd, offset, SEEK_SET) == -1) { in do_write()
1798 return -1; in do_write()
1803 if (rval == -1) { in do_write()
1807 format_rw(req, fd, addr, -1, Pattern, in do_write()
1815 fdc->c_miniosz, nbytes % fdc->c_miniosz, in do_write()
1816 oflags, fdc->c_memalign, in do_write()
1817 (long)addr % fdc->c_memalign); in do_write()
1828 "write() returned wrong # bytes - expected %d, got %d\n%s\n", in do_write()
1830 format_rw(req, fd, addr, -1, Pattern, in do_write()
1833 rval = -1; in do_write()
1841 * async write in do_write()
1843 if (lseek(fd, offset, SEEK_SET) == -1) { in do_write()
1847 return -1; in do_write()
1850 aio_strat = req->r_data.write.r_aio_strat; in do_write()
1857 * init iosw and do the async write in do_write()
1860 if (writea(fd, addr, nbytes, &aiop->iosw, signo) == -1) { in do_write()
1864 format_rw(req, fd, addr, -1, Pattern, in do_write()
1868 rval = -1; in do_write()
1872 * Wait for io to complete in do_write()
1881 if (aiop->iosw.sw_count != nbytes) { in do_write()
1885 aiop->iosw.sw_flag, in do_write()
1886 aiop->iosw.sw_error, in do_write()
1887 aiop->iosw.sw_count, in do_write()
1888 format_rw(req, fd, addr, -1, in do_write()
1889 Pattern, &aiop->iosw)); in do_write()
1892 rval = -1; in do_write()
1904 * Verify that the data was written correctly - check_file() returns in do_write()
1905 * a non-null pointer which contains an error message if there are in do_write()
1915 format_rw(req, fd, addr, -1, Pattern, in do_write()
1916 &aiop->iosw) in do_write()
1918 format_rw(req, fd, addr, -1, Pattern, NULL) in do_write()
1930 * Write extent information to the write-log, so that doio_check can do in do_write()
1947 alloc_mem(-1); in do_write()
1952 return ((rval == -1) ? -1 : 0); in do_write()
1974 return -1; in lock_file_region()
1989 struct listio_req *liop = &ioreq->r_data.listio; in format_listio()
2014 aio_strat = format_strat(liop->r_aio_strat); in format_listio()
2018 cp += sprintf(cp, "----------------------------------------\n"); in format_listio()
2022 switch (listreq->li_opcode) { in format_listio()
2037 listreq->li_drvr); in format_listio()
2040 listreq->li_flags); in format_listio()
2043 listreq->li_offset); in format_listio()
2046 listreq->li_fildes); in format_listio()
2049 listreq->li_buf); in format_listio()
2052 listreq->li_nbyte); in format_listio()
2055 listreq->li_status, listreq->li_status->sw_flag, in format_listio()
2056 listreq->li_status->sw_error, in format_listio()
2057 listreq->li_status->sw_count); in format_listio()
2060 listreq->li_signo); in format_listio()
2063 listreq->li_nstride); in format_listio()
2066 listreq->li_filstride); in format_listio()
2069 listreq->li_memstride); in format_listio()
2071 sprintf(cp, " io completion strategy is %s\n", in format_listio()
2096 lio = &req->r_data.listio; in do_listio()
2104 if (lio->r_filestride && abs(lio->r_filestride) < lio->r_nbytes) { in do_listio()
2106 "do_listio(): Bogus listio request - abs(filestride) [%d] < nbytes [%d]\n", in do_listio()
2107 abs(lio->r_filestride), lio->r_nbytes); in do_listio()
2108 return -1; in do_listio()
2117 stride_bounds(0, lio->r_memstride, lio->r_nstrides, in do_listio()
2118 lio->r_nbytes, NULL, NULL); in do_listio()
2125 * Set the memory address pointer. If the io is not raw, adjust in do_listio()
2126 * addr by a random amount, so that non-raw io is not necessarily in do_listio()
2132 if (!(lio->r_uflags & F_WORD_ALIGNED)) { in do_listio()
2133 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_listio()
2136 if (lio->r_opcode == LO_WRITE) { in do_listio()
2137 Pattern[0] = lio->r_pattern; in do_listio()
2144 * Get a descriptor to do the io on. No need to do an lseek, as this in do_listio()
2148 if ((fd = alloc_fd(lio->r_file, lio->r_oflags)) == -1) { in do_listio()
2149 return -1; in do_listio()
2152 rval = -1; in do_listio()
2163 if (lio->r_opcode == LO_WRITE && k_opt) { in do_listio()
2164 stride_bounds(lio->r_offset, in do_listio()
2165 lio->r_filestride, lio->r_nstrides, in do_listio()
2166 lio->r_nbytes, &min_byte, &max_byte); in do_listio()
2168 if (lock_file_region(lio->r_file, fd, F_WRLCK, in do_listio()
2169 min_byte, (max_byte - min_byte + 1)) < 0) { in do_listio()
2172 lio->r_offset, lio->r_filestride, in do_listio()
2173 lio->r_nstrides, lio->r_nbytes, min_byte, in do_listio()
2175 return -1; in do_listio()
2182 * async write in do_listio()
2185 aio_strat = lio->r_aio_strat; in do_listio()
2195 lio_req.li_opcode = lio->r_opcode; in do_listio()
2198 lio_req.li_offset = lio->r_offset; in do_listio()
2201 if (lio->r_memstride >= 0 || lio->r_nstrides <= 1) { in do_listio()
2204 lio_req.li_buf = addr + mem_needed - lio->r_nbytes; in do_listio()
2207 lio_req.li_nbyte = lio->r_nbytes; in do_listio()
2208 lio_req.li_status = &aiop->iosw; in do_listio()
2210 lio_req.li_nstride = lio->r_nstrides; in do_listio()
2211 lio_req.li_filstride = lio->r_filestride; in do_listio()
2212 lio_req.li_memstride = lio->r_memstride; in do_listio()
2225 if (listio(lio->r_cmd, &lio_req, 1) < 0) { in do_listio()
2229 format_listio(req, lio->r_cmd, &lio_req, 1, fd, in do_listio()
2241 * Wait for io to complete in do_listio()
2246 nstrides = lio->r_nstrides ? lio->r_nstrides : 1; in do_listio()
2247 if (aiop->iosw.sw_count != lio->r_nbytes * nstrides) { in do_listio()
2250 1, 0, lio->r_nbytes * lio->r_nstrides, in do_listio()
2251 aiop->iosw.sw_flag, in do_listio()
2252 aiop->iosw.sw_error, aiop->iosw.sw_count, in do_listio()
2253 format_listio(req, lio->r_cmd, &lio_req, 1, fd, in do_listio()
2263 * Verify that the data was written correctly - check_file() returns in do_listio()
2264 * a non-null pointer which contains an error message if there are in do_listio()
2272 fstride = lio->r_filestride ? lio->r_filestride : lio->r_nbytes; in do_listio()
2273 mstride = lio->r_memstride ? lio->r_memstride : lio->r_nbytes; in do_listio()
2274 foffset = lio->r_offset; in do_listio()
2276 if (mstride > 0 || lio->r_nstrides <= 1) { in do_listio()
2279 moffset = addr + mem_needed - lio->r_nbytes; in do_listio()
2283 msg = check_file(lio->r_file, in do_listio()
2284 foffset, lio->r_nbytes, in do_listio()
2286 moffset - addr, in do_listio()
2287 lio->r_oflags & O_PARALLEL); in do_listio()
2292 format_listio(req, lio->r_cmd, in do_listio()
2319 if (lock_file_region(lio->r_file, fd, F_UNLCK, in do_listio()
2320 min_byte, (max_byte - min_byte + 1)) < 0) { in do_listio()
2321 return -1; in do_listio()
2327 return -1; in do_listio()
2342 nbytes = req->r_data.ssread.r_nbytes; in do_ssdio()
2351 if (alloc_sds(nbytes) == -1) in do_ssdio()
2352 return -1; in do_ssdio()
2354 if (req->r_type == SSWRITE) { in do_ssdio()
2360 Pattern[0] = req->r_data.sswrite.r_pattern; in do_ssdio()
2364 if (sswrite((long)Memptr, (long)Sdsptr, btoc(nbytes)) == -1) { in do_ssdio()
2369 return -1; in do_ssdio()
2376 if (ssread((long)Memptr, (long)Sdsptr, btoc(nbytes)) == -1) { in do_ssdio()
2382 return -1; in do_ssdio()
2390 if (v_opt && req->r_type == SSWRITE) { in do_ssdio()
2394 -1) { in do_ssdio()
2396 "sds DATA COMPARE ERROR - ABORTING\n%s\n", in do_ssdio()
2412 "Internal Error - do_ssdio() called on a non-cray1 system\n"); in do_ssdio()
2413 alloc_mem(-1); in do_ssdio()
2425 struct rw_req *io; in fmt_ioreq() local
2437 io = &ioreq->r_data.io; in fmt_ioreq()
2440 * Look up async I/O completion strategy in fmt_ioreq()
2443 aname->value != -1 && aname->value != io->r_aio_strat; aname++) ; in fmt_ioreq()
2449 sprintf(cp, " fd %d is file %s - open flags are %#o %s\n", in fmt_ioreq()
2450 fd, io->r_file, io->r_oflags, format_oflags(io->r_oflags)); in fmt_ioreq()
2452 if (sy->sy_flags & SY_WRITE) { in fmt_ioreq()
2455 " write done at file offset %d - pattern is %c (%#o)\n", in fmt_ioreq()
2456 io->r_offset, in fmt_ioreq()
2457 (io->r_pattern == '\0') ? '?' : io->r_pattern, in fmt_ioreq()
2458 io->r_pattern); in fmt_ioreq()
2461 io->r_offset); in fmt_ioreq()
2464 if (sy->sy_flags & SY_ASYNC) { in fmt_ioreq()
2467 " async io completion strategy is %s\n", in fmt_ioreq()
2468 aname->string); in fmt_ioreq()
2474 io->r_nent, io->r_nstrides); in fmt_ioreq()
2476 cp += sprintf(cp, " i/o byte count = %d\n", io->r_nbytes); in fmt_ioreq()
2479 (io-> in fmt_ioreq()
2483 if (io->r_oflags & O_RAW) { in fmt_ioreq()
2487 io->r_offset % 4096, io->r_nbytes % 4096); in fmt_ioreq()
2499 if (io->r_oflags & O_DIRECT) { in fmt_ioreq()
2501 if (fcntl(fd, F_DIOINFO, &finfo) == -1) { in fmt_ioreq()
2514 finfo.d_miniosz, io->r_offset % finfo.d_miniosz, in fmt_ioreq()
2515 io->r_nbytes, io->r_nbytes % finfo.d_miniosz); in fmt_ioreq()
2541 * Initialize common fields - assumes r_oflags, r_file, r_offset, and in sy_listio()
2545 offset = req->r_data.io.r_offset; in sy_listio()
2546 nbytes = req->r_data.io.r_nbytes; in sy_listio()
2547 nstrides = req->r_data.io.r_nstrides; in sy_listio()
2548 nents = req->r_data.io.r_nent; in sy_listio()
2549 aio_strat = req->r_data.io.r_aio_strat; in sy_listio()
2551 lc = (sysc->sy_flags & SY_ASYNC) ? LC_START : LC_WAIT; in sy_listio()
2559 status->aioid = malloc((nents + 1) * sizeof(int)); in sy_listio()
2560 if (status->aioid == NULL) { in sy_listio()
2579 status->aioid[i] = aio_id; in sy_listio()
2581 l->li_opcode = (sysc->sy_flags & SY_WRITE) ? LO_WRITE : LO_READ; in sy_listio()
2582 l->li_offset = o; in sy_listio()
2583 l->li_fildes = fd; in sy_listio()
2584 l->li_buf = a; in sy_listio()
2585 l->li_nbyte = nbytes; in sy_listio()
2586 l->li_status = &aiop->iosw; in sy_listio()
2587 l->li_signo = signo; in sy_listio()
2588 l->li_nstride = nstrides; in sy_listio()
2589 l->li_filstride = 0; in sy_listio()
2590 l->li_memstride = 0; in sy_listio()
2591 l->li_drvr = 0; in sy_listio()
2592 l->li_flags = LF_LSEEK; in sy_listio()
2595 status->aioid[nents] = -1; /* end sentinel */ in sy_listio()
2597 if ((status->rval = listio(lc, lio_req, nents)) == -1) { in sy_listio()
2598 status->err = errno; in sy_listio()
2615 req->r_data.io.r_nstrides * req->r_data.io.r_nent, in listio_mem()
2616 req->r_data.io.r_nbytes, min, max); in listio_mem()
2637 c = (sy->sy_flags & SY_ASYNC) ? "lc_wait" : "lc_start"; in fmt_listio()
2641 c, req->r_data.io.r_nent); in fmt_listio()
2656 rc = pread(fd, addr, req->r_data.io.r_nbytes, req->r_data.io.r_offset); in sy_pread()
2664 status->aioid = NULL; in sy_pread()
2665 status->rval = rc; in sy_pread()
2666 status->err = errno; in sy_pread()
2677 rc = pwrite(fd, addr, req->r_data.io.r_nbytes, req->r_data.io.r_offset); in sy_pwrite()
2685 status->aioid = NULL; in sy_pwrite()
2686 status->rval = rc; in sy_pwrite()
2687 status->err = errno; in sy_pwrite()
2708 sy->sy_name, fd, addr, req->r_data.io.r_nbytes); in fmt_pread()
2741 status->aioid = NULL; in sy_rwv()
2744 if ((rc = lseek(fd, req->r_data.io.r_offset, SEEK_SET)) == -1) { in sy_rwv()
2745 status->rval = rc; in sy_rwv()
2746 status->err = errno; in sy_rwv()
2751 iov[0].iov_len = req->r_data.io.r_nbytes; in sy_rwv()
2757 status->aioid = NULL; in sy_rwv()
2758 status->rval = rc; in sy_rwv()
2759 status->err = errno; in sy_rwv()
2770 sy->sy_name, fd); in fmt_readv()
2798 /* POSIX 1003.1b-1993 Async read */ in sy_arw()
2810 aio_strat = req->r_data.io.r_aio_strat; in sy_arw()
2816 memset((void *)&aiop->aiocb, 0, sizeof(aiocb_t)); in sy_arw()
2818 aiop->aiocb.aio_fildes = fd; in sy_arw()
2819 aiop->aiocb.aio_nbytes = req->r_data.io.r_nbytes; in sy_arw()
2820 aiop->aiocb.aio_offset = req->r_data.io.r_offset; in sy_arw()
2821 aiop->aiocb.aio_buf = addr; in sy_arw()
2822 aiop->aiocb.aio_reqprio = 0; /* must be 0 */ in sy_arw()
2823 aiop->aiocb.aio_lio_opcode = 0; in sy_arw()
2826 aiop->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL; in sy_arw()
2827 aiop->aiocb.aio_sigevent.sigev_signo = signo; in sy_arw()
2829 aiop->aiocb.aio_sigevent.sigev_signo = 0; in sy_arw()
2830 aiop->aiocb.aio_sigevent.sigev_notify = SIGEV_CALLBACK; in sy_arw()
2831 aiop->aiocb.aio_sigevent.sigev_func = cb_handler; in sy_arw()
2832 aiop->aiocb.aio_sigevent.sigev_value.sival_int = aio_id; in sy_arw()
2834 aiop->aiocb.aio_sigevent.sigev_notify = SIGEV_NONE; in sy_arw()
2835 aiop->aiocb.aio_sigevent.sigev_signo = 0; in sy_arw()
2839 rc = aio_write(&aiop->aiocb); in sy_arw()
2841 rc = aio_read(&aiop->aiocb); in sy_arw()
2843 status->aioid = malloc(2 * sizeof(int)); in sy_arw()
2844 if (status->aioid == NULL) { in sy_arw()
2849 status->aioid[0] = aio_id; in sy_arw()
2850 status->aioid[1] = -1; in sy_arw()
2851 status->rval = rc; in sy_arw()
2852 status->err = errno; in sy_arw()
2862 cp += sprintf(cp, "syscall: %s(&aiop->aiocb)\n", sy->sy_name); in fmt_aread()
2903 status->aioid = NULL; in sy_mmrw()
2904 status->rval = -1; in sy_mmrw()
2906 fdc = alloc_fdcache(req->r_data.io.r_file, req->r_data.io.r_oflags); in sy_mmrw()
2908 if (v_opt || fdc->c_memaddr == NULL) { in sy_mmrw()
2911 status->err = errno; in sy_mmrw()
2915 fdc->c_memlen = (int)sbuf.st_size; in sy_mmrw()
2921 doio_fprintf(stderr, "mmap() failed - 0x%lx %d\n", in sy_mmrw()
2923 status->err = errno; in sy_mmrw()
2927 fdc->c_memaddr = mrc; in sy_mmrw()
2930 memaddr = (void *)((char *)fdc->c_memaddr + req->r_data.io.r_offset); in sy_mmrw()
2934 memcpy(memaddr, addr, req->r_data.io.r_nbytes); in sy_mmrw()
2936 memcpy(addr, memaddr, req->r_data.io.r_nbytes); in sy_mmrw()
2938 msync(fdc->c_memaddr, (int)sbuf.st_size, MS_SYNC); in sy_mmrw()
2941 status->rval = req->r_data.io.r_nbytes; in sy_mmrw()
2942 status->err = 0; in sy_mmrw()
2958 fdc = alloc_fdcache(req->r_data.io.r_file, req->r_data.io.r_oflags); in fmt_mmrw()
2962 sy->sy_name, in fmt_mmrw()
2963 fdc->c_memlen, in fmt_mmrw()
2964 (sy->sy_flags & SY_WRITE) ? "PROT_WRITE" : "PROT_READ", in fmt_mmrw()
2968 (unsigned long)fdc->c_memaddr); in fmt_mmrw()
2970 memaddr = (void *)((char *)fdc->c_memaddr + req->r_data.io.r_offset); in fmt_mmrw()
2972 cp += sprintf(cp, "\tfile-mem=0x%lx, length=%d, buffer=0x%lx\n", in fmt_mmrw()
2973 (unsigned long)memaddr, req->r_data.io.r_nbytes, in fmt_mmrw()
2982 {"listio-read-sync", LREAD,
2985 {"listio-read-strides-sync", LSREAD,
2988 {"listio-read-reqs-sync", LEREAD,
2991 {"listio-read-async", LREADA,
2994 {"listio-read-strides-async", LSREADA,
2997 {"listio-read-reqs-async", LEREADA,
3000 {"listio-write-sync", LWRITE,
3003 {"listio-write-strides-sync", LSWRITE,
3006 {"listio-write-reqs-sync", LEWRITE,
3009 {"listio-write-async", LWRITEA,
3012 {"listio-write-strides-async", LSWRITEA,
3015 {"listio-write-reqs-async", LEWRITEA,
3042 {"mmap-read", MMAPR,
3045 {"mmap-write", MMAPW,
3057 static int pid = -1; in do_rw()
3078 * Initialize common fields - assumes r_oflags, r_file, r_offset, and in do_rw()
3082 file = req->r_data.io.r_file; in do_rw()
3083 oflags = req->r_data.io.r_oflags; in do_rw()
3084 offset = req->r_data.io.r_offset; in do_rw()
3085 nbytes = req->r_data.io.r_nbytes; in do_rw()
3086 nstrides = req->r_data.io.r_nstrides; in do_rw()
3087 nents = req->r_data.io.r_nent; in do_rw()
3088 pattern = req->r_data.io.r_pattern; in do_rw()
3094 return (-1); in do_rw()
3100 for (sy = syscalls; sy->sy_name != NULL && sy->sy_type != req->r_type; in do_rw()
3103 if (sy->sy_name == NULL) { in do_rw()
3105 req->r_type); in do_rw()
3106 return (-1); in do_rw()
3115 if ((fd = alloc_fd(file, oflags)) == -1) in do_rw()
3116 return -1; in do_rw()
3124 * 1 extra word for possible partial-word address "bump" in do_rw()
3126 * MPP_BUMP extra words for T3E non-hw-aligned memory address. in do_rw()
3129 if (sy->sy_buffer != NULL) { in do_rw()
3130 mem_needed = (*sy->sy_buffer) (req, 0, 0, NULL, NULL); in do_rw()
3146 if ((rval = alloc_mem(mem_needed + wtob(1) * 2 + fdc->c_memalign)) < 0) { in do_rw()
3166 if (alloc_sds(nbytes) == -1) in do_rw()
3167 return -1; in do_rw()
3169 if (sy->sy_flags & SY_WRITE) { in do_rw()
3175 -1) { in do_rw()
3181 return -1; in do_rw()
3190 return -1; in do_rw()
3194 "Invalid O_SSD flag was generated for non-Cray system\n"); in do_rw()
3196 return -1; in do_rw()
3202 * if io is not raw, bump the offset by a random amount in do_rw()
3203 * to generate non-word-aligned io. in do_rw()
3206 * For non-aligned I/O, bump the address from 1 to 8 words. in do_rw()
3209 if (!(req->r_data.io.r_uflags & F_WORD_ALIGNED)) { in do_rw()
3214 addr += random_range(0, wtob(1) - 1, 1, NULL); in do_rw()
3220 if ((oflags & O_DIRECT) && ((long)addr % fdc->c_memalign != 0)) { in do_rw()
3222 fdc->c_memalign - ((long)addr % fdc->c_memalign); in do_rw()
3227 * FILL must be done on a word-aligned buffer. in do_rw()
3231 if (sy->sy_flags & SY_WRITE) { in do_rw()
3246 if (sy->sy_flags & SY_WRITE && k_opt) { in do_rw()
3247 if (sy->sy_buffer != NULL) { in do_rw()
3248 (*sy->sy_buffer) (req, offset, 0, &min_byte, &max_byte); in do_rw()
3255 min_byte, (max_byte - min_byte + 1)) < 0) { in do_rw()
3262 alloc_mem(-1); in do_rw()
3270 * Write a preliminary write-log entry. This is done so that in do_rw()
3273 * re-creates the file extents as if the write completed, but does not in do_rw()
3274 * do any checking - see comments in doio_check for more details. in do_rw()
3277 if (sy->sy_flags & SY_WRITE && w_opt) { in do_rw()
3278 if (pid == -1) { in do_rw()
3282 wrec.w_async = (sy->sy_flags & SY_ASYNC) ? 1 : 0; in do_rw()
3286 wrec.w_nbytes = nbytes; /* mem_needed -- total length */ in do_rw()
3297 if ((woffset = wlog_record_write(&Wlog, &wrec, -1)) == -1) { in do_rw()
3299 "Could not append to write-log: %s (%d)\n", in do_rw()
3306 s = (*sy->sy_syscall) (req, sy, fd, addr); in do_rw()
3308 if (s->rval == -1) { in do_rw()
3311 sy->sy_name, SYSERR, errno, in do_rw()
3313 (*sy->sy_format) (req, sy, fd, addr)); in do_rw()
3318 if (s->aioid == NULL) in do_rw()
3320 aio_unregister(s->aioid[i]); in do_rw()
3322 rval = -1; in do_rw()
3325 * If the syscall was async, wait for I/O to complete in do_rw()
3328 if (sy->sy_flags & SY_ASYNC) { in do_rw()
3330 aio_wait(s->aioid[i]); in do_rw()
3336 * Check the syscall how-much-data-written return. Look in do_rw()
3341 if (sy->sy_flags & SY_IOSW) { in do_rw()
3344 if (s->aioid == NULL) in do_rw()
3346 aiop = aio_slot(s->aioid[i]); in do_rw()
3347 iosw = &aiop->iosw; in do_rw()
3348 if (iosw->sw_error != 0) { in do_rw()
3351 sy->sy_name, in do_rw()
3352 strerror(iosw->sw_error), in do_rw()
3354 (*sy->sy_format) (req, sy, in do_rw()
3358 rval = -1; in do_rw()
3359 } else if (iosw->sw_count != nbytes * nstrides) { in do_rw()
3362 sy->sy_name, i, in do_rw()
3364 iosw->sw_flag, in do_rw()
3365 iosw->sw_error, in do_rw()
3366 iosw->sw_count, in do_rw()
3368 (*sy->sy_format) (req, sy, in do_rw()
3372 rval = -1; in do_rw()
3375 aio_unregister(s->aioid[i]); in do_rw()
3379 for (i = 0; s->aioid[i] != -1; i++) { in do_rw()
3380 if (s->aioid == NULL) { in do_rw()
3385 aiop = aio_slot(s->aioid[i]); in do_rw()
3388 * make sure the io completed without error in do_rw()
3390 if (aiop->aio_errno != 0) { in do_rw()
3393 sy->sy_name, in do_rw()
3394 strerror(aiop->aio_errno), in do_rw()
3395 aiop->aio_errno, in do_rw()
3397 (*sy->sy_format) (req, sy, in do_rw()
3401 rval = -1; in do_rw()
3402 } else if (aiop->aio_ret != nbytes) { in do_rw()
3405 sy->sy_name, i, in do_rw()
3407 aiop->aio_errno, in do_rw()
3408 aiop->aio_ret, in do_rw()
3410 (*sy->sy_format) (req, sy, in do_rw()
3413 aio_unregister(s->aioid[i]); in do_rw()
3415 return -1; in do_rw()
3417 aio_unregister(s->aioid[i]); in do_rw()
3424 if (s->rval != mem_needed) { in do_rw()
3426 "%s() request returned wrong # of bytes - expected %d, got %d\n%s\n%s\n", in do_rw()
3427 sy->sy_name, nbytes, s->rval, in do_rw()
3429 (*sy->sy_format) (req, sy, fd, in do_rw()
3431 rval = -1; in do_rw()
3438 * Verify that the data was written correctly - check_file() returns in do_rw()
3439 * a non-null pointer which contains an error message if there are in do_rw()
3443 if (rval == 0 && sy->sy_flags & SY_WRITE && v_opt) { in do_rw()
3451 (*sy->sy_format) (req, sy, fd, addr)); in do_rw()
3460 * Write extent information to the write-log, so that doio_check can do in do_rw()
3477 min_byte, (max_byte - min_byte + 1)) < 0) { in do_rw()
3478 alloc_mem(-1); in do_rw()
3483 if (s->aioid != NULL) in do_rw()
3484 free(s->aioid); in do_rw()
3486 return (rval == -1) ? -1 : 0; in do_rw()
3490 * fcntl-based requests
3491 * - F_FRESVSP
3492 * - F_UNRESVSP
3493 * - F_FSYNC
3506 * Initialize common fields - assumes r_oflags, r_file, r_offset, and in do_fcntl()
3510 file = req->r_data.io.r_file; in do_fcntl()
3511 oflags = req->r_data.io.r_oflags; in do_fcntl()
3512 offset = req->r_data.io.r_offset; in do_fcntl()
3513 nbytes = req->r_data.io.r_nbytes; in do_fcntl()
3524 if ((fd = alloc_fd(file, oflags)) == -1) in do_fcntl()
3525 return -1; in do_fcntl()
3543 alloc_mem(-1); in do_fcntl()
3550 switch (req->r_type) { in do_fcntl()
3569 if (rval == -1) { in do_fcntl()
3577 rval = -1; in do_fcntl()
3586 min_byte, (max_byte - min_byte + 1)) < 0) { in do_fcntl()
3587 alloc_mem(-1); in do_fcntl()
3592 return (rval == -1) ? -1 : 0; in do_fcntl()
3607 * Initialize common fields - assumes r_oflags, r_file, r_offset, and in do_sync()
3611 file = req->r_data.io.r_file; in do_sync()
3612 oflags = req->r_data.io.r_oflags; in do_sync()
3618 if ((fd = alloc_fd(file, oflags)) == -1) in do_sync()
3619 return -1; in do_sync()
3622 switch (req->r_type) { in do_sync()
3630 rval = -1; in do_sync()
3632 return (rval == -1) ? -1 : 0; in do_sync()
3655 "Corrupt regions follow - unprintable chars are represented as '.'\n"); in doio_pat_check()
3658 "-----------------------------------------------------------------\n"); in doio_pat_check()
3666 nb = bufend - cp; in doio_pat_check()
3667 if ((unsigned int)nb > sizeof(expected) - 1) { in doio_pat_check()
3668 nb = sizeof(expected) - 1; in doio_pat_check()
3674 offset + (int)(cp - buf)); in doio_pat_check()
3729 * The fsa flag is set to non-zero if the buffer should be read back through
3732 * FSA will not allow the file to be opened for buffered io if it was
3733 * previously opened for O_PARALLEL io.
3759 if ((fd = alloc_fd(file, flags)) == -1) { in check_file()
3766 if (lseek(fd, offset, SEEK_SET) == -1) { in check_file()
3775 if ((flags & O_DIRECT) && ((long)buf % fdc->c_memalign != 0)) { in check_file()
3776 buf += fdc->c_memalign - ((long)buf % fdc->c_memalign); in check_file()
3780 if ((nb = read(fd, buf, length)) == -1) { in check_file()
3786 fdc->c_memalign, (long)buf % fdc->c_memalign); in check_file()
3822 * Function to single-thread stdio output.
3827 static int pid = -1; in doio_fprintf()
3836 if (pid == -1) { in doio_fprintf()
3846 rval += fprintf(stream, "---------------------\n"); in doio_fprintf()
3879 /* nbytes = -1 means "free all allocated memory" */ in alloc_mem()
3880 if (nbytes == -1) { in alloc_mem()
3936 * Select a memory area (currently round-robbin) in alloc_mem()
3944 switch (M->memtype) { in alloc_mem()
3946 if (nbytes > M->size) { in alloc_mem()
3947 if (M->space != NULL) { in alloc_mem()
3949 if (M->flags & MEMF_MPIN) in alloc_mem()
3950 munpin(M->space, M->size); in alloc_mem()
3952 free(M->space); in alloc_mem()
3954 M->space = NULL; in alloc_mem()
3955 M->size = 0; in alloc_mem()
3958 if (M->space == NULL) { in alloc_mem()
3963 return -1; in alloc_mem()
3966 if (M->flags & MEMF_MPIN) { in alloc_mem()
3967 if (mpin(cp, nbytes) == -1) { in alloc_mem()
3974 M->space = (void *)cp; in alloc_mem()
3975 M->size = nbytes; in alloc_mem()
3980 if (nbytes > M->size) { in alloc_mem()
3981 if (M->space != NULL) { in alloc_mem()
3983 if (M->flags & MEMF_MPIN) in alloc_mem()
3984 munpin(M->space, M->size); in alloc_mem()
3986 munmap(M->space, M->size); in alloc_mem()
3987 close(M->fd); in alloc_mem()
3988 if (M->flags & MEMF_FILE) in alloc_mem()
3989 unlink(M->name); in alloc_mem()
3991 M->space = NULL; in alloc_mem()
3992 M->size = 0; in alloc_mem()
3995 if (M->space == NULL) { in alloc_mem()
3996 if (strchr(M->name, '%')) { in alloc_mem()
3997 sprintf(filename, M->name, getpid()); in alloc_mem()
3998 M->name = strdup(filename); in alloc_mem()
4001 if ((M->fd = in alloc_mem()
4002 open(M->name, O_CREAT | O_RDWR, 0666)) == -1) { in alloc_mem()
4005 errno, SYSERR, M->name); in alloc_mem()
4006 return (-1); in alloc_mem()
4011 M->size = nbytes * 4; in alloc_mem()
4017 if (M->flags & MEMF_PRIVATE) in alloc_mem()
4020 if (M->flags & MEMF_LOCAL) in alloc_mem()
4022 if (M->flags & MEMF_AUTORESRV) in alloc_mem()
4024 if (M->flags & MEMF_AUTOGROW) in alloc_mem()
4027 if (M->flags & MEMF_SHARED) in alloc_mem()
4030 /*printf("alloc_mem, about to mmap, fd=%d, name=(%s)\n", M->fd, M->name);*/ in alloc_mem()
4031 if ((M->space = mmap(addr, M->size, in alloc_mem()
4033 flags, M->fd, 0)) in alloc_mem()
4037 errno, SYSERR, addr, M->size, in alloc_mem()
4039 M->flags, M->fd, M->name); in alloc_mem()
4053 return (-1); in alloc_mem()
4059 if (nbytes > M->size) { in alloc_mem()
4060 if (M->space != NULL) { in alloc_mem()
4062 if (M->flags & MEMF_MPIN) in alloc_mem()
4063 munpin(M->space, M->size); in alloc_mem()
4065 shmdt(M->space); in alloc_mem()
4067 shmctl(M->fd, IPC_RMID); in alloc_mem()
4069 shmctl(M->fd, IPC_RMID, &shm_ds); in alloc_mem()
4072 M->space = NULL; in alloc_mem()
4073 M->size = 0; in alloc_mem()
4076 if (M->space == NULL) { in alloc_mem()
4077 if (!strcmp(M->name, "private")) { in alloc_mem()
4080 sscanf(M->name, "%i", &key); in alloc_mem()
4083 M->size = M->nblks ? M->nblks * 512 : nbytes; in alloc_mem()
4085 if (nbytes > M->size) { in alloc_mem()
4089 M->nblks, nbytes, M->size); in alloc_mem()
4094 shmid = shmget(key, M->size, IPC_CREAT | 0666); in alloc_mem()
4095 if (shmid == -1) { in alloc_mem()
4098 key, M->size, SYSERR, errno); in alloc_mem()
4099 return (-1); in alloc_mem()
4101 M->fd = shmid; in alloc_mem()
4102 M->space = shmat(shmid, NULL, SHM_RND); in alloc_mem()
4103 if (M->space == (void *)-1) { in alloc_mem()
4107 return (-1); in alloc_mem()
4110 if (M->flags & MEMF_MPIN) { in alloc_mem()
4111 if (mpin(M->space, M->size) == -1) { in alloc_mem()
4114 M->space, M->size, SYSERR, in alloc_mem()
4129 Memptr = M->space; in alloc_mem()
4130 Memsize = M->size; in alloc_mem()
4144 * this caused problems with async I/O on irix, and now appears in alloc_mem()
4149 if ((cp = (char *)sbrk(nbytes - Memsize)) == (char *)-1) { in alloc_mem()
4151 nbytes - Memsize, SYSERR, errno); in alloc_mem()
4152 return -1; in alloc_mem()
4157 Memsize += nbytes - Memsize; in alloc_mem()
4161 /* nbytes = -1 means "free all allocated memory" */ in alloc_mem()
4162 if (nbytes == -1) { in alloc_mem()
4176 return -1; in alloc_mem()
4191 return -1; in alloc_mem()
4194 cp += (0x40 - (ip & 0x3F)); in alloc_mem()
4217 if ((nblks = ssbreak(btoc(nbytes - Sdssize))) == -1) { in alloc_sds()
4219 btoc(nbytes - Sdssize), SYSERR, errno); in alloc_sds()
4220 return -1; in alloc_sds()
4237 "Internal Error - alloc_sds() called on a CRAY2 system\n"); in alloc_sds()
4238 alloc_mem(-1); in alloc_sds()
4265 return (fdc->c_fd); in alloc_fd()
4267 return (-1); in alloc_fd()
4286 if (cp->c_fd != -1) { in alloc_fdcache()
4287 close(cp->c_fd); in alloc_fdcache()
4290 if (cp->c_memaddr != NULL) { in alloc_fdcache()
4291 munmap(cp->c_memaddr, cp->c_memlen); in alloc_fdcache()
4313 if (cp->c_fd != -1 && in alloc_fdcache()
4314 cp->c_oflags == oflags && strcmp(cp->c_file, file) == 0) { in alloc_fdcache()
4316 cp->c_rtc = _rtc(); in alloc_fdcache()
4318 cp->c_rtc = Reqno; in alloc_fdcache()
4323 if (cp->c_fd == -1) { in alloc_fdcache()
4329 cp->c_rtc < oldest_slot->c_rtc) { in alloc_fdcache()
4346 alloc_mem(-1); in alloc_fdcache()
4353 * oldest_slot), and attempt to re-open. in alloc_fdcache()
4356 close(oldest_slot->c_fd); in alloc_fdcache()
4357 oldest_slot->c_fd = -1; in alloc_fdcache()
4365 alloc_mem(-1); in alloc_fdcache()
4386 alloc_mem(-1); in alloc_fdcache()
4392 for (cp = &cache[cache_size - FD_ALLOC_INCR]; in alloc_fdcache()
4394 cp->c_fd = -1; in alloc_fdcache()
4397 free_slot = &cache[cache_size - FD_ALLOC_INCR]; in alloc_fdcache()
4404 free_slot->c_fd = fd; in alloc_fdcache()
4405 free_slot->c_oflags = oflags; in alloc_fdcache()
4406 strcpy(free_slot->c_file, file); in alloc_fdcache()
4408 free_slot->c_rtc = _rtc(); in alloc_fdcache()
4410 free_slot->c_rtc = Reqno; in alloc_fdcache()
4415 if (fcntl(fd, F_DIOINFO, &finfo) == -1) { in alloc_fdcache()
4426 free_slot->c_memalign = finfo.d_mem; in alloc_fdcache()
4427 free_slot->c_miniosz = finfo.d_miniosz; in alloc_fdcache()
4428 free_slot->c_maxiosz = finfo.d_maxiosz; in alloc_fdcache()
4431 free_slot->c_memaddr = NULL; in alloc_fdcache()
4432 free_slot->c_memlen = 0; in alloc_fdcache()
4447 * "caller-id" for signals
4454 switch (info->si_code) { in signal_info()
4458 info->si_signo, info->si_errno, in signal_info()
4459 info->si_pid, info->si_uid); in signal_info()
4466 info->si_signo); in signal_info()
4472 if ((info->si_signo == SIGSEGV) || in signal_info()
4473 (info->si_signo == SIGBUS)) { in signal_info()
4476 info->si_signo, info->si_errno, in signal_info()
4477 info->si_code, info->si_addr, in signal_info()
4486 info->si_signo, info->si_errno, in signal_info()
4487 info->si_code); in signal_info()
4498 alloc_mem(-1); in cleanup_handler()
4506 alloc_mem(-1); in die_handler()
4513 get a SIGBUS for a variety of reasons--and not all of them in sigbus_handler()
4517 told to shutdown. However, if we're currently doing the above- in sigbus_handler()
4528 if (active_mmap_rw && havesigint && (info->si_errno == EINTR)) { in sigbus_handler()
4539 alloc_mem(-1); in cleanup_handler()
4546 alloc_mem(-1); in die_handler()
4582 if (Children[i] != -1) { in sigint_handler()
4589 * Signal handler used to inform a process when async io completes. Referenced
4591 * re-registered.
4602 if (aiop->strategy == A_SIGNAL && aiop->sig == sig) { in aio_handler()
4603 aiop->signalled++; in aio_handler()
4606 aiop->done++; in aio_handler()
4632 fprintf(stderr, "%d active async i/os\n", count); in dump_aio()
4650 if (aiop->strategy == A_CALLBACK) { in cb_handler()
4651 aiop->signalled++; in cb_handler()
4654 aiop->done++; in cb_handler()
4669 if (aio_id == -1) { in aio_slot()
4672 aiop->busy = 1; in aio_slot()
4673 aiop->id = id++; in aio_slot()
4688 alloc_mem(-1); in aio_slot()
4700 aiop = aio_slot(-1); in aio_register()
4702 aiop->fd = fd; in aio_register()
4703 aiop->strategy = strategy; in aio_register()
4704 aiop->done = 0; in aio_register()
4706 memset((char *)&aiop->iosw, 0x00, sizeof(aiop->iosw)); in aio_register()
4710 aiop->sig = sig; in aio_register()
4711 aiop->signalled = 0; in aio_register()
4717 sigaction(sig, &sa, &aiop->osa); in aio_register()
4719 aiop->sig = -1; in aio_register()
4720 aiop->signalled = 0; in aio_register()
4723 return aiop->id; in aio_register()
4732 if (aiop->strategy == A_SIGNAL) { in aio_unregister()
4733 sigaction(aiop->sig, &aiop->osa, NULL); in aio_unregister()
4736 aiop->busy = 0; in aio_unregister()
4759 switch (aiop->strategy) { in aio_wait()
4766 sighold(aiop->sig); in aio_wait()
4768 while (!aiop->signalled || !aiop->done) { in aio_wait()
4770 sighold(aiop->sig); in aio_wait()
4776 ioswlist[0] = &aiop->iosw; in aio_wait()
4777 if (recall(aiop->fd, 1, ioswlist) < 0) { in aio_wait()
4788 RECALL_SET(mask, aiop->fd); in aio_wait()
4795 RECALL_CLR(mask, aiop->fd); in aio_wait()
4800 ioswlist[0] = &aiop->iosw; in aio_wait()
4811 aioary[0] = &aiop->aiocb; in aio_wait()
4815 if (r == -1) { in aio_wait()
4822 } while (aiop->done == 0); in aio_wait()
4841 aioary[0] = &aiop->aiocb; in aio_wait()
4843 if (r == -1) { in aio_wait()
4854 /*printf("aio_wait: errno %d return %d\n", aiop->aio_errno, aiop->aio_ret);*/ in aio_wait()
4877 * Simple routine to check if an async io request has completed.
4883 return ainfo->iosw.sw_flag; in aio_done()
4887 if ((ainfo->aio_errno = aio_error(&ainfo->aiocb)) == -1) { in aio_done()
4892 /*printf("%d aio_done aio_errno=%d\n", getpid(), ainfo->aio_errno); */ in aio_done()
4893 if (ainfo->aio_errno != EINPROGRESS) { in aio_done()
4894 if ((ainfo->aio_ret = aio_return(&ainfo->aiocb)) == -1) { in aio_done()
4902 return (ainfo->aio_errno != EINPROGRESS); in aio_done()
4904 return -1; /* invalid */ in aio_done()
4909 * Routine to handle upanic() - it first attempts to set the panic flag. If
4914 * Note - we only execute the upanic code if -U was used, and the passed in
4926 "WARNING - Could not set the panic flag - upanic(PA_SET) failed: %s (%d)\n", in doio_upanic()
4933 syssgi(1005); /* syssgi test panic - DEBUG kernels only */ in doio_upanic()
4935 doio_fprintf(stderr, "WARNING - upanic() failed\n"); in doio_upanic()
4955 if (*argv[0] == '-') { in parse_cmdline()
4975 for (s = checkmap; s->string != NULL; s++) in parse_cmdline()
4976 if (!strcmp(s->string, optarg)) in parse_cmdline()
4978 if (s->string == NULL && tok != NULL) { in parse_cmdline()
4980 "%s%s: Illegal -C arg (%s). Must be one of: ", in parse_cmdline()
4983 for (s = checkmap; s->string != NULL; s++) in parse_cmdline()
4984 fprintf(stderr, "%s ", s->string); in parse_cmdline()
4989 switch (s->value) { in parse_cmdline()
4996 "%s%s: Unrecognised -C arg '%s' %d", in parse_cmdline()
4997 Prog, TagName, s->string, s->value); in parse_cmdline()
5009 "%s%s: Warning - Program is a multi-pe application - exec option is ignored.\n", in parse_cmdline()
5028 "%s%s: Illegal -m arg (%s): Must be an integer >= 0\n", in parse_cmdline()
5044 "%s%s: Error: -M isn't supported on this platform\n", in parse_cmdline()
5059 "%s%s: Illegal -n arg (%s): Must be integer > 0\n", in parse_cmdline()
5066 "%s%s: Program has been built as a multi-pe app. -n1 is the only nprocs value allowed\n", in parse_cmdline()
5077 "%s%s: Illegal -r arg (%s): Must be integer >= 0\n", in parse_cmdline()
5116 "%s: Invalid -V argument (%s) - must be a decimal, hex, or octal\n", in parse_cmdline()
5130 for (s = Upanic_Args; s->string != NULL; s++) in parse_cmdline()
5131 if (strcmp(s->string, tok) == 0) in parse_cmdline()
5134 if (s->string == NULL) { in parse_cmdline()
5136 "%s%s: Illegal -U arg (%s). Must be one of: ", in parse_cmdline()
5139 for (s = Upanic_Args; s->string != NULL; in parse_cmdline()
5142 s->string); in parse_cmdline()
5149 Upanic_Conditions |= s->value; in parse_cmdline()
5212 * T3E-shmem:blksize[:nblks]
5213 * SysV-shmem:shmid:blksize:nblks
5219 * p - private (MAP_PRIVATE)
5220 * a - private, MAP_AUTORESRV
5221 * l - local (MAP_LOCAL)
5222 * s - shared (nblks required)
5225 * f - fixed address (MAP_FIXED)
5226 * A - use an address without MAP_FIXED
5227 * a - autogrow (map once at startup)
5233 * - put a directory at the beginning of the shared
5238 * nblks worth of directories - 1 int pids
5248 doio_fprintf(stderr, "Error - too many memory types (%d).\n", in parse_memalloc()
5257 M->memtype = MEM_DATA; in parse_memalloc()
5258 M->flags = 0; in parse_memalloc()
5259 M->name = NULL; in parse_memalloc()
5260 M->space = NULL; in parse_memalloc()
5264 M->flags |= MEMF_MPIN; in parse_memalloc()
5268 M->memtype = MEM_MMAP; in parse_memalloc()
5269 M->flags = 0; in parse_memalloc()
5270 M->space = NULL; in parse_memalloc()
5273 M->flags |= MEMF_PRIVATE; in parse_memalloc()
5275 M->flags |= MEMF_AUTORESRV; in parse_memalloc()
5277 M->flags |= MEMF_LOCAL; in parse_memalloc()
5279 M->flags |= MEMF_SHARED; in parse_memalloc()
5282 M->flags |= MEMF_FIXADDR; in parse_memalloc()
5284 M->flags |= MEMF_ADDR; in parse_memalloc()
5286 M->flags |= MEMF_AUTOGROW; in parse_memalloc()
5289 M->flags |= MEMF_FILE; in parse_memalloc()
5291 M->flags |= MEMF_PRIVATE; in parse_memalloc()
5296 M->name = "/dev/zero"; in parse_memalloc()
5297 if (M->flags & in parse_memalloc()
5299 M->flags |= MEMF_PRIVATE; in parse_memalloc()
5301 M->name = allocargs[2]; in parse_memalloc()
5304 M->name = "/dev/zero"; in parse_memalloc()
5305 if (M->flags & ((MEMF_PRIVATE | MEMF_LOCAL) == 0)) in parse_memalloc()
5306 M->flags |= MEMF_PRIVATE; in parse_memalloc()
5312 M->memtype = MEM_SHMEM; in parse_memalloc()
5313 M->flags = 0; in parse_memalloc()
5314 M->space = NULL; in parse_memalloc()
5316 M->name = allocargs[1]; in parse_memalloc()
5318 M->name = NULL; in parse_memalloc()
5321 sscanf(allocargs[2], "%i", &M->nblks); in parse_memalloc()
5323 M->nblks = 0; in parse_memalloc()
5327 M->flags |= MEMF_MPIN; in parse_memalloc()
5332 doio_fprintf(stderr, "Error - unknown memory type '%s'.\n", in parse_memalloc()
5373 * -d <op>:<time> - doio inter-operation delay
5390 for (s = delaymap; s->string != NULL; s++) in parse_delay()
5391 if (!strcmp(s->string, delayargs[0])) in parse_delay()
5393 if (s->string == NULL) { in parse_delay()
5397 for (s = delaymap; s->string != NULL; s++) in parse_delay()
5398 fprintf(stderr, "%s ", s->string); in parse_delay()
5403 delayop = s->value; in parse_delay()
5413 * Usage clause - obvious
5428 …"usage%s: %s [-aekv] [-m message_interval] [-n nprocs] [-r release_interval] [-w write_log] [-V v… in usage()
5436 * Only the app running on vpe 0 gets to issue help - this prevents in help()
5447 "\t-a abort - kill all doio processes on data compare\n"); in help()
5450 fprintf(stream, "\t-C data-pattern-type \n"); in help()
5453 fprintf(stream, "\t default - repeating pattern\n"); in help()
5454 fprintf(stream, "\t-d Operation:Time Inter-operation delay.\n"); in help()
5465 "\t-e Re-exec children before entering the main\n"); in help()
5469 "\t procs around on multi-pe systems.\n"); in help()
5471 "\t-k Lock file regions during writes using fcntl()\n"); in help()
5473 "\t-v Verify writes - this is done by doing a buffered\n"); in help()
5475 "\t read() of the data if file io was done, or\n"); in help()
5477 "\t an ssread()of the data if sds io was done\n"); in help()
5480 "\t-M Data buffer allocation method\n"); in help()
5481 fprintf(stream, "\t alloc-type[,type]\n"); in help()
5484 fprintf(stream, "\t p - mpin buffer\n"); in help()
5486 fprintf(stream, "\t p - mpin buffer\n"); in help()
5492 fprintf(stream, "\t p - private\n"); in help()
5494 fprintf(stream, "\t s - shared\n"); in help()
5495 fprintf(stream, "\t l - local\n"); in help()
5496 fprintf(stream, "\t a - autoresrv\n"); in help()
5497 fprintf(stream, "\t G - autogrow\n"); in help()
5500 "\t s - shared (shared file must exist\n"), in help()
5505 "\t f - fixed address (not used)\n"); in help()
5507 "\t a - specify address (not used)\n"); in help()
5509 "\t U - Unlink file when done\n"); in help()
5515 "\t-m message_interval Generate a message every 'message_interval'\n"); in help()
5520 fprintf(stream, "\t-N tagname Tag name, for Monster.\n"); in help()
5521 fprintf(stream, "\t-n nprocs # of processes to start up\n"); in help()
5523 "\t-r release_interval Release all memory and close\n"); in help()
5531 "\t-V validation_ftype The type of file descriptor to use for doing data\n"); in help()
5539 "\t 'buffered' - validate using bufferd read\n"); in help()
5541 "\t 'sync' - validate using O_SYNC read\n"); in help()
5544 "\t 'direct - validate using O_DIRECT read'\n"); in help()
5548 "\t 'ldraw' - validate using O_LDRAW read\n"); in help()
5550 "\t 'parallel' - validate using O_PARALLEL read\n"); in help()
5552 "\t 'raw' - validate using O_RAW read\n"); in help()
5560 "\t-w write_log File to log file writes to. The doio_check\n"); in help()
5568 "\t-U upanic_cond Comma separated list of conditions that will\n"); in help()
5572 "\t 'corruption' -> upanic on bad data comparisons\n"); in help()
5574 "\t 'iosw' ---> upanic on unexpected async iosw\n"); in help()
5576 "\t 'rval' ---> upanic on unexpected syscall rvals\n"); in help()
5578 "\t 'all' ---> all of the above\n"); in help()
5581 "\tinfile Input stream - default is stdin - must be a list\n"); in help()