Skip to content

Commit

Permalink
Add TD_F_SYNCS thread flag
Browse files Browse the repository at this point in the history
It's not enough to just track writes, some operating systems require
a file to be opened for write to issue a file sync. Which does kind
of make sense...

Add such a flag and set it for iolog/blktrace replay, if we see a sync
in there.

This does mean we need to bump the IO engine version, as the engine
flags need to get shifted.

Link: axboe#1352
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Feb 26, 2022
1 parent cf25115 commit 78c0d7a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 4 additions & 0 deletions blktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ static bool handle_trace_flush(struct thread_data *td, struct blk_io_trace *t,

ios[DDIR_SYNC]++;
dprint(FD_BLKTRACE, "store flush delay=%lu\n", ipo->delay);

if (!(td->flags & TD_F_SYNCS))
td->flags |= TD_F_SYNCS;

queue_io_piece(td, ipo);
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions fio.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ enum {
__TD_F_MMAP_KEEP,
__TD_F_DIRS_CREATED,
__TD_F_CHECK_RATE,
__TD_F_SYNCS,
__TD_F_LAST, /* not a real bit, keep last */
};

Expand All @@ -118,6 +119,7 @@ enum {
TD_F_MMAP_KEEP = 1U << __TD_F_MMAP_KEEP,
TD_F_DIRS_CREATED = 1U << __TD_F_DIRS_CREATED,
TD_F_CHECK_RATE = 1U << __TD_F_CHECK_RATE,
TD_F_SYNCS = 1U << __TD_F_SYNCS,
};

enum {
Expand Down Expand Up @@ -678,8 +680,8 @@ enum {
TD_NR,
};

#define TD_ENG_FLAG_SHIFT 17
#define TD_ENG_FLAG_MASK ((1U << 17) - 1)
#define TD_ENG_FLAG_SHIFT 18
#define TD_ENG_FLAG_MASK ((1U << 18) - 1)

static inline void td_set_ioengine_flags(struct thread_data *td)
{
Expand Down
2 changes: 1 addition & 1 deletion ioengines.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "io_u.h"
#include "zbd_types.h"

#define FIO_IOOPS_VERSION 30
#define FIO_IOOPS_VERSION 31

#ifndef CONFIG_DYNAMIC_ENGINES
#define FIO_STATIC static
Expand Down
9 changes: 7 additions & 2 deletions iolog.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ static bool read_iolog2(struct thread_data *td)
enum fio_ddir rw;
bool realloc = false;
int64_t items_to_fetch = 0;
int syncs;

if (td->o.read_iolog_chunked) {
items_to_fetch = iolog_items_to_fetch(td);
Expand All @@ -417,7 +418,7 @@ static bool read_iolog2(struct thread_data *td)
rfname = fname = malloc(256+16);
act = malloc(256+16);

reads = writes = waits = 0;
syncs = reads = writes = waits = 0;
while ((p = fgets(str, 4096, td->io_log_rfile)) != NULL) {
struct io_piece *ipo;
int r;
Expand Down Expand Up @@ -492,7 +493,9 @@ static bool read_iolog2(struct thread_data *td)
continue;
waits++;
} else if (rw == DDIR_INVAL) {
} else if (!ddir_sync(rw)) {
} else if (ddir_sync(rw)) {
syncs++;
} else {
log_err("bad ddir: %d\n", rw);
continue;
}
Expand Down Expand Up @@ -547,6 +550,8 @@ static bool read_iolog2(struct thread_data *td)
" read-only\n", td->o.name, writes);
writes = 0;
}
if (syncs)
td->flags |= TD_F_SYNCS;

if (td->o.read_iolog_chunked) {
if (td->io_log_current == 0) {
Expand Down

0 comments on commit 78c0d7a

Please sign in to comment.