blob: aea0398ec691bb034910f0c545bc5bd214dc8306 [file] [log] [blame]
Jens Axboef29b25a2007-07-23 08:56:43 +02001/*
2 * Code related to writing an iolog of what a thread is doing, and to
3 * later read that back and replay
4 */
Jens Axboe3c39a372006-06-06 20:56:12 +02005#include <stdio.h>
6#include <stdlib.h>
Jens Axboef29b25a2007-07-23 08:56:43 +02007#include <assert.h>
Jens Axboe3c39a372006-06-06 20:56:12 +02008#include "list.h"
9#include "fio.h"
10
Jens Axboef29b25a2007-07-23 08:56:43 +020011static const char iolog_ver2[] = "fio version 2 iolog";
12
13void log_io_u(struct thread_data *td, struct io_u *io_u)
Jens Axboe3c39a372006-06-06 20:56:12 +020014{
Jens Axboef29b25a2007-07-23 08:56:43 +020015 const char *act[] = { "read", "write", "sync" };
16
17 assert(io_u->ddir < 3);
18
19 if (!td->o.write_iolog_file)
20 return;
21
Jens Axboe5ec10ea2008-03-06 15:42:00 +010022 fprintf(td->iolog_f, "%s %s %llu %lu\n", io_u->file->file_name,
23 act[io_u->ddir], io_u->offset,
24 io_u->buflen);
Jens Axboef29b25a2007-07-23 08:56:43 +020025}
26
27void log_file(struct thread_data *td, struct fio_file *f,
28 enum file_log_act what)
29{
30 const char *act[] = { "add", "open", "close" };
31
32 assert(what < 3);
33
34 if (!td->o.write_iolog_file)
35 return;
36
37 fprintf(td->iolog_f, "%s %s\n", f->file_name, act[what]);
Jens Axboe3c39a372006-06-06 20:56:12 +020038}
39
Jens Axboea61edde2007-05-15 14:29:58 +020040static void iolog_delay(struct thread_data *td, unsigned long delay)
41{
42 unsigned long usec = utime_since_now(&td->last_issue);
43
44 if (delay < usec)
45 return;
46
47 delay -= usec;
48
49 /*
50 * less than 100 usec delay, just regard it as noise
51 */
52 if (delay < 100)
53 return;
54
55 usec_sleep(td, delay);
56}
57
Jens Axboe3c39a372006-06-06 20:56:12 +020058int read_iolog_get(struct thread_data *td, struct io_u *io_u)
59{
60 struct io_piece *ipo;
61
Jens Axboeb3f4b4f2007-07-23 11:23:26 +020062 while (!list_empty(&td->io_log_list)) {
Jens Axboe3c39a372006-06-06 20:56:12 +020063 ipo = list_entry(td->io_log_list.next, struct io_piece, list);
64 list_del(&ipo->list);
Jens Axboea61edde2007-05-15 14:29:58 +020065
Jens Axboef29b25a2007-07-23 08:56:43 +020066 /*
67 * invalid ddir, this is a file action
68 */
Jens Axboe429f6672007-07-23 10:38:43 +020069 if (ipo->ddir == DDIR_INVAL) {
Jens Axboe126d65c2008-03-01 18:04:31 +010070 struct fio_file *f = td->files[ipo->fileno];
Jens Axboef29b25a2007-07-23 08:56:43 +020071
72 if (ipo->file_action == FIO_LOG_OPEN_FILE) {
73 assert(!td_io_open_file(td, f));
74 free(ipo);
Jens Axboeb3f4b4f2007-07-23 11:23:26 +020075 continue;
Jens Axboef29b25a2007-07-23 08:56:43 +020076 } else if (ipo->file_action == FIO_LOG_CLOSE_FILE) {
77 td_io_close_file(td, f);
78 free(ipo);
Jens Axboeb3f4b4f2007-07-23 11:23:26 +020079 continue;
Jens Axboef29b25a2007-07-23 08:56:43 +020080 }
81 }
82
Jens Axboe429f6672007-07-23 10:38:43 +020083 io_u->offset = ipo->offset;
84 io_u->buflen = ipo->len;
85 io_u->ddir = ipo->ddir;
Jens Axboe126d65c2008-03-01 18:04:31 +010086 io_u->file = td->files[ipo->fileno];
Jens Axboe429f6672007-07-23 10:38:43 +020087 get_file(io_u->file);
88
Jens Axboeee56ad52008-02-01 10:30:20 +010089 dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset,
90 io_u->buflen, io_u->file->file_name);
91
Jens Axboea61edde2007-05-15 14:29:58 +020092 if (ipo->delay)
93 iolog_delay(td, ipo->delay);
94
Jens Axboe3c39a372006-06-06 20:56:12 +020095 free(ipo);
96 return 0;
97 }
98
Jens Axboe20e354e2007-07-23 14:36:16 +020099 td->done = 1;
Jens Axboe3c39a372006-06-06 20:56:12 +0200100 return 1;
101}
102
103void prune_io_piece_log(struct thread_data *td)
104{
105 struct io_piece *ipo;
Jens Axboe4b878982007-03-26 09:32:22 +0200106 struct rb_node *n;
Jens Axboe3c39a372006-06-06 20:56:12 +0200107
Jens Axboe4b878982007-03-26 09:32:22 +0200108 while ((n = rb_first(&td->io_hist_tree)) != NULL) {
109 ipo = rb_entry(n, struct io_piece, rb_node);
110 rb_erase(n, &td->io_hist_tree);
Jens Axboe3c39a372006-06-06 20:56:12 +0200111 free(ipo);
112 }
Jens Axboe8ce9cd32008-02-21 09:52:35 +0100113
114 while (!list_empty(&td->io_hist_list)) {
115 ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
116 list_del(&ipo->list);
117 free(ipo);
118 }
Jens Axboe3c39a372006-06-06 20:56:12 +0200119}
120
121/*
Jens Axboe34403fb2007-03-02 21:43:25 +0100122 * log a successful write, so we can unwind the log for verify
Jens Axboe3c39a372006-06-06 20:56:12 +0200123 */
124void log_io_piece(struct thread_data *td, struct io_u *io_u)
125{
Jens Axboe8de8f042007-03-27 10:36:12 +0200126 struct rb_node **p, *parent;
Jens Axboe4b878982007-03-26 09:32:22 +0200127 struct io_piece *ipo, *__ipo;
Jens Axboe3c39a372006-06-06 20:56:12 +0200128
Jens Axboe4b878982007-03-26 09:32:22 +0200129 ipo = malloc(sizeof(struct io_piece));
Jens Axboe53cdc682006-10-18 11:50:58 +0200130 ipo->file = io_u->file;
Jens Axboe3c39a372006-06-06 20:56:12 +0200131 ipo->offset = io_u->offset;
132 ipo->len = io_u->buflen;
133
134 /*
Jens Axboe8de8f042007-03-27 10:36:12 +0200135 * We don't need to sort the entries, if:
136 *
137 * Sequential writes, or
138 * Random writes that lay out the file as it goes along
139 *
140 * For both these cases, just reading back data in the order we
141 * wrote it out is the fastest.
142 */
Jens Axboe9b23c9f2008-02-21 09:51:32 +0100143 if (!td_random(td) || !td->o.overwrite) {
Jens Axboe8de8f042007-03-27 10:36:12 +0200144 INIT_LIST_HEAD(&ipo->list);
145 list_add_tail(&ipo->list, &td->io_hist_list);
146 return;
147 }
148
149 RB_CLEAR_NODE(&ipo->rb_node);
150 p = &td->io_hist_tree.rb_node;
151 parent = NULL;
152
153 /*
Jens Axboe4b878982007-03-26 09:32:22 +0200154 * Sort the entry into the verification list
Jens Axboe3c39a372006-06-06 20:56:12 +0200155 */
Jens Axboe4b878982007-03-26 09:32:22 +0200156 while (*p) {
157 parent = *p;
Jens Axboe3c39a372006-06-06 20:56:12 +0200158
Jens Axboe4b878982007-03-26 09:32:22 +0200159 __ipo = rb_entry(parent, struct io_piece, rb_node);
Jens Axboebb5d7d02007-03-27 10:21:25 +0200160 if (ipo->offset <= __ipo->offset)
Jens Axboe4b878982007-03-26 09:32:22 +0200161 p = &(*p)->rb_left;
Jens Axboe4b878982007-03-26 09:32:22 +0200162 else
Jens Axboebb5d7d02007-03-27 10:21:25 +0200163 p = &(*p)->rb_right;
Jens Axboe3c39a372006-06-06 20:56:12 +0200164 }
165
Jens Axboe4b878982007-03-26 09:32:22 +0200166 rb_link_node(&ipo->rb_node, parent, p);
167 rb_insert_color(&ipo->rb_node, &td->io_hist_tree);
Jens Axboe3c39a372006-06-06 20:56:12 +0200168}
169
170void write_iolog_close(struct thread_data *td)
171{
172 fflush(td->iolog_f);
173 fclose(td->iolog_f);
174 free(td->iolog_buf);
Jens Axboef29b25a2007-07-23 08:56:43 +0200175 td->iolog_f = NULL;
176 td->iolog_buf = NULL;
Jens Axboe3c39a372006-06-06 20:56:12 +0200177}
178
Jens Axboefb71fbd2006-10-20 09:15:46 +0200179/*
Jens Axboef29b25a2007-07-23 08:56:43 +0200180 * Read version 2 iolog data. It is enhanced to include per-file logging,
181 * syncs, etc.
Jens Axboefb71fbd2006-10-20 09:15:46 +0200182 */
Jens Axboef29b25a2007-07-23 08:56:43 +0200183static int read_iolog2(struct thread_data *td, FILE *f)
184{
185 unsigned long long offset;
186 unsigned int bytes;
Jens Axboe53fa9b62007-07-23 11:25:39 +0200187 int reads, writes, fileno = 0, file_action = 0; /* stupid gcc */
Jens Axboef29b25a2007-07-23 08:56:43 +0200188 char *fname, *act;
189 char *str, *p;
Jens Axboe53fa9b62007-07-23 11:25:39 +0200190 enum fio_ddir rw;
Jens Axboef29b25a2007-07-23 08:56:43 +0200191
192 free_release_files(td);
193
194 /*
195 * Read in the read iolog and store it, reuse the infrastructure
196 * for doing verifications.
197 */
198 str = malloc(4096);
199 fname = malloc(256+16);
200 act = malloc(256+16);
201
202 reads = writes = 0;
203 while ((p = fgets(str, 4096, f)) != NULL) {
204 struct io_piece *ipo;
205 int r;
206
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100207 r = sscanf(p, "%256s %256s %llu %u", fname, act, &offset,
208 &bytes);
Jens Axboef29b25a2007-07-23 08:56:43 +0200209 if (r == 4) {
210 /*
211 * Check action first
212 */
213 if (!strcmp(act, "read"))
214 rw = DDIR_READ;
215 else if (!strcmp(act, "write"))
216 rw = DDIR_WRITE;
217 else if (!strcmp(act, "sync"))
218 rw = DDIR_SYNC;
219 else {
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100220 log_err("fio: bad iolog file action: %s\n",
221 act);
Jens Axboef29b25a2007-07-23 08:56:43 +0200222 continue;
223 }
224 } else if (r == 2) {
225 rw = DDIR_INVAL;
226 if (!strcmp(act, "add")) {
227 td->o.nr_files++;
228 fileno = add_file(td, fname);
229 file_action = FIO_LOG_ADD_FILE;
230 continue;
231 } else if (!strcmp(act, "open")) {
232 fileno = get_fileno(td, fname);
233 file_action = FIO_LOG_OPEN_FILE;
234 } else if (!strcmp(act, "close")) {
235 fileno = get_fileno(td, fname);
236 file_action = FIO_LOG_CLOSE_FILE;
237 } else {
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100238 log_err("fio: bad iolog file action: %s\n",
239 act);
Jens Axboef29b25a2007-07-23 08:56:43 +0200240 continue;
241 }
242 } else {
243 log_err("bad iolog2: %s", p);
244 continue;
245 }
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100246
Jens Axboef29b25a2007-07-23 08:56:43 +0200247 if (rw == DDIR_READ)
248 reads++;
Jens Axboe4241ea82007-09-12 08:18:36 +0200249 else if (rw == DDIR_WRITE) {
Jens Axboef29b25a2007-07-23 08:56:43 +0200250 writes++;
Jens Axboe4241ea82007-09-12 08:18:36 +0200251 /*
252 * Don't add a write for ro mode
253 */
254 if (read_only)
255 continue;
256 } else if (rw != DDIR_SYNC && rw != DDIR_INVAL) {
Jens Axboef29b25a2007-07-23 08:56:43 +0200257 log_err("bad ddir: %d\n", rw);
258 continue;
259 }
260
261 /*
262 * Make note of file
263 */
264 ipo = malloc(sizeof(*ipo));
265 memset(ipo, 0, sizeof(*ipo));
266 INIT_LIST_HEAD(&ipo->list);
267 ipo->offset = offset;
268 ipo->len = bytes;
Jens Axboe53fa9b62007-07-23 11:25:39 +0200269 ipo->ddir = rw;
Jens Axboef29b25a2007-07-23 08:56:43 +0200270 if (bytes > td->o.max_bs[rw])
271 td->o.max_bs[rw] = bytes;
272 if (rw == DDIR_INVAL) {
273 ipo->fileno = fileno;
274 ipo->file_action = file_action;
275 }
276 list_add_tail(&ipo->list, &td->io_log_list);
Jens Axboeea966f82007-09-03 10:09:37 +0200277 td->total_io_size += bytes;
Jens Axboef29b25a2007-07-23 08:56:43 +0200278 }
279
280 free(str);
281 free(act);
282 free(fname);
283
Jens Axboe4241ea82007-09-12 08:18:36 +0200284 if (writes && read_only) {
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100285 log_err("fio: <%s> skips replay of %d writes due to"
286 " read-only\n", td->o.name, writes);
Jens Axboe4241ea82007-09-12 08:18:36 +0200287 writes = 0;
288 }
289
Jens Axboef29b25a2007-07-23 08:56:43 +0200290 if (!reads && !writes)
291 return 1;
292 else if (reads && !writes)
293 td->o.td_ddir = TD_DDIR_READ;
294 else if (!reads && writes)
295 td->o.td_ddir = TD_DDIR_WRITE;
296 else
297 td->o.td_ddir = TD_DDIR_RW;
298
299 return 0;
300}
301
302/*
303 * Read version 1 iolog data.
304 */
305static int read_iolog(struct thread_data *td, FILE *f)
Jens Axboe3c39a372006-06-06 20:56:12 +0200306{
307 unsigned long long offset;
308 unsigned int bytes;
309 char *str, *p;
Jens Axboe21bd2982007-07-23 11:26:27 +0200310 int reads, writes;
gurudas pai59b9ddf2007-10-22 22:10:39 +0200311 int rw;
Jens Axboe3c39a372006-06-06 20:56:12 +0200312
Jens Axboe3c39a372006-06-06 20:56:12 +0200313 /*
Jens Axboe3c39a372006-06-06 20:56:12 +0200314 * Read in the read iolog and store it, reuse the infrastructure
315 * for doing verifications.
316 */
317 str = malloc(4096);
Jens Axboefb71fbd2006-10-20 09:15:46 +0200318 reads = writes = 0;
Jens Axboe3c39a372006-06-06 20:56:12 +0200319 while ((p = fgets(str, 4096, f)) != NULL) {
320 struct io_piece *ipo;
321
322 if (sscanf(p, "%d,%llu,%u", &rw, &offset, &bytes) != 3) {
Jens Axboe3b70d7e2006-06-08 21:48:46 +0200323 log_err("bad iolog: %s\n", p);
Jens Axboe3c39a372006-06-06 20:56:12 +0200324 continue;
325 }
326 if (rw == DDIR_READ)
327 reads++;
Jens Axboe4241ea82007-09-12 08:18:36 +0200328 else if (rw == DDIR_WRITE) {
Jens Axboe3c39a372006-06-06 20:56:12 +0200329 writes++;
Jens Axboe4241ea82007-09-12 08:18:36 +0200330 /*
331 * Don't add a write for ro mode
332 */
333 if (read_only)
334 continue;
335 } else if (rw != DDIR_SYNC) {
Jens Axboe3b70d7e2006-06-08 21:48:46 +0200336 log_err("bad ddir: %d\n", rw);
Jens Axboe3c39a372006-06-06 20:56:12 +0200337 continue;
338 }
339
340 ipo = malloc(sizeof(*ipo));
Jens Axboe733ed592007-04-25 14:24:12 +0200341 memset(ipo, 0, sizeof(*ipo));
Jens Axboe3c39a372006-06-06 20:56:12 +0200342 INIT_LIST_HEAD(&ipo->list);
343 ipo->offset = offset;
344 ipo->len = bytes;
gurudas pai59b9ddf2007-10-22 22:10:39 +0200345 ipo->ddir = (enum fio_ddir) rw;
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100346 if (bytes > td->o.max_bs[rw])
347 td->o.max_bs[rw] = bytes;
Jens Axboe3c39a372006-06-06 20:56:12 +0200348 list_add_tail(&ipo->list, &td->io_log_list);
Jens Axboeea966f82007-09-03 10:09:37 +0200349 td->total_io_size += bytes;
Jens Axboe3c39a372006-06-06 20:56:12 +0200350 }
351
352 free(str);
Jens Axboe3c39a372006-06-06 20:56:12 +0200353
Jens Axboe4241ea82007-09-12 08:18:36 +0200354 if (writes && read_only) {
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100355 log_err("fio: <%s> skips replay of %d writes due to"
356 " read-only\n", td->o.name, writes);
Jens Axboe4241ea82007-09-12 08:18:36 +0200357 writes = 0;
358 }
359
Jens Axboefb71fbd2006-10-20 09:15:46 +0200360 if (!reads && !writes)
Jens Axboe3c39a372006-06-06 20:56:12 +0200361 return 1;
Jens Axboefb71fbd2006-10-20 09:15:46 +0200362 else if (reads && !writes)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100363 td->o.td_ddir = TD_DDIR_READ;
Jens Axboe3c39a372006-06-06 20:56:12 +0200364 else if (!reads && writes)
Jens Axboe36361eb2007-05-15 11:12:19 +0200365 td->o.td_ddir = TD_DDIR_WRITE;
Jens Axboe3c39a372006-06-06 20:56:12 +0200366 else
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100367 td->o.td_ddir = TD_DDIR_RW;
Jens Axboe3c39a372006-06-06 20:56:12 +0200368
369 return 0;
370}
Jens Axboe8914a9d2006-06-07 11:14:56 +0200371
Jens Axboefb71fbd2006-10-20 09:15:46 +0200372/*
Jens Axboef29b25a2007-07-23 08:56:43 +0200373 * open iolog, check version, and call appropriate parser
374 */
375static int init_iolog_read(struct thread_data *td)
376{
377 char buffer[256], *p;
378 FILE *f;
379 int ret;
380
381 f = fopen(td->o.read_iolog_file, "r");
382 if (!f) {
383 perror("fopen read iolog");
384 return 1;
385 }
386
387 p = fgets(buffer, sizeof(buffer), f);
388 if (!p) {
389 td_verror(td, errno, "iolog read");
390 log_err("fio: unable to read iolog\n");
391 return 1;
392 }
393
394 /*
395 * version 2 of the iolog stores a specific string as the
396 * first line, check for that
397 */
398 if (!strncmp(iolog_ver2, buffer, strlen(iolog_ver2)))
399 ret = read_iolog2(td, f);
400 else {
401 /*
402 * seek back to the beginning
403 */
404 if (fseek(f, 0, SEEK_SET) < 0) {
405 td_verror(td, errno, "iolog read");
406 log_err("fio: unable to read iolog\n");
407 return 1;
408 }
409
410 ret = read_iolog(td, f);
411 }
412
413 fclose(f);
414 return ret;
415}
416
417/*
Jens Axboefb71fbd2006-10-20 09:15:46 +0200418 * Setup a log for storing io patterns.
419 */
420static int init_iolog_write(struct thread_data *td)
421{
Jens Axboef29b25a2007-07-23 08:56:43 +0200422 struct fio_file *ff;
Jens Axboe076efc72006-10-27 11:24:25 +0200423 FILE *f;
Jens Axboef29b25a2007-07-23 08:56:43 +0200424 unsigned int i;
Jens Axboe733ed592007-04-25 14:24:12 +0200425
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100426 f = fopen(td->o.write_iolog_file, "w+");
Jens Axboefb71fbd2006-10-20 09:15:46 +0200427 if (!f) {
428 perror("fopen write iolog");
429 return 1;
430 }
431
432 /*
433 * That's it for writing, setup a log buffer and we're done.
434 */
435 td->iolog_f = f;
436 td->iolog_buf = malloc(8192);
437 setvbuf(f, td->iolog_buf, _IOFBF, 8192);
Jens Axboef29b25a2007-07-23 08:56:43 +0200438
439 /*
440 * write our version line
441 */
442 if (fprintf(f, "%s\n", iolog_ver2) < 0) {
443 perror("iolog init\n");
444 return 1;
445 }
446
447 /*
448 * add all known files
449 */
450 for_each_file(td, ff, i)
451 log_file(td, ff, FIO_LOG_ADD_FILE);
452
Jens Axboefb71fbd2006-10-20 09:15:46 +0200453 return 0;
454}
455
456int init_iolog(struct thread_data *td)
457{
Jens Axboeb4a6a592006-10-20 13:54:47 +0200458 int ret = 0;
Jens Axboefb71fbd2006-10-20 09:15:46 +0200459
Jens Axboeba0fbe12007-03-09 14:34:23 +0100460 if (td->io_ops->flags & FIO_DISKLESSIO)
Jens Axboef48b4672006-10-27 11:30:07 +0200461 return 0;
462
Jens Axboefb7b71a2007-05-15 08:44:04 +0200463 if (td->o.read_iolog_file) {
464 /*
465 * Check if it's a blktrace file and load that if possible.
466 * Otherwise assume it's a normal log file and load that.
467 */
468 if (is_blktrace(td->o.read_iolog_file))
469 ret = load_blktrace(td, td->o.read_iolog_file);
470 else
471 ret = init_iolog_read(td);
472 } else if (td->o.write_iolog_file)
Jens Axboeb4a6a592006-10-20 13:54:47 +0200473 ret = init_iolog_write(td);
474
Jens Axboe1e97cce2006-12-05 11:44:16 +0100475 return ret;
Jens Axboefb71fbd2006-10-20 09:15:46 +0200476}
477
Jens Axboe8914a9d2006-06-07 11:14:56 +0200478void setup_log(struct io_log **log)
479{
480 struct io_log *l = malloc(sizeof(*l));
481
482 l->nr_samples = 0;
483 l->max_samples = 1024;
484 l->log = malloc(l->max_samples * sizeof(struct io_sample));
485 *log = l;
486}
487
Jens Axboebb3884d2007-01-17 17:23:11 +1100488void __finish_log(struct io_log *log, const char *name)
Jens Axboe8914a9d2006-06-07 11:14:56 +0200489{
Jens Axboe8914a9d2006-06-07 11:14:56 +0200490 unsigned int i;
Jens Axboebb3884d2007-01-17 17:23:11 +1100491 FILE *f;
Jens Axboe8914a9d2006-06-07 11:14:56 +0200492
Jens Axboebb3884d2007-01-17 17:23:11 +1100493 f = fopen(name, "w");
Jens Axboe8914a9d2006-06-07 11:14:56 +0200494 if (!f) {
495 perror("fopen log");
496 return;
497 }
498
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100499 for (i = 0; i < log->nr_samples; i++) {
500 fprintf(f, "%lu, %lu, %u\n", log->log[i].time, log->log[i].val,
501 log->log[i].ddir);
502 }
Jens Axboe8914a9d2006-06-07 11:14:56 +0200503
504 fclose(f);
505 free(log->log);
506 free(log);
507}
Jens Axboebb3884d2007-01-17 17:23:11 +1100508
509void finish_log(struct thread_data *td, struct io_log *log, const char *name)
510{
511 char file_name[256];
512
513 snprintf(file_name, 200, "client%d_%s.log", td->thread_number, name);
514 __finish_log(log, file_name);
515}