/alps/fwbench

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/fwbench

« back to all changes in this revision

Viewing changes to seqreader.c

  • Committer: Suren A. Chilingaryan
  • Date: 2012-11-29 02:18:11 UTC
  • Revision ID: csa@dside.dyndns.org-20121129021811-5aau4xlrqpy9v9a0
Big file support

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#define EXTRA_BUFFERS 2
23
23
#define WRITE_INTERVAL 1
24
24
 
 
25
 
25
26
#define RAID_STRIP_SIZE         256
26
27
#define RAID_DISKS              8
27
28
#define STRIPS_AT_ONCE          2
28
29
 
 
30
#define FS_MIN_BLOCK_SIZE (1024 * RAID_STRIP_SIZE)
 
31
#define FS_BLOCK_SIZE (1024 * RAID_STRIP_SIZE * RAID_DISKS)
 
32
 
29
33
#ifdef AIO_MODE
30
34
# define SYNC_MODE
31
35
#endif /* AIO_MODE */
62
66
    char *buffer;
63
67
    long double mcoef = 1000000. / (1024 * 1024);
64
68
    int flags = O_RDONLY|O_NOATIME|O_LARGEFILE;
 
69
    struct stat st;
65
70
 
66
71
#ifdef AIO_MODE
67
72
    int i;
79
84
    posix_memalign((void**)&buffer, FASTWRITER_SYNCIO_ALIGN, BUFSIZE);
80
85
    
81
86
    if (argc < 2) {
82
 
        printf("Usage: %s <directory|device> [skip|size]\n", argv[0]);
 
87
        printf("Usage: %s <directory|file|device> [skip|size]\n", argv[0]);
83
88
        exit(0);
84
89
    }
85
90
    
86
 
    if (strstr(argv[1], "/dev/")) {
 
91
    if (stat(argv[1], &st)) {
 
92
        printf("stat on (%s) have failed", argv[1]);
 
93
        exit(-1);
 
94
    }
 
95
    
 
96
    if (strstr(argv[1], "/dev/")||(S_ISREG(st.st_mode))) {
87
97
        if (argc > 2) {
88
98
            max_size = atol(argv[2]);
89
99
            max_size *= 1024 * 1024 * 1024;
125
135
#ifdef AIO_MODE 
126
136
        err = io_submit(aio, AIO_MODE, ioptr);
127
137
        if (err != AIO_MODE) {
128
 
            printf("io_submit returned %i\n", err);
129
 
            perror("Failed to submit initial AIO jobs");
 
138
            printf("Failed to submit initial AIO job, io_submit returned %i\n", err);
 
139
            exit(-1);
130
140
        }
131
141
#endif /* AIO_MODE */
132
142
        
155
165
                for (i = 0; i < err; i++) {
156
166
                    struct io_event *ep = &ev[events + i];
157
167
                    int doneio = (uintptr_t)ep->data;
158
 
                    if (ep->res2 || (ep->res != BLOCK_SIZE)) perror("Error in async IO");
 
168
                    if (ep->res2 || (ep->res != BLOCK_SIZE)) {
 
169
                        printf("Error in async IO\n");
 
170
                        exit(-1);
 
171
                    }
159
172
                    done[doneio%(AIO_MODE + EXTRA_BUFFERS)] = 1;
160
173
//                  printf("done (%i): %i\n", i, doneio);
161
174
                }
169
182
                    io_prep_pread(newio, fd, buffer + (schedio % (AIO_MODE + EXTRA_BUFFERS)) * BLOCK_SIZE, BLOCK_SIZE, schedio * BLOCK_SIZE);
170
183
                    io_set_callback(newio, (void*)(uintptr_t)schedio);
171
184
                    err = io_submit(aio, 1, &newio);
172
 
                    if (err != 1) perror("Failed to submit AIO jobs");
 
185
                    if (err != 1) {
 
186
                        printf("Failed to submit AIO jobs %i", err);
 
187
                        exit(-1);
 
188
                    }
173
189
                    schedio++;
174
190
                }
175
191
                events = i + 1;
249
265
      skip = 0;
250
266
      dir = opendir(".");
251
267
      while ((ent = readdir(dir))) {
252
 
        struct stat st;
253
 
        
254
268
        if (((skip++)%SKIP) != run) continue;
255
269
 
256
270
        if (stat(ent->d_name, &st)) continue;
268
282
# ifdef FS_SYNC_MODE
269
283
        if (size < BLOCK_SIZE) size = BLOCK_SIZE;
270
284
# endif /* FS_SYNC_MODE */
 
285
        if (size < FS_MIN_BLOCK_SIZE) size = FS_BLOCK_SIZE;
271
286
#endif  
272
287
 
273
288
        if (!files)