plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 3 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of version 2 of the GNU General Public License as |
| 6 | * published by the Free Software Foundation. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 7 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 8 | * This program is distributed in the hope that it would be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 11 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 12 | * Further, this software is distributed without any warranty that it is |
| 13 | * free of the rightful claim of any third person regarding infringement |
| 14 | * or the like. Any license provided herein, whether implied or |
| 15 | * otherwise, applies only to this software file. Patent licenses, if |
| 16 | * any, provided herein do not apply to combinations of this program with |
| 17 | * other software, or any other product whatsoever. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 18 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 19 | * You should have received a copy of the GNU General Public License along |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 20 | * with this program; if not, write the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 22 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 24 | * Mountain View, CA 94043, or: |
Chris Dearman | 37550cf | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 25 | * |
| 26 | * http://www.sgi.com |
| 27 | * |
| 28 | * For further information regarding this notice, see: |
| 29 | * |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 30 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 31 | */ |
| 32 | /* |
| 33 | * Define io syscalls supported by doio |
| 34 | */ |
| 35 | |
| 36 | #define READ 1 |
| 37 | #define WRITE 2 |
| 38 | #define READA 3 |
| 39 | #define WRITEA 4 |
| 40 | #define SSREAD 5 |
| 41 | #define SSWRITE 6 |
| 42 | #define LISTIO 7 |
| 43 | #define LREAD 10 /* listio - single stride, single entry */ |
| 44 | #define LREADA 11 |
| 45 | #define LWRITE 12 |
| 46 | #define LWRITEA 13 |
| 47 | #define LSREAD 14 /* listio - multi-stride, single entry */ |
| 48 | #define LSREADA 15 |
| 49 | #define LSWRITE 16 |
| 50 | #define LSWRITEA 17 |
| 51 | #define LEREAD 18 /* listio - single stride, multiple entry */ |
| 52 | #define LEREADA 19 |
| 53 | #define LEWRITE 20 |
| 54 | #define LEWRITEA 21 |
| 55 | |
| 56 | /* Irix System Calls */ |
| 57 | #define PREAD 100 |
| 58 | #define PWRITE 101 |
| 59 | #define READV 102 |
| 60 | #define WRITEV 103 |
| 61 | #define AREAD 104 |
| 62 | #define AWRITE 105 |
| 63 | #define LLREAD 110 |
| 64 | #define LLAREAD 111 |
| 65 | #define LLWRITE 112 |
| 66 | #define LLAWRITE 113 |
| 67 | #define MMAPR 120 |
| 68 | #define MMAPW 121 |
| 69 | #define RESVSP 122 /* fcntl(F_RESVSP) */ |
| 70 | #define UNRESVSP 123 /* fcntl(F_UNRESVSP) */ |
| 71 | #define DFFSYNC 124 /* fcntl(F_FSYNC) */ |
| 72 | #define FSYNC2 125 /* fsync(2) */ |
| 73 | #define FDATASYNC 126 /* fdatasync(2) */ |
| 74 | #define BIOSIZE 127 /* fcntl(F_SETBIOSIZE) */ |
| 75 | |
| 76 | #ifdef CRAY |
| 77 | /* used: <<doio>> 1.? <<DOIO>> 1.5 <-DOIO-> 1.7*/ |
| 78 | #define DOIO_MAGIC '<[DOIO]>' |
| 79 | #else |
| 80 | #define DOIO_MAGIC 07116601 |
| 81 | #endif |
| 82 | |
| 83 | /* |
| 84 | * Define various user flags (r_uflag field) that io requests can have |
| 85 | * specified. |
| 86 | */ |
| 87 | |
| 88 | #define F_WORD_ALIGNED 0001 /* force request to be word aligned */ |
| 89 | |
| 90 | /* |
| 91 | * define various doio exit status's |
| 92 | */ |
| 93 | |
| 94 | #define E_NORMAL 000 /* normal completion */ |
| 95 | #define E_USAGE 001 /* cmdline usage error */ |
| 96 | #define E_SETUP 002 /* any of a million setup conditions */ |
| 97 | #define E_COMPARE 004 /* data compare error from doio child */ |
| 98 | #define E_INTERNAL 010 /* various internal errors */ |
| 99 | #define E_LOCKD 020 /* lockd startup/timeout errors */ |
| 100 | #define E_SIGNAL 040 /* killed by signal */ |
| 101 | |
| 102 | /* |
| 103 | * Define async io completion strategies supported by doio. |
| 104 | */ |
| 105 | |
| 106 | #define A_POLL 1 /* poll iosw for completion */ |
| 107 | #define A_SIGNAL 2 /* get signal for completion */ |
| 108 | #define A_RECALL 3 /* use recall(2) to wait */ |
| 109 | #define A_RECALLA 4 /* use recalla(2) to wait */ |
| 110 | #define A_RECALLS 5 /* use recalls(2) to wait */ |
| 111 | #define A_SUSPEND 6 /* use aio_suspend(2) to wait */ |
| 112 | #define A_CALLBACK 7 /* use a callback signal op. */ |
| 113 | |
| 114 | /* |
| 115 | * Define individual structures for each syscall type. These will all be |
| 116 | * unionized into a single io_req structure which io generators fill in and |
| 117 | * pass to doio. |
| 118 | * |
| 119 | * Note: It is VERY important that the r_file, r_oflags, r_offset, and |
| 120 | * r_nbytes fields occupy the same record positions in the |
| 121 | * read_req, reada_req, write_req, and writea_req structures and |
| 122 | * that they have the same type. It is also that r_pattern |
| 123 | * has the same type/offset in the write_req and writea_req |
| 124 | * structures. |
| 125 | * |
| 126 | * Since doio.c accesses all information through the r_data |
| 127 | * union in io_req, if the above assumptions hold, the above |
| 128 | * fields can be accessed without regard to structure type. |
| 129 | * This is an allowed assumption in C. |
| 130 | */ |
| 131 | |
| 132 | #define MAX_FNAME_LENGTH 128 |
| 133 | |
| 134 | struct read_req { |
| 135 | char r_file[MAX_FNAME_LENGTH]; |
| 136 | int r_oflags; /* open flags */ |
| 137 | int r_offset; |
| 138 | int r_nbytes; |
| 139 | int r_uflags; /* user flags: mem alignment */ |
| 140 | int r_aio_strat; /* asynch read completion strategy */ |
| 141 | int r_nstrides; /* listio: multiple strides */ |
| 142 | int r_nent; /* listio: multiple list entries */ |
| 143 | }; |
| 144 | |
| 145 | struct write_req { |
| 146 | char r_file[MAX_FNAME_LENGTH]; |
| 147 | int r_oflags; |
| 148 | int r_offset; |
| 149 | int r_nbytes; |
| 150 | char r_pattern; |
| 151 | int r_uflags; /* user flags: mem alignment */ |
| 152 | int r_aio_strat; /* asynch write completion strategy */ |
| 153 | int r_nstrides; /* listio: multiple strides */ |
| 154 | int r_nent; /* listio: multiple list entries */ |
| 155 | }; |
| 156 | |
| 157 | struct ssread_req { |
| 158 | int r_nbytes; |
| 159 | }; |
| 160 | |
| 161 | struct sswrite_req { |
| 162 | int r_nbytes; |
| 163 | char r_pattern; |
| 164 | }; |
| 165 | |
| 166 | struct listio_req { |
| 167 | char r_file[MAX_FNAME_LENGTH]; |
| 168 | int r_cmd; /* LC_START or LC_WAIT */ |
| 169 | int r_offset; /* file offset */ |
| 170 | int r_opcode; /* LO_READ, or LO_WRITE */ |
| 171 | int r_nbytes; /* bytes per stride */ |
| 172 | int r_nstrides; /* how many strides to make */ |
| 173 | int r_nent; /* how many listreq entries to make */ |
| 174 | int r_filestride; /* always 0 for now */ |
| 175 | int r_memstride; /* always 0 for now */ |
| 176 | char r_pattern; /* for LO_WRITE operations */ |
| 177 | int r_oflags; /* open(2) flags */ |
| 178 | int r_aio_strat; /* async I/O completion strategy */ |
| 179 | int r_uflags; /* user flags: memory alignment */ |
| 180 | }; |
| 181 | |
| 182 | #define rw_req listio_req /* listio is superset of everything */ |
| 183 | |
| 184 | /* |
| 185 | * Main structure for sending a request to doio. Any tools which form IO |
| 186 | * for doio must present it using one of these structures. |
| 187 | */ |
| 188 | |
| 189 | struct io_req { |
| 190 | int r_type; /* must be one of the #defines above */ |
| 191 | int r_magic; /* must be set to DOIO_MAGIC by requestor */ |
| 192 | union { |
| 193 | struct read_req read; |
| 194 | struct write_req write; |
| 195 | struct ssread_req ssread; |
| 196 | struct sswrite_req sswrite; |
| 197 | struct listio_req listio; |
| 198 | struct rw_req io; |
| 199 | } r_data; |
| 200 | }; |