1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte * CDDL HEADER START
3fcf3ce44SJohn Forte *
4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte *
8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte * and limitations under the License.
12fcf3ce44SJohn Forte *
13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte *
19fcf3ce44SJohn Forte * CDDL HEADER END
20fcf3ce44SJohn Forte */
21*570de38fSSurya Prakki
22fcf3ce44SJohn Forte /*
23*570de38fSSurya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24fcf3ce44SJohn Forte * Use is subject to license terms.
25fcf3ce44SJohn Forte */
26fcf3ce44SJohn Forte
27fcf3ce44SJohn Forte /* #include <version.h> SKK */
28fcf3ce44SJohn Forte #include <errno.h>
29fcf3ce44SJohn Forte #include <sys/types.h>
30fcf3ce44SJohn Forte #include <sys/time.h>
31fcf3ce44SJohn Forte #include <sys/param.h>
32fcf3ce44SJohn Forte #include <sys/inttypes.h>
33fcf3ce44SJohn Forte #include <stdio.h>
34fcf3ce44SJohn Forte #include <strings.h>
35fcf3ce44SJohn Forte #include <fcntl.h>
36fcf3ce44SJohn Forte #include <sys/shm.h>
37fcf3ce44SJohn Forte #include <sys/wait.h>
38fcf3ce44SJohn Forte #include <unistd.h>
39fcf3ce44SJohn Forte #include <nsctl.h>
40fcf3ce44SJohn Forte
41fcf3ce44SJohn Forte #include <sys/nsctl/sd_cache.h>
42fcf3ce44SJohn Forte #include <sys/nsctl/sd_conf.h>
43fcf3ce44SJohn Forte
44fcf3ce44SJohn Forte #include <stdlib.h>
45fcf3ce44SJohn Forte #include <thread.h>
46fcf3ce44SJohn Forte #include <synch.h>
47fcf3ce44SJohn Forte
48fcf3ce44SJohn Forte #define MAXPARTS 100 /* Max disks */
49fcf3ce44SJohn Forte #define MAXBUF 65536 /* Max buffer size in long words */
50fcf3ce44SJohn Forte #define DISKLIST "disk_config" /* Default config file */
51fcf3ce44SJohn Forte #define DEF_SIZE 8192 /* Default buffer size */
52fcf3ce44SJohn Forte #define DEF_LOOP 1000 /* Loops for test */
53fcf3ce44SJohn Forte #define RAND_LOOPS DEF_LOOP /* # of random ios to do */
54fcf3ce44SJohn Forte
55fcf3ce44SJohn Forte /*
56fcf3ce44SJohn Forte * >>>>>>>>> USER LEVEL SD CACHE DIAGNOSTICS <<<<<<<<<<
57fcf3ce44SJohn Forte *
58fcf3ce44SJohn Forte * Write and read data blocks w/multiple processes
59fcf3ce44SJohn Forte * Starts one process for each partition specified in
60fcf3ce44SJohn Forte * the config file
61fcf3ce44SJohn Forte */
62fcf3ce44SJohn Forte
63fcf3ce44SJohn Forte int buf1[MAXBUF];
64fcf3ce44SJohn Forte int buf2[MAXBUF];
65fcf3ce44SJohn Forte char name[MAXPARTS][80];
66fcf3ce44SJohn Forte int pattern[MAXPARTS];
67fcf3ce44SJohn Forte int bufsize = DEF_SIZE;
68fcf3ce44SJohn Forte int fba_num_bufsize;
69fcf3ce44SJohn Forte nsc_size_t loops = DEF_LOOP;
70fcf3ce44SJohn Forte nsc_size_t r_loops = RAND_LOOPS;
71fcf3ce44SJohn Forte int fsize = -1;
72fcf3ce44SJohn Forte int readercount = 3;
73fcf3ce44SJohn Forte int Rflag = O_EXCL;
74fcf3ce44SJohn Forte char config_file[32];
75fcf3ce44SJohn Forte
76fcf3ce44SJohn Forte int
read_parts()77fcf3ce44SJohn Forte read_parts()
78fcf3ce44SJohn Forte {
79fcf3ce44SJohn Forte FILE *dfile;
80fcf3ce44SJohn Forte int partitions = 0;
81fcf3ce44SJohn Forte int i;
82fcf3ce44SJohn Forte
83fcf3ce44SJohn Forte dfile = fopen(config_file, "r");
84fcf3ce44SJohn Forte if (dfile == NULL) {
85fcf3ce44SJohn Forte (void) printf("cannot open file: %s\n", config_file);
86fcf3ce44SJohn Forte perror("fopen");
87fcf3ce44SJohn Forte exit(errno);
88fcf3ce44SJohn Forte }
89fcf3ce44SJohn Forte for (i = 0; i < MAXPARTS; i++) {
90fcf3ce44SJohn Forte if (fscanf(dfile, "%s %x", name[i], (uint_t *)&pattern[i]) ==
91fcf3ce44SJohn Forte EOF) {
92fcf3ce44SJohn Forte break;
93fcf3ce44SJohn Forte } else
94fcf3ce44SJohn Forte if (name[i][0] == '#' || strchr(name[i], '/') == NULL) {
95fcf3ce44SJohn Forte i--;
96fcf3ce44SJohn Forte continue;
97fcf3ce44SJohn Forte }
98fcf3ce44SJohn Forte partitions++;
99fcf3ce44SJohn Forte }
100fcf3ce44SJohn Forte (void) fclose(dfile);
101fcf3ce44SJohn Forte (void) printf("No. of partitions listed in file '%s' = %d\n\n",
102fcf3ce44SJohn Forte config_file, partitions);
103fcf3ce44SJohn Forte return (partitions);
104fcf3ce44SJohn Forte }
105fcf3ce44SJohn Forte
106fcf3ce44SJohn Forte void
print_usage()107fcf3ce44SJohn Forte print_usage()
108fcf3ce44SJohn Forte {
109fcf3ce44SJohn Forte (void) printf("Usage:\n");
110fcf3ce44SJohn Forte (void) printf(
111fcf3ce44SJohn Forte "sd_diag [-R] [-b <bufsize>] [-d <datasize>] [-l <loops>] [-r <readers>]\n");
112fcf3ce44SJohn Forte (void) printf(
113fcf3ce44SJohn Forte " [-f <disk_config_file>] <test#>\n");
114fcf3ce44SJohn Forte (void) printf(" test 1 = random read/write\n");
115fcf3ce44SJohn Forte (void) printf(" 2 = random read/write/verify, read after write\n");
116fcf3ce44SJohn Forte (void) printf(" 3 = random read/write/verify,");
117fcf3ce44SJohn Forte (void) printf(" all reads after all writes\n");
118fcf3ce44SJohn Forte (void) printf(" 4 = sequential read/write\n");
119fcf3ce44SJohn Forte (void) printf(" 5 = sequential write/read/verify,");
120fcf3ce44SJohn Forte (void) printf(" all reads after all writes\n");
121fcf3ce44SJohn Forte (void) printf(
122fcf3ce44SJohn Forte " 6 = altenating top/bottom sequential read/write/verify\n");
123fcf3ce44SJohn Forte (void) printf(" 7 = multiple readers/1 random writer\n");
124fcf3ce44SJohn Forte (void) printf(" 8 = random writes\n");
125fcf3ce44SJohn Forte (void) printf(" 9 = sequential write of known data\n");
126fcf3ce44SJohn Forte (void) printf(" 10 = sequential copy of datasize disk/verify\n");
127fcf3ce44SJohn Forte (void) printf(" 11 = sequential read/verify test 9 data -");
128fcf3ce44SJohn Forte (void) printf(" then clear data with timestamp\n");
129fcf3ce44SJohn Forte (void) printf(" 12 = sequential read/verify test 9 data -");
130fcf3ce44SJohn Forte (void) printf(" no clear data\n");
131fcf3ce44SJohn Forte (void) printf("\n");
132fcf3ce44SJohn Forte (void) printf(" <bufsize> in bytes (minimum is 512 bytes)\n");
133fcf3ce44SJohn Forte (void) printf(" <datasize> in Mbytes per disk\n");
134fcf3ce44SJohn Forte (void) printf(" <loops> is count of reads/writes,\n");
135fcf3ce44SJohn Forte (void) printf(" loops = 0 tests entire datasize disk");
136fcf3ce44SJohn Forte (void) printf(" for sequential tests.\n");
137fcf3ce44SJohn Forte (void) printf(" loops = 0 performs %d I/Os for the random "
138fcf3ce44SJohn Forte "tests\n", RAND_LOOPS);
139fcf3ce44SJohn Forte (void) printf(" <readers> is count of readers for test #7 (default "
140fcf3ce44SJohn Forte "is 3).\n");
141fcf3ce44SJohn Forte (void) printf(" [ defaults: bufsize = %d bytes, loops = %d,",
142fcf3ce44SJohn Forte DEF_SIZE, DEF_LOOP);
143fcf3ce44SJohn Forte (void) printf(" datasize = disksize ]\n");
144fcf3ce44SJohn Forte (void) printf("\n");
145fcf3ce44SJohn Forte (void) printf(" -R : do nsc_reserve(), nsc_release(0 around each "
146fcf3ce44SJohn Forte "I/O\n");
147fcf3ce44SJohn Forte }
148fcf3ce44SJohn Forte
149fcf3ce44SJohn Forte void
parse_opts(int argc,char * argv[])150fcf3ce44SJohn Forte parse_opts(int argc, char *argv[])
151fcf3ce44SJohn Forte {
152fcf3ce44SJohn Forte extern char *optarg;
153fcf3ce44SJohn Forte int c;
154fcf3ce44SJohn Forte
155fcf3ce44SJohn Forte while ((c = getopt(argc, argv, "b:d:l:r:Rf:")) != -1) {
156fcf3ce44SJohn Forte switch (c) {
157fcf3ce44SJohn Forte case 'f':
158fcf3ce44SJohn Forte /* printf("\n%s", optarg); */
159*570de38fSSurya Prakki (void) strcpy(config_file, optarg);
160fcf3ce44SJohn Forte break;
161fcf3ce44SJohn Forte case 'b':
162fcf3ce44SJohn Forte /* bufsize between 1*512 and 512*512 */
163fcf3ce44SJohn Forte bufsize = strtol(optarg, 0, 0);
164fcf3ce44SJohn Forte if (bufsize > (MAXBUF*4))
165fcf3ce44SJohn Forte bufsize = MAXBUF*4;
166fcf3ce44SJohn Forte else if (bufsize < FBA_SIZE(1))
167fcf3ce44SJohn Forte bufsize = FBA_SIZE(1);
168fcf3ce44SJohn Forte break;
169fcf3ce44SJohn Forte case 'd':
170fcf3ce44SJohn Forte /* convert datasize from Mb's to fba */
171fcf3ce44SJohn Forte fsize = strtol(optarg, 0, 0) * FBA_NUM(1 << 20);
172fcf3ce44SJohn Forte break;
173fcf3ce44SJohn Forte case 'l':
174fcf3ce44SJohn Forte loops = (nsc_size_t)strtoll(optarg, 0, 0);
175fcf3ce44SJohn Forte break;
176fcf3ce44SJohn Forte case 'r':
177fcf3ce44SJohn Forte /* count of readers for test 7 */
178fcf3ce44SJohn Forte readercount = strtol(optarg, 0, 0);
179fcf3ce44SJohn Forte break;
180fcf3ce44SJohn Forte case 'R':
181fcf3ce44SJohn Forte /* do reserve, release on a per io basis */
182fcf3ce44SJohn Forte Rflag = 0;
183fcf3ce44SJohn Forte break;
184fcf3ce44SJohn Forte case '?':
185fcf3ce44SJohn Forte print_usage();
186fcf3ce44SJohn Forte exit(0);
187fcf3ce44SJohn Forte }
188fcf3ce44SJohn Forte }
189fcf3ce44SJohn Forte bufsize &= ~FBA_MASK; /* multiple of 512 bytes for SECTMODE I/O */
190fcf3ce44SJohn Forte fba_num_bufsize = FBA_NUM(bufsize);
191fcf3ce44SJohn Forte
192fcf3ce44SJohn Forte /* set #ios for random io tests */
193fcf3ce44SJohn Forte if (loops != 0)
194fcf3ce44SJohn Forte r_loops = loops;
195fcf3ce44SJohn Forte
196fcf3ce44SJohn Forte }
197fcf3ce44SJohn Forte
198fcf3ce44SJohn Forte nsc_size_t
set_part_size(char * path,nsc_fd_t * sdfd)199fcf3ce44SJohn Forte set_part_size(char *path, nsc_fd_t *sdfd)
200fcf3ce44SJohn Forte {
201fcf3ce44SJohn Forte nsc_size_t filesize;
202fcf3ce44SJohn Forte int rc;
203fcf3ce44SJohn Forte
204fcf3ce44SJohn Forte rc = nsc_partsize(sdfd, &filesize); /* partsize in FBAs (512 bytes) */
205fcf3ce44SJohn Forte if (rc < 0 || filesize == 0) {
206fcf3ce44SJohn Forte (void) fprintf(stderr,
207fcf3ce44SJohn Forte "set_part_size: cannot access partition size");
208fcf3ce44SJohn Forte (void) fprintf(stderr, " for %s\n", path);
209fcf3ce44SJohn Forte (void) nsc_close(sdfd);
210fcf3ce44SJohn Forte exit(1);
211fcf3ce44SJohn Forte }
212fcf3ce44SJohn Forte
213fcf3ce44SJohn Forte (void) printf("Partition %s, size:%" NSC_SZFMT " blocks\n", path,
214fcf3ce44SJohn Forte filesize);
215fcf3ce44SJohn Forte
216fcf3ce44SJohn Forte if (fsize != -1 && fsize < filesize)
217fcf3ce44SJohn Forte filesize = fsize;
218fcf3ce44SJohn Forte filesize -= fba_num_bufsize;
219fcf3ce44SJohn Forte if (filesize < fba_num_bufsize) {
220fcf3ce44SJohn Forte (void) printf("ERROR: Max block size %" NSC_SZFMT "\n",
221fcf3ce44SJohn Forte filesize);
222fcf3ce44SJohn Forte (void) nsc_close(sdfd);
223fcf3ce44SJohn Forte exit(0);
224fcf3ce44SJohn Forte }
225fcf3ce44SJohn Forte
226fcf3ce44SJohn Forte return (filesize);
227fcf3ce44SJohn Forte }
228fcf3ce44SJohn Forte
229fcf3ce44SJohn Forte int
do_sdtest1(int fd,nsc_size_t loops,nsc_size_t filesize)230fcf3ce44SJohn Forte do_sdtest1(int fd, nsc_size_t loops, nsc_size_t filesize)
231fcf3ce44SJohn Forte {
232fcf3ce44SJohn Forte nsc_off_t seekpos;
233fcf3ce44SJohn Forte nsc_size_t i;
234fcf3ce44SJohn Forte ssize_t r;
235fcf3ce44SJohn Forte
236fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
237fcf3ce44SJohn Forte seekpos = (
238fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
239fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
240fcf3ce44SJohn Forte #endif
241fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
242fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (off_t)(seekpos << SCTRSHFT));
243fcf3ce44SJohn Forte if (r <= 0) {
244fcf3ce44SJohn Forte perror("Test1: write");
245fcf3ce44SJohn Forte return (1);
246fcf3ce44SJohn Forte }
247fcf3ce44SJohn Forte seekpos = (
248fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
249fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
250fcf3ce44SJohn Forte #endif
251fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
252fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (off_t)(seekpos << SCTRSHFT));
253fcf3ce44SJohn Forte if (r <= 0) {
254fcf3ce44SJohn Forte perror("Test1: read");
255fcf3ce44SJohn Forte return (1);
256fcf3ce44SJohn Forte }
257fcf3ce44SJohn Forte }
258fcf3ce44SJohn Forte return (0);
259fcf3ce44SJohn Forte }
260fcf3ce44SJohn Forte
261fcf3ce44SJohn Forte void
gen_data(int * buffer,int size)262fcf3ce44SJohn Forte gen_data(int *buffer, int size)
263fcf3ce44SJohn Forte {
264fcf3ce44SJohn Forte int i;
265fcf3ce44SJohn Forte
266fcf3ce44SJohn Forte size /= 4;
267fcf3ce44SJohn Forte for (i = 0; i < size; i++)
268fcf3ce44SJohn Forte buffer[i] = rand() << 16 | rand();
269fcf3ce44SJohn Forte }
270fcf3ce44SJohn Forte
271fcf3ce44SJohn Forte int
do_sdtest2(int fd,nsc_size_t loops,nsc_size_t filesize,int h)272fcf3ce44SJohn Forte do_sdtest2(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
273fcf3ce44SJohn Forte {
274fcf3ce44SJohn Forte nsc_off_t seekpos;
275fcf3ce44SJohn Forte int err = 0;
276fcf3ce44SJohn Forte ssize_t r;
277fcf3ce44SJohn Forte nsc_size_t i;
278fcf3ce44SJohn Forte
279fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
280fcf3ce44SJohn Forte seekpos = (
281fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
282fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
283fcf3ce44SJohn Forte #endif
284fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
285fcf3ce44SJohn Forte gen_data(buf1, bufsize);
286fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (off_t)(seekpos << SCTRSHFT));
287fcf3ce44SJohn Forte if (r <= 0) {
288fcf3ce44SJohn Forte perror("Test2: write");
289fcf3ce44SJohn Forte err++;
290fcf3ce44SJohn Forte return (err);
291fcf3ce44SJohn Forte }
292fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (off_t)(seekpos << SCTRSHFT));
293fcf3ce44SJohn Forte if (r <= 0) {
294fcf3ce44SJohn Forte perror("Test2: read");
295fcf3ce44SJohn Forte err++;
296fcf3ce44SJohn Forte return (err);
297fcf3ce44SJohn Forte }
298fcf3ce44SJohn Forte if (memcmp(buf1, buf2, bufsize)) {
299fcf3ce44SJohn Forte (void) printf("Test2: Data corruption,"
300fcf3ce44SJohn Forte " fd:%s, fpos:%" PRId64 ", len:%d\n",
301fcf3ce44SJohn Forte name[h], (int64_t)(seekpos << SCTRSHFT),
302fcf3ce44SJohn Forte bufsize);
303fcf3ce44SJohn Forte err++;
304fcf3ce44SJohn Forte }
305fcf3ce44SJohn Forte }
306fcf3ce44SJohn Forte return (err);
307fcf3ce44SJohn Forte }
308fcf3ce44SJohn Forte
309fcf3ce44SJohn Forte int
do_sdtest3(int fd,nsc_size_t loops,nsc_size_t filesize,int h,nsc_fd_t * sdfd)310fcf3ce44SJohn Forte do_sdtest3(int fd, nsc_size_t loops, nsc_size_t filesize, int h, nsc_fd_t *sdfd)
311fcf3ce44SJohn Forte {
312fcf3ce44SJohn Forte nsc_off_t *seekpos;
313fcf3ce44SJohn Forte int err = 0;
314fcf3ce44SJohn Forte nsc_size_t i;
315fcf3ce44SJohn Forte ssize_t r;
316fcf3ce44SJohn Forte
317fcf3ce44SJohn Forte seekpos = malloc(loops*sizeof (nsc_off_t));
318fcf3ce44SJohn Forte if (seekpos == NULL) {
319fcf3ce44SJohn Forte perror("Test3: malloc");
320fcf3ce44SJohn Forte (void) nsc_close(sdfd);
321fcf3ce44SJohn Forte exit(errno);
322fcf3ce44SJohn Forte }
323fcf3ce44SJohn Forte gen_data(buf1, bufsize);
324fcf3ce44SJohn Forte
325fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
326fcf3ce44SJohn Forte seekpos[i] = (
327fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
328fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
329fcf3ce44SJohn Forte #endif
330fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
331fcf3ce44SJohn Forte seekpos[i] -= seekpos[i] % fba_num_bufsize;
332fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (off_t)(seekpos[i] << SCTRSHFT));
333fcf3ce44SJohn Forte if (r <= 0) {
334fcf3ce44SJohn Forte perror("Test3: write");
335fcf3ce44SJohn Forte err++;
336fcf3ce44SJohn Forte goto cleanup;
337fcf3ce44SJohn Forte }
338fcf3ce44SJohn Forte }
339fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
340fcf3ce44SJohn Forte buf2[0] = '\0'; /* clear buf to make sure something is read */
341fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (off_t)(seekpos[i] << SCTRSHFT));
342fcf3ce44SJohn Forte if (r <= 0) {
343fcf3ce44SJohn Forte perror("Test3: read");
344fcf3ce44SJohn Forte err++;
345fcf3ce44SJohn Forte goto cleanup;
346fcf3ce44SJohn Forte }
347fcf3ce44SJohn Forte if (memcmp(buf1, buf2, bufsize)) {
348fcf3ce44SJohn Forte (void) printf("Data corruption, fd:%s, fpos:%" PRId64
349fcf3ce44SJohn Forte ", len:%d\n", name[h],
350fcf3ce44SJohn Forte (int64_t)(seekpos[i] << SCTRSHFT), bufsize);
351fcf3ce44SJohn Forte err++;
352fcf3ce44SJohn Forte }
353fcf3ce44SJohn Forte }
354fcf3ce44SJohn Forte
355fcf3ce44SJohn Forte cleanup:
356fcf3ce44SJohn Forte free(seekpos);
357fcf3ce44SJohn Forte return (err);
358fcf3ce44SJohn Forte }
359fcf3ce44SJohn Forte
360fcf3ce44SJohn Forte int
do_sdtest4(int fd,nsc_size_t loops,nsc_size_t filesize)361fcf3ce44SJohn Forte do_sdtest4(int fd, nsc_size_t loops, nsc_size_t filesize)
362fcf3ce44SJohn Forte {
363fcf3ce44SJohn Forte ssize_t r;
364fcf3ce44SJohn Forte nsc_size_t i;
365fcf3ce44SJohn Forte
366fcf3ce44SJohn Forte /*
367fcf3ce44SJohn Forte * Do sequential reads/writes for loops number
368fcf3ce44SJohn Forte * of bufsize chunks, unless loops == 0, then do
369fcf3ce44SJohn Forte * entire disk.
370fcf3ce44SJohn Forte * 1. sequential reads from the top down,
371fcf3ce44SJohn Forte * 2. sequential writes from the top down,
372fcf3ce44SJohn Forte * 3. sequential reads from the bottom up,
373fcf3ce44SJohn Forte * 4. sequential writes from the bottom up.
374fcf3ce44SJohn Forte */
375fcf3ce44SJohn Forte if ((loops > (filesize / fba_num_bufsize)) || (!loops))
376fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize; /* entire disk */
377fcf3ce44SJohn Forte
378fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
379fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
380fcf3ce44SJohn Forte if (r <= 0) {
381fcf3ce44SJohn Forte perror("Test4: read");
382fcf3ce44SJohn Forte return (1);
383fcf3ce44SJohn Forte }
384fcf3ce44SJohn Forte }
385fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
386fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
387fcf3ce44SJohn Forte if (r <= 0) {
388fcf3ce44SJohn Forte perror("Test4: write");
389fcf3ce44SJohn Forte return (1);
390fcf3ce44SJohn Forte }
391fcf3ce44SJohn Forte }
392fcf3ce44SJohn Forte for (i = loops - 1; i + 1 > 0; i--) {
393fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
394fcf3ce44SJohn Forte if (r <= 0) {
395fcf3ce44SJohn Forte perror("Test4: read");
396fcf3ce44SJohn Forte return (1);
397fcf3ce44SJohn Forte }
398fcf3ce44SJohn Forte }
399fcf3ce44SJohn Forte for (i = loops - 1; i + 1 > 0; i--) {
400fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
401fcf3ce44SJohn Forte if (r <= 0) {
402fcf3ce44SJohn Forte perror("Test4: write");
403fcf3ce44SJohn Forte return (1);
404fcf3ce44SJohn Forte }
405fcf3ce44SJohn Forte }
406fcf3ce44SJohn Forte return (0);
407fcf3ce44SJohn Forte }
408fcf3ce44SJohn Forte
409fcf3ce44SJohn Forte int
do_sdtest5(int fd,nsc_size_t loops,nsc_size_t filesize,int h)410fcf3ce44SJohn Forte do_sdtest5(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
411fcf3ce44SJohn Forte {
412fcf3ce44SJohn Forte int err = 0;
413fcf3ce44SJohn Forte ssize_t r;
414fcf3ce44SJohn Forte nsc_size_t i;
415fcf3ce44SJohn Forte
416fcf3ce44SJohn Forte /*
417fcf3ce44SJohn Forte * Do sequential writes with verify reads for loops number
418fcf3ce44SJohn Forte * of bufsize chunks, unless loops == 0, then do
419fcf3ce44SJohn Forte * entire disk.
420fcf3ce44SJohn Forte * 1. sequential writes from the top down,
421fcf3ce44SJohn Forte * 2. sequential reads from the top down with verify,
422fcf3ce44SJohn Forte * 3. sequential writes from the bottom up,
423fcf3ce44SJohn Forte * 4. sequential reads from the bottom up with verify.
424fcf3ce44SJohn Forte */
425fcf3ce44SJohn Forte if ((loops > (filesize / fba_num_bufsize)) || (!loops))
426fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize; /* entire disk */
427fcf3ce44SJohn Forte
428fcf3ce44SJohn Forte gen_data(buf1, bufsize);
429fcf3ce44SJohn Forte
430fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
431fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
432fcf3ce44SJohn Forte if (r <= 0) {
433fcf3ce44SJohn Forte perror("Test5: write");
434fcf3ce44SJohn Forte err++;
435fcf3ce44SJohn Forte return (err);
436fcf3ce44SJohn Forte }
437fcf3ce44SJohn Forte }
438fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
439fcf3ce44SJohn Forte buf2[0] = '\0'; /* clear buf to make sure something is read */
440fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
441fcf3ce44SJohn Forte if (r <= 0) {
442fcf3ce44SJohn Forte perror("Test5: read");
443fcf3ce44SJohn Forte err++;
444fcf3ce44SJohn Forte return (err);
445fcf3ce44SJohn Forte }
446fcf3ce44SJohn Forte if (memcmp(buf1, buf2, bufsize)) {
447fcf3ce44SJohn Forte (void) printf("Test5: Data corruption,"
448fcf3ce44SJohn Forte " fd:%s, fpos:%" NSC_SZFMT ", len:%d\n",
449fcf3ce44SJohn Forte name[h], i, bufsize);
450fcf3ce44SJohn Forte err++;
451fcf3ce44SJohn Forte }
452fcf3ce44SJohn Forte }
453fcf3ce44SJohn Forte
454fcf3ce44SJohn Forte gen_data(buf1, bufsize);
455fcf3ce44SJohn Forte
456fcf3ce44SJohn Forte for (i = loops - 1; i + 1 > 0; i--) {
457fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
458fcf3ce44SJohn Forte if (r <= 0) {
459fcf3ce44SJohn Forte perror("Test5: write");
460fcf3ce44SJohn Forte err++;
461fcf3ce44SJohn Forte return (err);
462fcf3ce44SJohn Forte }
463fcf3ce44SJohn Forte }
464fcf3ce44SJohn Forte for (i = loops - 1; i + 1 > 0; i--) {
465fcf3ce44SJohn Forte buf2[0] = '\0'; /* clear buf to make sure something is read */
466fcf3ce44SJohn Forte r = pread(fd, buf2, bufsize, (i*fba_num_bufsize) << SCTRSHFT);
467fcf3ce44SJohn Forte if (r <= 0) {
468fcf3ce44SJohn Forte perror("Test5: read");
469fcf3ce44SJohn Forte err++;
470fcf3ce44SJohn Forte return (err);
471fcf3ce44SJohn Forte }
472fcf3ce44SJohn Forte if (memcmp(buf1, buf2, bufsize)) {
473fcf3ce44SJohn Forte (void) printf("Test5: Data corruption,"
474fcf3ce44SJohn Forte " fd:%s, fpos:%" NSC_SZFMT ", len:%d\n",
475fcf3ce44SJohn Forte name[h], i, bufsize);
476fcf3ce44SJohn Forte err++;
477fcf3ce44SJohn Forte }
478fcf3ce44SJohn Forte }
479fcf3ce44SJohn Forte return (err);
480fcf3ce44SJohn Forte }
481fcf3ce44SJohn Forte
482fcf3ce44SJohn Forte
483fcf3ce44SJohn Forte int
do_sdtest6(int fd,nsc_size_t loops,nsc_size_t filesize,int h)484fcf3ce44SJohn Forte do_sdtest6(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
485fcf3ce44SJohn Forte {
486fcf3ce44SJohn Forte int err = 0;
487fcf3ce44SJohn Forte nsc_size_t i;
488fcf3ce44SJohn Forte ssize_t r;
489fcf3ce44SJohn Forte nsc_size_t endloop = filesize / fba_num_bufsize;
490fcf3ce44SJohn Forte int buf3[MAXBUF];
491fcf3ce44SJohn Forte int buf4[MAXBUF];
492fcf3ce44SJohn Forte nsc_off_t top_pos, bottom_pos;
493fcf3ce44SJohn Forte
494fcf3ce44SJohn Forte /*
495fcf3ce44SJohn Forte * Do alternating top down and bottom up sequential writes
496fcf3ce44SJohn Forte * (working towards middle) and verify with reads
497fcf3ce44SJohn Forte * for loops number of bufsize chunks, unless loops == 0, then do
498fcf3ce44SJohn Forte * entire disk.
499fcf3ce44SJohn Forte */
500fcf3ce44SJohn Forte if ((loops > (filesize / fba_num_bufsize)) || (!loops))
501fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize; /* entire disk */
502fcf3ce44SJohn Forte
503fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
504fcf3ce44SJohn Forte gen_data(buf1, bufsize);
505fcf3ce44SJohn Forte bottom_pos = i*fba_num_bufsize;
506fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (off_t)(bottom_pos << SCTRSHFT));
507fcf3ce44SJohn Forte if (r <= 0) {
508fcf3ce44SJohn Forte perror("Test6: write");
509fcf3ce44SJohn Forte err++;
510fcf3ce44SJohn Forte return (err);
511fcf3ce44SJohn Forte }
512fcf3ce44SJohn Forte gen_data(buf2, bufsize);
513fcf3ce44SJohn Forte top_pos = (endloop - i - 1)*fba_num_bufsize;
514fcf3ce44SJohn Forte
515fcf3ce44SJohn Forte /* Make sure we don't collide in the middle */
516fcf3ce44SJohn Forte
517fcf3ce44SJohn Forte if (abs(top_pos - bottom_pos) < fba_num_bufsize)
518fcf3ce44SJohn Forte top_pos = bottom_pos + fba_num_bufsize;
519fcf3ce44SJohn Forte
520fcf3ce44SJohn Forte r = pwrite(fd, buf2, bufsize, (off_t)(top_pos << SCTRSHFT));
521fcf3ce44SJohn Forte if (r <= 0) {
522fcf3ce44SJohn Forte perror("Test6: write");
523fcf3ce44SJohn Forte err++;
524fcf3ce44SJohn Forte return (err);
525fcf3ce44SJohn Forte }
526fcf3ce44SJohn Forte r = pread(fd, buf3, bufsize, (off_t)(bottom_pos << SCTRSHFT));
527fcf3ce44SJohn Forte if (r <= 0) {
528fcf3ce44SJohn Forte perror("Test6: read");
529fcf3ce44SJohn Forte err++;
530fcf3ce44SJohn Forte return (err);
531fcf3ce44SJohn Forte }
532fcf3ce44SJohn Forte if (memcmp(buf1, buf3, bufsize)) {
533fcf3ce44SJohn Forte (void) printf("Data corruption(1), fd:%s, fpos:%"
534fcf3ce44SJohn Forte PRId64 ", len:%d\n", name[h],
535fcf3ce44SJohn Forte (int64_t)(bottom_pos << SCTRSHFT), bufsize);
536fcf3ce44SJohn Forte err++;
537fcf3ce44SJohn Forte }
538fcf3ce44SJohn Forte r = pread(fd, buf4, bufsize, (off_t)(top_pos << SCTRSHFT));
539fcf3ce44SJohn Forte if (r <= 0) {
540fcf3ce44SJohn Forte perror("Test6: read");
541fcf3ce44SJohn Forte return (1);
542fcf3ce44SJohn Forte }
543fcf3ce44SJohn Forte if (memcmp(buf2, buf4, bufsize)) {
544fcf3ce44SJohn Forte (void) printf("Test6: Data corruption(2),"
545fcf3ce44SJohn Forte " fd:%s, fpos:%" PRId64 ", len:%d\n",
546fcf3ce44SJohn Forte name[h], (int64_t)(top_pos << SCTRSHFT), bufsize);
547fcf3ce44SJohn Forte err++;
548fcf3ce44SJohn Forte }
549fcf3ce44SJohn Forte }
550fcf3ce44SJohn Forte return (err);
551fcf3ce44SJohn Forte }
552fcf3ce44SJohn Forte
553fcf3ce44SJohn Forte int shmid;
554fcf3ce44SJohn Forte
555fcf3ce44SJohn Forte #define MAXREADERS 32
556fcf3ce44SJohn Forte
557fcf3ce44SJohn Forte struct shm_struct {
558fcf3ce44SJohn Forte int writebuf[MAXBUF];
559fcf3ce44SJohn Forte volatile nsc_off_t writepos;
560fcf3ce44SJohn Forte int quit;
561fcf3ce44SJohn Forte int err;
562fcf3ce44SJohn Forte mutex_t err_mutex;
563fcf3ce44SJohn Forte int rd_done[MAXREADERS];
564fcf3ce44SJohn Forte int rd_done_mask[MAXREADERS];
565fcf3ce44SJohn Forte } *shm;
566fcf3ce44SJohn Forte
567fcf3ce44SJohn Forte #define WRITEBUF (shm->writebuf)
568fcf3ce44SJohn Forte #define WRITEPOS (shm->writepos)
569fcf3ce44SJohn Forte
570fcf3ce44SJohn Forte #define QUIT (shm->quit)
571fcf3ce44SJohn Forte #define ERR (shm->err)
572fcf3ce44SJohn Forte #define ERRMUTEX (shm->err_mutex)
573fcf3ce44SJohn Forte #define RD_DONE (shm->rd_done)
574fcf3ce44SJohn Forte #define RD_DONE_MASK (shm->rd_done_mask)
575fcf3ce44SJohn Forte
576fcf3ce44SJohn Forte #define LOCKWRITE
577fcf3ce44SJohn Forte #define LOCKREAD(i)
578fcf3ce44SJohn Forte
579fcf3ce44SJohn Forte /* Clear RD_DONE and Set WRITEPOS */
580fcf3ce44SJohn Forte #define FREEWRITE { \
581fcf3ce44SJohn Forte bzero(RD_DONE, sizeof (RD_DONE)); \
582fcf3ce44SJohn Forte WRITEPOS = wr_pos; }
583fcf3ce44SJohn Forte
584fcf3ce44SJohn Forte /* Reader i+1 marks himself as finished */
585fcf3ce44SJohn Forte #define FREEREAD(i) (RD_DONE[(i)] = 1)
586fcf3ce44SJohn Forte
587fcf3ce44SJohn Forte
588fcf3ce44SJohn Forte int
do_sdtest7read(int fd,int h,int which)589fcf3ce44SJohn Forte do_sdtest7read(int fd, int h, int which)
590fcf3ce44SJohn Forte {
591fcf3ce44SJohn Forte int err;
592fcf3ce44SJohn Forte ssize_t r_rd;
593fcf3ce44SJohn Forte nsc_off_t curr_pos;
594fcf3ce44SJohn Forte nsc_size_t loop_cnt;
595fcf3ce44SJohn Forte err = 0; curr_pos = 0; loop_cnt = 0;
596fcf3ce44SJohn Forte for (;;) {
597fcf3ce44SJohn Forte /* Already read this? */
598fcf3ce44SJohn Forte if (curr_pos == WRITEPOS) {
599fcf3ce44SJohn Forte if (!QUIT) {
600fcf3ce44SJohn Forte continue;
601fcf3ce44SJohn Forte } else {
602fcf3ce44SJohn Forte /* Time to go! */
603fcf3ce44SJohn Forte /* printf("Quitting [%d]\n", which+1); */
604fcf3ce44SJohn Forte break;
605fcf3ce44SJohn Forte }
606fcf3ce44SJohn Forte }
607fcf3ce44SJohn Forte
608fcf3ce44SJohn Forte /* get location to read from */
609fcf3ce44SJohn Forte curr_pos = WRITEPOS;
610fcf3ce44SJohn Forte
611fcf3ce44SJohn Forte r_rd = pread(fd, buf1, bufsize, (curr_pos << SCTRSHFT));
612fcf3ce44SJohn Forte loop_cnt += 1;
613fcf3ce44SJohn Forte if (r_rd <= 0) {
614fcf3ce44SJohn Forte FREEREAD(which);
615fcf3ce44SJohn Forte perror("Test7: read");
616fcf3ce44SJohn Forte err += 1;
617fcf3ce44SJohn Forte continue;
618fcf3ce44SJohn Forte }
619fcf3ce44SJohn Forte
620fcf3ce44SJohn Forte if (memcmp(buf1, WRITEBUF, bufsize)) {
621fcf3ce44SJohn Forte FREEREAD(which);
622fcf3ce44SJohn Forte (void) printf("\nTest7: Data corruption, reader #%d, "
623fcf3ce44SJohn Forte "fd:%s, \
624fcf3ce44SJohn Forte fpos:%" PRId64 ", len:%d\n", which + 1, name[h],
625fcf3ce44SJohn Forte (int64_t)(curr_pos << SCTRSHFT), bufsize);
626fcf3ce44SJohn Forte err += 1;
627fcf3ce44SJohn Forte continue;
628fcf3ce44SJohn Forte }
629fcf3ce44SJohn Forte
630fcf3ce44SJohn Forte FREEREAD(which);
631fcf3ce44SJohn Forte }
632fcf3ce44SJohn Forte
633fcf3ce44SJohn Forte (void) printf(
634fcf3ce44SJohn Forte "Partition %s, Test 7, reader #%d: %d errors %lld loops\n",
635fcf3ce44SJohn Forte name[h], which+1, err, loop_cnt);
636fcf3ce44SJohn Forte
637fcf3ce44SJohn Forte if (err > 0) {
638fcf3ce44SJohn Forte (void) mutex_lock(&ERRMUTEX);
639fcf3ce44SJohn Forte ERR += err;
640fcf3ce44SJohn Forte (void) mutex_unlock(&ERRMUTEX);
641fcf3ce44SJohn Forte }
642fcf3ce44SJohn Forte
643fcf3ce44SJohn Forte if (err)
644fcf3ce44SJohn Forte return (1);
645fcf3ce44SJohn Forte else
646fcf3ce44SJohn Forte return (0);
647fcf3ce44SJohn Forte }
648fcf3ce44SJohn Forte
649fcf3ce44SJohn Forte
650fcf3ce44SJohn Forte int
do_sdtest7write(int fd,nsc_size_t filesize,int h)651fcf3ce44SJohn Forte do_sdtest7write(int fd, nsc_size_t filesize, int h)
652fcf3ce44SJohn Forte {
653fcf3ce44SJohn Forte int err = 0;
654fcf3ce44SJohn Forte ssize_t r;
655fcf3ce44SJohn Forte nsc_off_t wr_pos;
656fcf3ce44SJohn Forte
657fcf3ce44SJohn Forte /* Wait for readers to finish */
658fcf3ce44SJohn Forte while (memcmp(RD_DONE, RD_DONE_MASK, readercount*sizeof (int)))
659fcf3ce44SJohn Forte ;
660fcf3ce44SJohn Forte
661fcf3ce44SJohn Forte gen_data(WRITEBUF, bufsize);
662fcf3ce44SJohn Forte wr_pos = (
663fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
664fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
665fcf3ce44SJohn Forte #endif
666fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
667fcf3ce44SJohn Forte r = pwrite(fd, WRITEBUF, bufsize, (off_t)(wr_pos << SCTRSHFT));
668fcf3ce44SJohn Forte if (r <= 0) {
669fcf3ce44SJohn Forte FREEWRITE;
670fcf3ce44SJohn Forte perror("Test7: write");
671fcf3ce44SJohn Forte return (1);
672fcf3ce44SJohn Forte }
673fcf3ce44SJohn Forte FREEWRITE;
674fcf3ce44SJohn Forte
675fcf3ce44SJohn Forte /* verify write */
676fcf3ce44SJohn Forte r = pread(fd, buf1, bufsize, (off_t)(wr_pos << SCTRSHFT));
677fcf3ce44SJohn Forte if (r <= 0) {
678fcf3ce44SJohn Forte perror("Test7: writer: read");
679fcf3ce44SJohn Forte return (1);
680fcf3ce44SJohn Forte }
681fcf3ce44SJohn Forte
682fcf3ce44SJohn Forte
683fcf3ce44SJohn Forte if (memcmp(buf1, WRITEBUF, bufsize)) {
684fcf3ce44SJohn Forte (void) printf("\nTest7: Data corruption in writer,"
685fcf3ce44SJohn Forte " fd:%s, fpos:%" PRId64 ", len:%d\n",
686fcf3ce44SJohn Forte name[h], (int64_t)(wr_pos << SCTRSHFT), bufsize);
687fcf3ce44SJohn Forte err++;
688fcf3ce44SJohn Forte }
689fcf3ce44SJohn Forte
690fcf3ce44SJohn Forte
691fcf3ce44SJohn Forte return (err);
692fcf3ce44SJohn Forte }
693fcf3ce44SJohn Forte
694fcf3ce44SJohn Forte void
init_shm()695fcf3ce44SJohn Forte init_shm()
696fcf3ce44SJohn Forte {
697fcf3ce44SJohn Forte int i;
698fcf3ce44SJohn Forte
699fcf3ce44SJohn Forte /* Clear out everything */
700fcf3ce44SJohn Forte bzero(shm, sizeof (struct shm_struct));
701fcf3ce44SJohn Forte
702fcf3ce44SJohn Forte (void) mutex_init(&ERRMUTEX, USYNC_PROCESS, NULL);
703fcf3ce44SJohn Forte
704fcf3ce44SJohn Forte /* Set up mask (constant) to test reader doneness */
705fcf3ce44SJohn Forte for (i = 0; i < readercount; i++)
706fcf3ce44SJohn Forte RD_DONE_MASK[i] = 1;
707fcf3ce44SJohn Forte
708fcf3ce44SJohn Forte /* Mark all readers done - so writer can start */
709fcf3ce44SJohn Forte for (i = 0; i < readercount; i++)
710fcf3ce44SJohn Forte RD_DONE[i] = 1;
711fcf3ce44SJohn Forte }
712fcf3ce44SJohn Forte
713fcf3ce44SJohn Forte int
do_sdtest7(int fd,nsc_size_t loops,nsc_size_t filesize,int h,nsc_fd_t * sdfd)714fcf3ce44SJohn Forte do_sdtest7(int fd, nsc_size_t loops, nsc_size_t filesize, int h, nsc_fd_t *sdfd)
715fcf3ce44SJohn Forte {
716fcf3ce44SJohn Forte int r, i, err;
717fcf3ce44SJohn Forte nsc_size_t j;
718fcf3ce44SJohn Forte
719fcf3ce44SJohn Forte if ((shmid = shmget(IPC_PRIVATE, sizeof (struct shm_struct),
720fcf3ce44SJohn Forte IPC_CREAT | 0666)) < 0) {
721fcf3ce44SJohn Forte perror("shmget error: ");
722fcf3ce44SJohn Forte (void) nsc_close(sdfd);
723fcf3ce44SJohn Forte exit(1);
724fcf3ce44SJohn Forte }
725fcf3ce44SJohn Forte
726fcf3ce44SJohn Forte shm = (struct shm_struct *)shmat(shmid, NULL, 0);
727fcf3ce44SJohn Forte if (shm == (struct shm_struct *)-1) {
728fcf3ce44SJohn Forte perror("shmat error: ");
729fcf3ce44SJohn Forte (void) nsc_close(sdfd);
730fcf3ce44SJohn Forte exit(1); /* cleanup exits */
731fcf3ce44SJohn Forte }
732fcf3ce44SJohn Forte
733fcf3ce44SJohn Forte init_shm();
734fcf3ce44SJohn Forte
735fcf3ce44SJohn Forte /* Start Readers */
736fcf3ce44SJohn Forte for (i = 0; i < readercount; i++) {
737fcf3ce44SJohn Forte r = fork();
738fcf3ce44SJohn Forte if (r == 0) { /* child */
739fcf3ce44SJohn Forte (void) do_sdtest7read(fd, h, i);
740fcf3ce44SJohn Forte (void) nsc_close(sdfd);
741fcf3ce44SJohn Forte exit(0);
742fcf3ce44SJohn Forte } else
743fcf3ce44SJohn Forte continue;
744fcf3ce44SJohn Forte }
745fcf3ce44SJohn Forte
746fcf3ce44SJohn Forte /* Start Writer */
747fcf3ce44SJohn Forte srand(getpid()); err = 0;
748fcf3ce44SJohn Forte for (j = 0; j < loops; j++) {
749fcf3ce44SJohn Forte err += do_sdtest7write(fd, filesize, h);
750fcf3ce44SJohn Forte }
751fcf3ce44SJohn Forte QUIT = 1;
752fcf3ce44SJohn Forte
753fcf3ce44SJohn Forte (void) printf("\n\nPartition %s, Test 7, writer: %d errors\n",
754fcf3ce44SJohn Forte name[h], err);
755fcf3ce44SJohn Forte
756fcf3ce44SJohn Forte for (i = 0; i < readercount; i++)
757*570de38fSSurya Prakki (void) wait(0);
758fcf3ce44SJohn Forte
759fcf3ce44SJohn Forte /* No lock needed here - everybody's finished */
760fcf3ce44SJohn Forte err += ERR;
761fcf3ce44SJohn Forte
762fcf3ce44SJohn Forte (void) mutex_destroy(&ERRMUTEX);
763*570de38fSSurya Prakki (void) shmctl(shmid, IPC_RMID, 0);
764fcf3ce44SJohn Forte return (err);
765fcf3ce44SJohn Forte }
766fcf3ce44SJohn Forte
767fcf3ce44SJohn Forte int
do_sdtest8(int fd,nsc_size_t loops,nsc_size_t filesize)768fcf3ce44SJohn Forte do_sdtest8(int fd, nsc_size_t loops, nsc_size_t filesize)
769fcf3ce44SJohn Forte {
770fcf3ce44SJohn Forte nsc_off_t seekpos;
771fcf3ce44SJohn Forte int err = 0;
772fcf3ce44SJohn Forte ssize_t r;
773fcf3ce44SJohn Forte nsc_size_t i;
774fcf3ce44SJohn Forte
775fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
776fcf3ce44SJohn Forte seekpos = (
777fcf3ce44SJohn Forte #ifdef NSC_MULTI_TERABYTE
778fcf3ce44SJohn Forte ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) |
779fcf3ce44SJohn Forte #endif
780fcf3ce44SJohn Forte (rand() << 16) | rand()) % filesize;
781fcf3ce44SJohn Forte gen_data(buf1, bufsize);
782fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize, (off_t)(seekpos << SCTRSHFT));
783fcf3ce44SJohn Forte if (r <= 0) {
784fcf3ce44SJohn Forte perror("Test8: write");
785fcf3ce44SJohn Forte err++;
786fcf3ce44SJohn Forte return (err);
787fcf3ce44SJohn Forte }
788fcf3ce44SJohn Forte }
789fcf3ce44SJohn Forte return (err);
790fcf3ce44SJohn Forte }
791fcf3ce44SJohn Forte
792fcf3ce44SJohn Forte void
gen_data_known(int * buffer,int size,int data)793fcf3ce44SJohn Forte gen_data_known(int *buffer, int size, int data)
794fcf3ce44SJohn Forte {
795fcf3ce44SJohn Forte int i;
796fcf3ce44SJohn Forte
797fcf3ce44SJohn Forte size /= 4;
798fcf3ce44SJohn Forte for (i = 0; i < size; i++)
799fcf3ce44SJohn Forte buffer[i] = data;
800fcf3ce44SJohn Forte }
801fcf3ce44SJohn Forte
802fcf3ce44SJohn Forte int
do_sdtest9(int fd,nsc_size_t loops,nsc_size_t filesize,int h)803fcf3ce44SJohn Forte do_sdtest9(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
804fcf3ce44SJohn Forte {
805fcf3ce44SJohn Forte int err = 0;
806fcf3ce44SJohn Forte ssize_t r;
807fcf3ce44SJohn Forte nsc_off_t fba_offset;
808fcf3ce44SJohn Forte nsc_size_t i, wrapval;
809fcf3ce44SJohn Forte
810fcf3ce44SJohn Forte /*
811fcf3ce44SJohn Forte * Test 9 will write a given pattern over and over Test 11 or
812fcf3ce44SJohn Forte * Test 12 will read same pattern.
813fcf3ce44SJohn Forte */
814fcf3ce44SJohn Forte /* Large loop value that would cause write overflow will wrap */
815fcf3ce44SJohn Forte
816fcf3ce44SJohn Forte gen_data_known(buf1, bufsize, pattern[h]);
817fcf3ce44SJohn Forte
818fcf3ce44SJohn Forte wrapval = filesize / fba_num_bufsize;
819fcf3ce44SJohn Forte
820fcf3ce44SJohn Forte if (loops == 0)
821fcf3ce44SJohn Forte loops = wrapval; /* entire disk */
822fcf3ce44SJohn Forte
823fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
824fcf3ce44SJohn Forte fba_offset = i % wrapval;
825fcf3ce44SJohn Forte r = pwrite(fd, buf1, bufsize,
826fcf3ce44SJohn Forte (off_t)(fba_offset * fba_num_bufsize) << SCTRSHFT);
827fcf3ce44SJohn Forte if (r <= 0) {
828fcf3ce44SJohn Forte perror("Test9: write");
829fcf3ce44SJohn Forte err++;
830fcf3ce44SJohn Forte return (err);
831fcf3ce44SJohn Forte }
832fcf3ce44SJohn Forte }
833fcf3ce44SJohn Forte return (err);
834fcf3ce44SJohn Forte }
835fcf3ce44SJohn Forte
836fcf3ce44SJohn Forte int
do_sdtest10(int fd1,int fd2,nsc_size_t loops,nsc_size_t filesize1,nsc_size_t filesize2,int h)837fcf3ce44SJohn Forte do_sdtest10(int fd1, int fd2, nsc_size_t loops, nsc_size_t filesize1,
838fcf3ce44SJohn Forte nsc_size_t filesize2, int h)
839fcf3ce44SJohn Forte {
840fcf3ce44SJohn Forte nsc_size_t filesize;
841fcf3ce44SJohn Forte int err = 0;
842fcf3ce44SJohn Forte nsc_size_t i;
843fcf3ce44SJohn Forte ssize_t r;
844fcf3ce44SJohn Forte
845fcf3ce44SJohn Forte /*
846fcf3ce44SJohn Forte * Do sequential copy of disk1 to disk2 for loops number
847fcf3ce44SJohn Forte * of bufsize chunks, unless loops == 0, then copy size of
848fcf3ce44SJohn Forte * the smaller disk.
849fcf3ce44SJohn Forte * Go back and verify that the two disks are identical.
850fcf3ce44SJohn Forte */
851fcf3ce44SJohn Forte
852fcf3ce44SJohn Forte filesize = (filesize1 < filesize2) ? filesize1 : filesize2;
853fcf3ce44SJohn Forte if ((loops > (filesize / fba_num_bufsize)) || (!loops))
854fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize;
855fcf3ce44SJohn Forte
856fcf3ce44SJohn Forte /* copy disk1 to to disk2 */
857fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
858fcf3ce44SJohn Forte r = pread(fd1, buf1, bufsize,
859fcf3ce44SJohn Forte (off_t)(i*fba_num_bufsize) << SCTRSHFT);
860fcf3ce44SJohn Forte if (r <= 0) {
861fcf3ce44SJohn Forte perror("Test10: read");
862fcf3ce44SJohn Forte return (1);
863fcf3ce44SJohn Forte }
864fcf3ce44SJohn Forte r = pwrite(fd2, buf1, bufsize,
865fcf3ce44SJohn Forte (off_t)(i*fba_num_bufsize) << SCTRSHFT);
866fcf3ce44SJohn Forte if (r <= 0) {
867fcf3ce44SJohn Forte perror("Test10: write");
868fcf3ce44SJohn Forte return (1);
869fcf3ce44SJohn Forte }
870fcf3ce44SJohn Forte }
871fcf3ce44SJohn Forte
872fcf3ce44SJohn Forte /* verify disks are identical */
873fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
874fcf3ce44SJohn Forte buf1[0] = '\0'; /* clear buf to make sure something is read */
875fcf3ce44SJohn Forte r = pread(fd1, buf1, bufsize,
876fcf3ce44SJohn Forte (off_t)(i * fba_num_bufsize) << SCTRSHFT);
877fcf3ce44SJohn Forte if (r <= 0) {
878fcf3ce44SJohn Forte perror("Test10: read");
879fcf3ce44SJohn Forte return (1);
880fcf3ce44SJohn Forte }
881fcf3ce44SJohn Forte buf2[0] = 'x'; /* make sure something is read */
882fcf3ce44SJohn Forte r = pread(fd2, buf2, bufsize,
883fcf3ce44SJohn Forte (off_t)(i * fba_num_bufsize) << SCTRSHFT);
884fcf3ce44SJohn Forte if (r <= 0) {
885fcf3ce44SJohn Forte perror("Test10: read");
886fcf3ce44SJohn Forte return (1);
887fcf3ce44SJohn Forte }
888fcf3ce44SJohn Forte if (memcmp(buf1, buf2, bufsize)) {
889fcf3ce44SJohn Forte (void) printf("Test10: Data corruption,"
890fcf3ce44SJohn Forte " fd1:%s, fd2:%s fpos:%" NSC_SZFMT ", len:%d\n",
891fcf3ce44SJohn Forte name[2*h], name[2*h+1], i, bufsize);
892fcf3ce44SJohn Forte err++;
893fcf3ce44SJohn Forte }
894fcf3ce44SJohn Forte }
895fcf3ce44SJohn Forte return (err);
896fcf3ce44SJohn Forte }
897fcf3ce44SJohn Forte
898fcf3ce44SJohn Forte int
buffcmp(int * b1,int * b2,int size)899fcf3ce44SJohn Forte buffcmp(int *b1, int *b2, int size)
900fcf3ce44SJohn Forte {
901fcf3ce44SJohn Forte int i;
902fcf3ce44SJohn Forte
903fcf3ce44SJohn Forte for (i = 0; i < size/4; i++) {
904fcf3ce44SJohn Forte if (b1[i] != b2[i]) {
905fcf3ce44SJohn Forte (void) printf("Word %d does not match b1=0x%x, "
906fcf3ce44SJohn Forte "b2=0x%x\n", i, b1[i], b2[i]);
907fcf3ce44SJohn Forte return (1);
908fcf3ce44SJohn Forte }
909fcf3ce44SJohn Forte }
910fcf3ce44SJohn Forte return (0);
911fcf3ce44SJohn Forte
912fcf3ce44SJohn Forte }
913fcf3ce44SJohn Forte
914fcf3ce44SJohn Forte int
do_sdtest11(int fd,nsc_size_t loops,nsc_size_t filesize,int h)915fcf3ce44SJohn Forte do_sdtest11(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
916fcf3ce44SJohn Forte {
917fcf3ce44SJohn Forte int err = 0;
918fcf3ce44SJohn Forte nsc_size_t i;
919fcf3ce44SJohn Forte ssize_t r;
920fcf3ce44SJohn Forte int buf3[MAXBUF];
921fcf3ce44SJohn Forte int buf4[MAXBUF];
922fcf3ce44SJohn Forte int timestamp;
923fcf3ce44SJohn Forte time_t clock;
924fcf3ce44SJohn Forte struct tm *tm;
925fcf3ce44SJohn Forte
926fcf3ce44SJohn Forte
927fcf3ce44SJohn Forte /*
928fcf3ce44SJohn Forte * Test 9 will write a given pattern over and over Test 11 will read
929fcf3ce44SJohn Forte * same pattern and clear with timestamp data (MM:SS).
930fcf3ce44SJohn Forte */
931fcf3ce44SJohn Forte
932fcf3ce44SJohn Forte clock = time(NULL);
933fcf3ce44SJohn Forte tm = localtime(&clock);
934fcf3ce44SJohn Forte (void) ascftime((char *)×tamp, "%M""%S", tm);
935fcf3ce44SJohn Forte
936fcf3ce44SJohn Forte gen_data_known(buf1, bufsize, pattern[h]);
937fcf3ce44SJohn Forte gen_data_known(buf4, bufsize, timestamp);
938fcf3ce44SJohn Forte if ((loops > filesize / fba_num_bufsize) || (!loops))
939fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize; /* entire disk */
940fcf3ce44SJohn Forte
941fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
942fcf3ce44SJohn Forte r = pread(fd, buf3, bufsize,
943fcf3ce44SJohn Forte (off_t)(i*fba_num_bufsize) << SCTRSHFT);
944fcf3ce44SJohn Forte if (r <= 0) {
945fcf3ce44SJohn Forte perror("Test11: read");
946fcf3ce44SJohn Forte err++;
947fcf3ce44SJohn Forte return (err);
948fcf3ce44SJohn Forte }
949fcf3ce44SJohn Forte if (buffcmp(buf1, buf3, bufsize)) {
950fcf3ce44SJohn Forte (void) printf("Data corr, fd:%s, fpos:%" NSC_SZFMT
951fcf3ce44SJohn Forte ", len:%d\n", name[h], i, bufsize);
952fcf3ce44SJohn Forte err++;
953fcf3ce44SJohn Forte return (err);
954fcf3ce44SJohn Forte }
955fcf3ce44SJohn Forte r = pwrite(fd, buf4, bufsize,
956fcf3ce44SJohn Forte (off_t)(i*fba_num_bufsize) << SCTRSHFT);
957fcf3ce44SJohn Forte if (r <= 0) {
958fcf3ce44SJohn Forte perror("Test11: write");
959fcf3ce44SJohn Forte err++;
960fcf3ce44SJohn Forte return (err);
961fcf3ce44SJohn Forte }
962fcf3ce44SJohn Forte }
963fcf3ce44SJohn Forte return (err);
964fcf3ce44SJohn Forte }
965fcf3ce44SJohn Forte
966fcf3ce44SJohn Forte int
do_sdtest12(int fd,nsc_size_t loops,nsc_size_t filesize,int h)967fcf3ce44SJohn Forte do_sdtest12(int fd, nsc_size_t loops, nsc_size_t filesize, int h)
968fcf3ce44SJohn Forte {
969fcf3ce44SJohn Forte int err = 0;
970fcf3ce44SJohn Forte nsc_size_t i;
971fcf3ce44SJohn Forte ssize_t r;
972fcf3ce44SJohn Forte int buf3[MAXBUF];
973fcf3ce44SJohn Forte
974fcf3ce44SJohn Forte /*
975fcf3ce44SJohn Forte * Test 9 will write a given pattern over and over Test 12 will read
976fcf3ce44SJohn Forte * same pattern
977fcf3ce44SJohn Forte */
978fcf3ce44SJohn Forte
979fcf3ce44SJohn Forte gen_data_known(buf1, bufsize, pattern[h]);
980fcf3ce44SJohn Forte if ((loops > filesize / fba_num_bufsize) || (!loops))
981fcf3ce44SJohn Forte loops = filesize / fba_num_bufsize; /* entire disk */
982fcf3ce44SJohn Forte
983fcf3ce44SJohn Forte for (i = 0; i < loops; i++) {
984fcf3ce44SJohn Forte r = pread(fd, buf3, bufsize,
985fcf3ce44SJohn Forte (off_t)(i*fba_num_bufsize) << SCTRSHFT);
986fcf3ce44SJohn Forte if (r <= 0) {
987fcf3ce44SJohn Forte perror("Test12: read");
988fcf3ce44SJohn Forte err++;
989fcf3ce44SJohn Forte return (err);
990fcf3ce44SJohn Forte }
991fcf3ce44SJohn Forte if (buffcmp(buf1, buf3, bufsize)) {
992fcf3ce44SJohn Forte (void) printf("Data corr, fd:%s, fpos:%" NSC_SZFMT
993fcf3ce44SJohn Forte ", len:%d\n", name[h], i, bufsize);
994fcf3ce44SJohn Forte err++;
995fcf3ce44SJohn Forte return (err);
996fcf3ce44SJohn Forte }
997fcf3ce44SJohn Forte }
998fcf3ce44SJohn Forte return (err);
999fcf3ce44SJohn Forte }
1000fcf3ce44SJohn Forte
1001fcf3ce44SJohn Forte #ifdef lint
1002fcf3ce44SJohn Forte int
sd_diag_lintmain(int argc,char * argv[])1003fcf3ce44SJohn Forte sd_diag_lintmain(int argc, char *argv[])
1004fcf3ce44SJohn Forte #else
1005fcf3ce44SJohn Forte int
1006fcf3ce44SJohn Forte main(int argc, char *argv[])
1007fcf3ce44SJohn Forte #endif
1008fcf3ce44SJohn Forte {
1009fcf3ce44SJohn Forte int procs;
1010fcf3ce44SJohn Forte nsc_size_t filesize, filesize2;
1011fcf3ce44SJohn Forte int fd, fd2, r, id, h, i;
1012fcf3ce44SJohn Forte nsc_fd_t *sdfd, *sdfd2;
1013fcf3ce44SJohn Forte
1014fcf3ce44SJohn Forte if (argc < 2) {
1015fcf3ce44SJohn Forte print_usage();
1016fcf3ce44SJohn Forte exit(0);
1017fcf3ce44SJohn Forte }
1018*570de38fSSurya Prakki (void) strcpy(config_file, DISKLIST);
1019fcf3ce44SJohn Forte parse_opts(argc, argv);
1020fcf3ce44SJohn Forte
1021fcf3ce44SJohn Forte _nsc_nocheck();
1022fcf3ce44SJohn Forte if ((procs = read_parts()) == 0)
1023fcf3ce44SJohn Forte exit(0);
1024fcf3ce44SJohn Forte
1025fcf3ce44SJohn Forte id = strtol(argv[optind], 0, 0);
1026fcf3ce44SJohn Forte if (id == 10) {
1027fcf3ce44SJohn Forte /*
1028fcf3ce44SJohn Forte * each process gets 2 disks and copies disk1 to disk2,
1029fcf3ce44SJohn Forte * then goes back and verifies that the two disks are
1030fcf3ce44SJohn Forte * identical.
1031fcf3ce44SJohn Forte */
1032fcf3ce44SJohn Forte if (procs < 2) {
1033fcf3ce44SJohn Forte (void) printf("%s requires having at least 2 disks for test "
1034fcf3ce44SJohn Forte "#10.\n", config_file);
1035fcf3ce44SJohn Forte exit(0);
1036fcf3ce44SJohn Forte }
1037fcf3ce44SJohn Forte
1038fcf3ce44SJohn Forte for (h = 0; h < procs/2; h++) {
1039fcf3ce44SJohn Forte r = fork();
1040fcf3ce44SJohn Forte if (r == 0) {
1041fcf3ce44SJohn Forte srand(getpid());
1042fcf3ce44SJohn Forte
1043fcf3ce44SJohn Forte
1044fcf3ce44SJohn Forte if (!(sdfd = nsc_open(name[2*h], NSC_CACHE,
1045fcf3ce44SJohn Forte O_RDWR | Rflag))) {
1046fcf3ce44SJohn Forte (void) fprintf(stderr,
1047fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[2*h]);
1048fcf3ce44SJohn Forte exit(1);
1049fcf3ce44SJohn Forte }
1050fcf3ce44SJohn Forte fd = nsc_fileno(sdfd);
1051fcf3ce44SJohn Forte if (fd == -1) {
1052fcf3ce44SJohn Forte (void) fprintf(stderr,
1053fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[2*h]);
1054fcf3ce44SJohn Forte (void) nsc_close(sdfd);
1055fcf3ce44SJohn Forte exit(1);
1056fcf3ce44SJohn Forte }
1057fcf3ce44SJohn Forte filesize = set_part_size(name[2*h], sdfd);
1058fcf3ce44SJohn Forte if (!(sdfd2 = nsc_open(name[2*h+1], NSC_CACHE,
1059fcf3ce44SJohn Forte O_RDWR | Rflag))) {
1060fcf3ce44SJohn Forte (void) fprintf(stderr,
1061fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[2*h+1]);
1062fcf3ce44SJohn Forte exit(1);
1063fcf3ce44SJohn Forte }
1064fcf3ce44SJohn Forte fd2 = nsc_fileno(sdfd2);
1065fcf3ce44SJohn Forte if (fd2 == -1) {
1066fcf3ce44SJohn Forte (void) fprintf(stderr,
1067fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[2*h+1]);
1068fcf3ce44SJohn Forte (void) nsc_close(sdfd2);
1069fcf3ce44SJohn Forte exit(1);
1070fcf3ce44SJohn Forte }
1071fcf3ce44SJohn Forte filesize2 = set_part_size(name[2*h+1], sdfd2);
1072fcf3ce44SJohn Forte (void) sleep(2);
1073fcf3ce44SJohn Forte r = do_sdtest10(fd, fd2, loops, filesize, filesize2, h);
1074fcf3ce44SJohn Forte
1075fcf3ce44SJohn Forte (void) printf("Partitions %s and %s, Test %d,"
1076fcf3ce44SJohn Forte " Completed %d errors\n",
1077fcf3ce44SJohn Forte name[2*h], name[2*h+1], id, r);
1078fcf3ce44SJohn Forte (void) nsc_close(sdfd);
1079fcf3ce44SJohn Forte (void) nsc_close(sdfd2);
1080fcf3ce44SJohn Forte exit(0);
1081fcf3ce44SJohn Forte } else if (r == -1) {
1082fcf3ce44SJohn Forte perror("fork");
1083fcf3ce44SJohn Forte break;
1084fcf3ce44SJohn Forte } else
1085fcf3ce44SJohn Forte continue;
1086fcf3ce44SJohn Forte } /* for */
1087fcf3ce44SJohn Forte for (i = 0; i < h; i++)
1088*570de38fSSurya Prakki (void) wait(0);
1089fcf3ce44SJohn Forte } else {
1090fcf3ce44SJohn Forte
1091fcf3ce44SJohn Forte for (h = 0; h < procs; h++) {
1092fcf3ce44SJohn Forte r = fork();
1093fcf3ce44SJohn Forte if (r == 0) {
1094fcf3ce44SJohn Forte srand(getpid());
1095fcf3ce44SJohn Forte
1096fcf3ce44SJohn Forte id = strtol(argv[optind], 0, 0);
1097fcf3ce44SJohn Forte if (!(sdfd = nsc_open(name[h], NSC_CACHE,
1098fcf3ce44SJohn Forte O_RDWR | Rflag))) {
1099fcf3ce44SJohn Forte (void) fprintf(stderr,
1100fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[h]);
1101fcf3ce44SJohn Forte exit(1);
1102fcf3ce44SJohn Forte }
1103fcf3ce44SJohn Forte fd = nsc_fileno(sdfd);
1104fcf3ce44SJohn Forte
1105fcf3ce44SJohn Forte if (fd == -1) {
1106fcf3ce44SJohn Forte (void) fprintf(stderr,
1107fcf3ce44SJohn Forte "sd_diag: Error opening %s\n", name[h]);
1108fcf3ce44SJohn Forte (void) nsc_close(sdfd);
1109fcf3ce44SJohn Forte exit(1);
1110fcf3ce44SJohn Forte }
1111fcf3ce44SJohn Forte filesize = set_part_size(name[h], sdfd);
1112fcf3ce44SJohn Forte
1113fcf3ce44SJohn Forte (void) sleep(2);
1114fcf3ce44SJohn Forte
1115fcf3ce44SJohn Forte
1116fcf3ce44SJohn Forte switch (id) {
1117fcf3ce44SJohn Forte case 1:
1118fcf3ce44SJohn Forte r = do_sdtest1(fd, r_loops, filesize);
1119fcf3ce44SJohn Forte break;
1120fcf3ce44SJohn Forte case 2:
1121fcf3ce44SJohn Forte r = do_sdtest2(fd, r_loops, filesize, h);
1122fcf3ce44SJohn Forte break;
1123fcf3ce44SJohn Forte case 3:
1124fcf3ce44SJohn Forte r = do_sdtest3(fd, r_loops, filesize, h, sdfd);
1125fcf3ce44SJohn Forte break;
1126fcf3ce44SJohn Forte case 4:
1127fcf3ce44SJohn Forte r = do_sdtest4(fd, loops, filesize);
1128fcf3ce44SJohn Forte break;
1129fcf3ce44SJohn Forte case 5:
1130fcf3ce44SJohn Forte r = do_sdtest5(fd, loops, filesize, h);
1131fcf3ce44SJohn Forte break;
1132fcf3ce44SJohn Forte case 6:
1133fcf3ce44SJohn Forte r = do_sdtest6(fd, loops, filesize, h);
1134fcf3ce44SJohn Forte break;
1135fcf3ce44SJohn Forte case 7:
1136fcf3ce44SJohn Forte r = do_sdtest7(fd, r_loops, filesize, h, sdfd);
1137fcf3ce44SJohn Forte break;
1138fcf3ce44SJohn Forte case 8:
1139fcf3ce44SJohn Forte r = do_sdtest8(fd, r_loops, filesize);
1140fcf3ce44SJohn Forte break;
1141fcf3ce44SJohn Forte case 9:
1142fcf3ce44SJohn Forte r = do_sdtest9(fd, loops, filesize, h);
1143fcf3ce44SJohn Forte break;
1144fcf3ce44SJohn Forte case 11:
1145fcf3ce44SJohn Forte r = do_sdtest11(fd, loops, filesize, h);
1146fcf3ce44SJohn Forte break;
1147fcf3ce44SJohn Forte case 12:
1148fcf3ce44SJohn Forte r = do_sdtest12(fd, loops, filesize, h);
1149fcf3ce44SJohn Forte break;
1150fcf3ce44SJohn Forte default:
1151fcf3ce44SJohn Forte break;
1152fcf3ce44SJohn Forte }
1153fcf3ce44SJohn Forte
1154fcf3ce44SJohn Forte (void) printf("Partition %s, Test %d, Completed %d "
1155fcf3ce44SJohn Forte "errors\n", name[h], id, r);
1156fcf3ce44SJohn Forte (void) nsc_close(sdfd);
1157fcf3ce44SJohn Forte exit(r ? 1 : 0);
1158fcf3ce44SJohn Forte } else if (r == -1) {
1159fcf3ce44SJohn Forte perror("fork");
1160fcf3ce44SJohn Forte break;
1161fcf3ce44SJohn Forte } else
1162fcf3ce44SJohn Forte continue;
1163fcf3ce44SJohn Forte }
1164fcf3ce44SJohn Forte for (i = 0; i < h; i++)
1165*570de38fSSurya Prakki (void) wait(0);
1166fcf3ce44SJohn Forte }
1167fcf3ce44SJohn Forte
1168fcf3ce44SJohn Forte return (0);
1169fcf3ce44SJohn Forte }
1170