Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6dc15e3

Browse files
committed
Use O_DIRECT in O_SYNC test of different size. Restructure O_DIRECT
error reporting to be more consistent.
1 parent3eebb33 commit6dc15e3

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

‎src/tools/fsync/test_fsync.c

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
#defineWRITE_SIZE(8 * 1024)/* 8k */
3333

34-
#defineLABEL_FORMAT" %-32s"
35-
#defineNA_FORMATLABEL_FORMAT "%18s"
34+
#defineLABEL_FORMAT" %-32s"
35+
#defineNA_FORMATLABEL_FORMAT "%18s"
3636

3737

3838
intops_per_test=2000;
@@ -365,19 +365,19 @@ test_sync(int writes_per_op)
365365
* If O_DIRECT is enabled, test that with open_sync
366366
*/
367367
#ifPG_O_DIRECT!=0
368-
if (writes_per_op==1)
369-
printf(LABEL_FORMAT,"open_sync 8k direct I/O write");
370-
else
371-
printf(LABEL_FORMAT,"2 open_sync 8k direct I/O writes");
372-
fflush(stdout);
373-
374368
if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1)
375369
{
376370
printf(NA_FORMAT,"o_direct","n/a**\n");
377371
fs_warning= true;
378372
}
379373
else
380374
{
375+
if (writes_per_op==1)
376+
printf(LABEL_FORMAT,"open_sync 8k direct I/O write");
377+
else
378+
printf(LABEL_FORMAT,"2 open_sync 8k direct I/O writes");
379+
fflush(stdout);
380+
381381
gettimeofday(&start_t,NULL);
382382
for (ops=0;ops<ops_per_test;ops++)
383383
{
@@ -423,47 +423,51 @@ test_open_syncs(void)
423423
printf("(This is designed to compare the cost of one large\n");
424424
printf("sync'ed write and two smaller sync'ed writes.)\n");
425425

426-
/* XXX no PG_O_DIRECT */
427-
428426
/*
429427
* Test open_sync with different size files
430428
*/
431429
#ifdefOPEN_SYNC_FLAG
432-
printf(LABEL_FORMAT,"open_sync 16k write");
433-
fflush(stdout);
434-
435-
if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG,0))==-1)
436-
die("Cannot open output file.");
437-
gettimeofday(&start_t,NULL);
438-
for (ops=0;ops<ops_per_test;ops++)
430+
if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1)
431+
printf(NA_FORMAT,"o_direct","n/a**\n");
432+
else
439433
{
440-
if (write(tmpfile,buf,WRITE_SIZE*2)!=WRITE_SIZE*2)
441-
die("write failed");
442-
if (lseek(tmpfile,0,SEEK_SET)==-1)
443-
die("seek failed");
444-
}
445-
gettimeofday(&stop_t,NULL);
446-
close(tmpfile);
447-
print_elapse(start_t,stop_t);
448-
449-
printf(LABEL_FORMAT,"2 open_sync 8k writes");
450-
fflush(stdout);
434+
printf(LABEL_FORMAT,"open_sync 16k write");
435+
fflush(stdout);
451436

452-
if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG,0))==-1)
453-
die("Cannot open output file.");
454-
gettimeofday(&start_t,NULL);
455-
for (ops=0;ops<ops_per_test;ops++)
437+
gettimeofday(&start_t,NULL);
438+
for (ops=0;ops<ops_per_test;ops++)
439+
{
440+
if (write(tmpfile,buf,WRITE_SIZE*2)!=WRITE_SIZE*2)
441+
die("write failed");
442+
if (lseek(tmpfile,0,SEEK_SET)==-1)
443+
die("seek failed");
444+
}
445+
gettimeofday(&stop_t,NULL);
446+
close(tmpfile);
447+
print_elapse(start_t,stop_t);
448+
}
449+
450+
if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1)
451+
printf(NA_FORMAT,"n/a**\n");
452+
else
456453
{
457-
if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE)
458-
die("write failed");
459-
if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE)
460-
die("write failed");
461-
if (lseek(tmpfile,0,SEEK_SET)==-1)
462-
die("seek failed");
454+
printf(LABEL_FORMAT,"2 open_sync 8k writes");
455+
fflush(stdout);
456+
457+
gettimeofday(&start_t,NULL);
458+
for (ops=0;ops<ops_per_test;ops++)
459+
{
460+
if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE)
461+
die("write failed");
462+
if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE)
463+
die("write failed");
464+
if (lseek(tmpfile,0,SEEK_SET)==-1)
465+
die("seek failed");
466+
}
467+
gettimeofday(&stop_t,NULL);
468+
close(tmpfile);
469+
print_elapse(start_t,stop_t);
463470
}
464-
gettimeofday(&stop_t,NULL);
465-
close(tmpfile);
466-
print_elapse(start_t,stop_t);
467471
#else
468472
printf(NA_FORMAT,"open_sync","n/a\n");
469473
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp