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