Introduce the end_syncfs option
v3 cover Introduce the end_syncfs option
Jens, Vincent,
This patch series introduces the end_syncfs option and adds support for it to the main IO engines that can handle regular files. This new option improves the precision of file system benchmarks when a large number of files are being handled.
Changes from v2:
- Reworked patch 1 to build a list of file system mounts per job and have the end_syncfs option issue syncfs() call for eacho mounted file system when a job write stage completes.
- Added patch 2 to 7 to support this new option in hte sync, libaio, io_uring, fallocate, fileoperations, ftruncate and posixaio IO engines.
Damien Le Moal (8):
fio: introduce the end_syncfs option
engines: sync: add support for DDIR_SYNCFS
engines: libaio: add support for DDIR_SYNCFS
engines: io_uring: add support for DDIR_SYNCFS
engines: fallocate: add support for DDIR_SYNCFS
engines: fileoperations: add support for DDIR_SYNCFS
engines: ftruncate: add support for DDIR_SYNCFS
engines: posixaio: add support for DDIR_SYNCFS
HOWTO.rst | 9 ++- backend.c | 59 ++++++++++++++---- cconv.c | 2 + configure | 21 +++++++ engines/falloc.c | 4 +- engines/fileoperations.c | 8 +-- engines/ftruncate.c | 4 +- engines/io_uring.c | 16 +++-- engines/libaio.c | 8 ++- engines/posixaio.c | 8 ++- engines/sync.c | 11 ++-- file.h | 15 +++++ filesetup.c | 129 ++++++++++++++++++++++++++++++++++++--- fio.1 | 8 ++- fio.h | 1 + helpers.c | 8 +++ helpers.h | 3 + init.c | 1 + io_ddir.h | 3 +- io_u.c | 6 +- ioengines.c | 10 ++- ioengines.h | 4 ++ options.c | 19 ++++++ server.h | 2 +- stat.c | 3 +- thread_options.h | 5 +- zbd.c | 1 + 27 files changed, 319 insertions(+), 49 deletions(-)
Signature · 1 line
2.53.0
PATCH v3 1/8 fio: introduce the end_syncfs option
When benchmarking buffered I/O file write workloads with file systems, the options fsync, fsync_on_close and end_fsync allow getting performance statistics accounting for all file data safely written to the file system device media. All these options can be used in different scenarios to emulate applications use of the fsync() system call.
However, these different options all involve using the fsync() system call against every written files, with the files being open. Depending on the file system, this characteristic is very limiting. E.g. the XFS file system optimizes data placement of closed files to store these files tightly in the same block group in order to generate a write command pattern that is very sequential and localized. The use of fio existing sync option variants thus does not allow measuring the performance benefits of this optimization. Furthermore, the option end_fsync applies to all files of a job, causing a loop to open, fsync() and close each written file. For benchmarks with a very large number of files (e.g. a long run), this is very ineficient and slow, and often causes the performance results to be much lower than expected.
Extending the sync operation variants to include the ability to use the syncfs() system call can solve these issues. Allow this by introducing the new end_syncfs option.
If enabled, the end_syncfs option results in a call to the syncfs() system call when a job completes. This allows syncing all written files with a single system call and also avoids the need to reopen all written files. This is thus much faster than using end_fsync, and also enables file system writeback optimizations that rely on the files being written back to be closed.
The syncfs() system call is supported by Linux only. This support is detected in the configure script and if detected, the CONFIG_SYNCFS configuration option defined. When not supported, the helpers.c file defines the syncfs() function to return an error. The option end_syncfs is allowed only when CONFIG_SYNCFS is defined.
Like other sync variants, end_syncfs causes issuing an io_u when a job completes so that the time taken to write back all written files is accounted for in the final performance statistics. The io_u data direction DDIR_SYNCFS is defined to control this. A DDIR_SYNCFS io_u is issued using the same function fio_io_sync() as for other sync variants. Calls to fio_io_sync() are driven with the new function fio_syncfs(), which iterates a list of struct fio_mount representing the mounted file systems for the files of a job thread. This list is built using the helper function add_file_fs(), called from setup_files(), and using the new fs_list struct flist_head defined for each thread. This list is freed on completion of a thread with a call to free_fs_list() from free_release_files().
struct fio_mount definition is moved to file.h to allow iterating a thread fs_list entries in backend.c. This structure is also augmented with a pointer to a struct fio_file and to an open directory stream (dir field). These new entries are used to avoid opening one of the file of a thread for a file system entry and instead used to allocate and initialize a struct fio_file representing the parent directory of a file of the file system entry. This is managed with the helper functions fio_open_fs() and fio_close_fs() which are used before and after calling fio_io_sync() in fio_syncfs().
Finally, since support for executing the syncfs() system call depends on the IO engine used, the engine flags FIO_SYNCFS and FIO_ASYNCIO_SYNC_SYNCFS are defined to allow indicating if an IO engine supports DDIR_SYNCFS operations.
--- HOWTO.rst | 9 +++- backend.c | 59 ++++++++++++++++++---- cconv.c | 2 + configure | 21 ++++++++ file.h | 15 ++++++ filesetup.c | 129 ++++++++++++++++++++++++++++++++++++++++++++--- fio.1 | 8 ++- fio.h | 1 + helpers.c | 8 +++ helpers.h | 3 ++ init.c | 1 + io_ddir.h | 3 +- io_u.c | 6 ++- ioengines.c | 10 +++- ioengines.h | 4 ++ options.c | 19 +++++++ server.h | 2 +- stat.c | 3 +- thread_options.h | 5 +- zbd.c | 1 + 20 files changed, 282 insertions(+), 27 deletions(-)
HOWTO.rst +8 -1
@@ -1450,7 +1450,7 @@ I/O type using non-buffered I/O, we may not sync the file. The exception is the sg I/O engine, which synchronizes the disk cache anyway. Defaults to 0, which means fio does not periodically issue and wait for a sync to complete. Also - see :option:`end_fsync` and :option:`fsync_on_close`. + see :option:`end_fsync`, :option:`fsync_on_close`, and :option:`end_syncfs`. .. option:: fdatasync=int
@@ -1494,6 +1494,13 @@ I/O type If true, :manpage:`fsync(2)` file contents when a write stage has completed. Default: false. +.. option:: end_syncfs=bool + + Equivalent to :option:`end_fsync` but instead of executing + :manpage:`fsync(2)` for each file of a write stage, executes + :manpage:`syncfs(2)` to synchronize all written files with a single + system call when a write stage has completed. Default: false. + .. option:: fsync_on_close=bool If true, fio will :manpage:`fsync(2)` a dirty file on close. This differs
backend.c +48 -11
102 lines not on this page · raw message
cconv.c +2 -0
@@ -176,6 +176,7 @@ int convert_thread_options_to_cpu(struct thread_options *o, o->create_only =le32_to_cpu (top->create_only); o->filetype =le32_to_cpu (top->filetype); o->end_fsync =le32_to_cpu (top->end_fsync); + o->end_syncfs =le32_to_cpu (top->end_syncfs); o->pre_read =le32_to_cpu (top->pre_read); o->sync_io =le32_to_cpu (top->sync_io); o->write_hint =le32_to_cpu (top->write_hint);
@@ -447,6 +448,7 @@ void convert_thread_options_to_net(struct thread_options_pack *top, top->create_only =cpu_to_le32 (o->create_only); top->filetype =cpu_to_le32 (o->filetype); top->end_fsync =cpu_to_le32 (o->end_fsync); + top->end_syncfs =cpu_to_le32 (o->end_syncfs); top->pre_read =cpu_to_le32 (o->pre_read); top->sync_io =cpu_to_le32 (o->sync_io); top->write_hint =cpu_to_le32 (o->write_hint);
configure +21 -0
@@ -1327,6 +1327,24 @@ if compile_prog "" "" "sync_file_range"; then fi print_config "sync_file_range" "$sync_file_range" +########################################## +# syncfs() probe +if test "$syncfs" != "yes" ; then + syncfs="no" +fi +cat > $TMPC << EOF +#include <stdio.h> +#include <unistd.h> +int main(int argc, char **argv) +{ + return syncfs(0); +} +EOF +if compile_prog "" "" "syncfs"; then + syncfs="yes" +fi +print_config "syncfs" "$syncfs" + ########################################## # ASharedMemory_create() probe if test "$ASharedMemory_create" != "yes" ; then
@@ -3132,6 +3150,9 @@ fi if test "$sync_file_range" = "yes" ; then output_sym "CONFIG_SYNC_FILE_RANGE" fi +if test "$syncfs" = "yes" ; then + output_sym "CONFIG_SYNCFS" +fi if test "$ASharedMemory_create" = "yes" ; then output_sym "CONFIG_ASHAREDMEMORY_CREATE" fi
file.h +15 -0
@@ -22,6 +22,7 @@ enum fio_filetype {FIO_TYPE_BLOCK ,/* block device */ FIO_TYPE_CHAR ,/* character device */ FIO_TYPE_PIPE ,/* pipe */ + FIO_TYPE_DIR, /* directory */ }; enum fio_file_flags {
@@ -194,6 +195,18 @@ FILE_FLAG_FNS(lfsr);FILE_FLAG_FNS (smalloc);#undef FILE_FLAG_FNS +/* +* File FS mount information. +*/ +struct fio_mount { +struct flist_head list; +const char *base; +char __base[256 ]; +unsigned int key; +struct fio_file *f; +void *dir; +}; +/* * File setup/shutdown */
@@ -235,5 +248,7 @@ extern bool fio_files_done(struct thread_data *);extern bool exists_and_not_regfile (const char *);extern int fio_set_directio (struct thread_data *,struct fio_file *);extern void fio_file_free (struct fio_file *); +extern int fio_open_fs (struct thread_data *td,struct fio_mount *fm); +extern void fio_close_fs (struct fio_mount *fm);#endif
filesetup.c +122 -7
162 lines not on this page · raw message
fio.1 +7 -1
@@ -1239,7 +1239,7 @@ as a parameter, fio will sync the file after every 32 writes issued. If fio is using non-buffered I/O, we may not sync the file. The exception is the sg I/O engine, which synchronizes the disk cache anyway. Defaults to 0, which means fio does not periodically issue and wait for a sync to complete. Also -see \fBend_fsync\fR and \fBfsync_on_close\fR. +see \fBend_fsync\fR, \fBend_syncfs\fR and \fBfsync_on_close\fR. .TP .BI fdatasync \fR=\fPint Like \fBfsync\fR but uses \fBfdatasync\fR\|(2) to only sync data and
@@ -1284,6 +1284,12 @@ will be done. Default: false. If true, \fBfsync\fR\|(2) file contents when a write stage has completed. Default: false. .TP +.BI end_syncfs \fR=\fPbool +Equivalent to \fBend_fsync\fR but instead of executing \fBfsync\fR\|(2) for +each file of a write stage, execute \fBsyncfs\fR\|(2) to synchronize all +written files with a single system call when a write stage has completed. +Default: false. +.TP .BI fsync_on_close \fR=\fPbool If true, fio will \fBfsync\fR\|(2) a dirty file on close. This differs from \fBend_fsync\fR in that it will happen on every file close, not
fio.h +1 -0
@@ -230,6 +230,7 @@ struct thread_data {struct rusage ru_start;struct rusage ru_end; +struct flist_head fs_list;struct fio_file **files;unsigned char *file_locks;unsigned int files_size;
helpers.c +8 -0
@@ -26,6 +26,14 @@ int sync_file_range(int fd, uint64_t offset, uint64_t nbytes, }#endif +#ifndef CONFIG_SYNCFS +int syncfs (int fd) +{ + errno =ENOSYS ; +return -1 ; +} +#endif +#ifndef CONFIG_POSIX_FADVISE int posix_fadvise (int fd,off_t offset,off_t len,int advice) {
helpers.h +3 -0
@@ -11,6 +11,9 @@ extern int posix_fallocate(int fd, off_t offset, off_t len);extern int sync_file_range (int fd,uint64_t offset,uint64_t nbytes,unsigned int flags);#endif +#ifndef CONFIG_SYNCFS +extern int syncfs (int fd); +#endif extern int posix_fadvise (int fd,off_t offset,off_t len,int advice);#endif /* FIO_HELPERS_H_ */
init.c +1 -0
@@ -508,6 +508,7 @@ static struct thread_data *get_new_job(bool global, struct thread_data *parent, td->o.uid = td->o.gid =-1U ; +INIT_FLIST_HEAD (&td->fs_list);dup_files (td, parent);fio_options_mem_dupe (td);
io_ddir.h +2 -1
@@ -8,6 +8,7 @@ enum fio_ddir {DDIR_SYNC =3 ,DDIR_DATASYNC ,DDIR_SYNC_FILE_RANGE , +DDIR_SYNCFS ,DDIR_WAIT ,DDIR_LAST , DDIR_INVAL = -1,
@@ -59,7 +60,7 @@ enum td_ddir {static inline int ddir_sync (enum fio_ddir ddir) {return ddir ==DDIR_SYNC || ddir ==DDIR_DATASYNC || - ddir ==DDIR_SYNC_FILE_RANGE ; + ddir ==DDIR_SYNC_FILE_RANGE || ddir ==DDIR_SYNCFS ; }static inline int ddir_rw (enum fio_ddir ddir)
io_u.c +4 -2
@@ -2482,9 +2482,11 @@ int do_io_u_sync(const struct thread_data *td, struct io_u *io_u) ret = io_u->xfer_buflen; io_u->error =EINVAL ;#endif - }else if (io_u->ddir ==DDIR_SYNC_FILE_RANGE ) + }else if (io_u->ddir ==DDIR_SYNC_FILE_RANGE ) { ret =do_sync_file_range (td, io_u->file); -else { + }else if (io_u->ddir ==DDIR_SYNCFS ) { + ret =syncfs (io_u->file->fd); + }else { ret = io_u->xfer_buflen; io_u->error =EINVAL ; }
ioengines.c +9 -1
@@ -32,6 +32,13 @@ static inline bool async_ioengine_sync_trim(struct thread_data *td, io_u->ddir ==DDIR_TRIM ; } +static inline bool async_ioengine_sync_syncfs (struct thread_data *td, +struct io_u *io_u) +{ +return td_ioengine_flagged (td,FIO_ASYNCIO_SYNC_SYNCFS ) && + io_u->ddir ==DDIR_SYNCFS ; +} +static bool check_engine_ops (struct thread_data *td,struct ioengine_ops *ops) {if (ops->version !=FIO_IOOPS_VERSION ) {
@@ -363,7 +370,8 @@ enum fio_q_status td_io_queue(struct thread_data *td, struct io_u *io_u) io_u->resid =0 ;if (td_ioengine_flagged (td,FIO_SYNCIO ) || -async_ioengine_sync_trim (td, io_u)) { +async_ioengine_sync_trim (td, io_u) || +async_ioengine_sync_syncfs (td, io_u)) {if (fio_fill_issue_time (td)) {fio_gettime (&io_u->issue_time,NULL );
ioengines.h +4 -0
@@ -90,6 +90,7 @@ enum { __FIO_NOSTATS,/* don't do IO stats */ __FIO_NOFILEHASH,/* doesn't hash the files for lookup later. */ __FIO_ASYNCIO_SYNC_TRIM,/* io engine has async ->queue except for trim */ + __FIO_ASYNCIO_SYNC_SYNCFS,/* io engine has async ->queue except for syncfs */ __FIO_NO_OFFLOAD,/* no async offload */ __FIO_ASYNCIO_SETS_ISSUE_TIME, /* async ioengine with commit function that setsissue_time */
@@ -98,6 +99,7 @@ enum {affects ioengines using generic_open_file */ __FIO_MULTI_RANGE_TRIM,/* ioengine supports trim with more than one range */ __FIO_ATOMICWRITES,/* ioengine supports atomic writes */ + __FIO_SYNCFS,/* ioengine supports syncfs */ __FIO_IOENGINE_F_LAST, /* not a real bit; used to count number of bits */ };
@@ -117,12 +119,14 @@ enum fio_ioengine_flags {FIO_NOSTATS =1 << __FIO_NOSTATS,FIO_NOFILEHASH =1 << __FIO_NOFILEHASH,FIO_ASYNCIO_SYNC_TRIM =1 << __FIO_ASYNCIO_SYNC_TRIM, +FIO_ASYNCIO_SYNC_SYNCFS =1 << __FIO_ASYNCIO_SYNC_SYNCFS,FIO_NO_OFFLOAD =1 << __FIO_NO_OFFLOAD,FIO_ASYNCIO_SETS_ISSUE_TIME =1 << __FIO_ASYNCIO_SETS_ISSUE_TIME,FIO_SKIPPABLE_IOMEM_ALLOC =1 << __FIO_SKIPPABLE_IOMEM_ALLOC,FIO_RO_NEEDS_RW_OPEN =1 << __FIO_RO_NEEDS_RW_OPEN,FIO_MULTI_RANGE_TRIM =1 << __FIO_MULTI_RANGE_TRIM,FIO_ATOMICWRITES =1 << __FIO_ATOMICWRITES, + FIO_SYNCFS = 1 << __FIO_SYNCFS, };/*
options.c +19 -0
@@ -4655,6 +4655,25 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_FILE, .group = FIO_OPT_G_INVALID, }, +#ifdef CONFIG_SYNCFS + { + .name = "end_syncfs", + .lname = "End sync FS", + .type = FIO_OPT_BOOL, + .off1 = offsetof(struct thread_options, end_syncfs), + .help = "Include sync of FS at the end of job", + .def = "0", + .category = FIO_OPT_C_FILE, + .group = FIO_OPT_G_INVALID, + }, +#else + { + .name = "end_syncfs", + .lname = "End sync FS", + .type = FIO_OPT_UNSUPPORTED, + .help = "Your platform does not support syncfs", + }, +#endif { .name = "unlink", .lname = "Unlink file",
server.h +1 -1
@@ -51,7 +51,7 @@ struct fio_net_cmd_reply { };enum { -FIO_SERVER_VER =118 , +FIO_SERVER_VER =119 ,FIO_SERVER_MAX_FRAGMENT_PDU =1024 ,FIO_SERVER_MAX_CMD_MB =2048 ,
stat.c +2 -1
@@ -539,7 +539,8 @@ static void show_ddir_status(const struct group_run_stats *rs, struct thread_staif (ddir_sync (ddir)) {if (calc_lat (&ts->sync_stat, &min, &max, &mean, &dev)) { -log_buf (out," %s:\n" ,"fsync/fdatasync/sync_file_range" ); +log_buf (out," %s:\n" , +"fsync/fdatasync/sync_file_range/syncfs" );display_lat (io_ddir_name (ddir), min, max, mean, dev, out); show_clat_percentiles(ts->io_u_sync_plat, ts->sync_stat.samples,
thread_options.h +4 -1
@@ -138,6 +138,7 @@ struct thread_options {unsigned int create_on_open;unsigned int create_only;unsigned int end_fsync; +unsigned int end_syncfs;unsigned int pre_read;unsigned int sync_io;unsigned int write_hint;
@@ -528,6 +529,8 @@ struct thread_options_pack {uint32_t exitall_error;uint32_t sync_file_range; +uint32_t end_syncfs; +uint32_t pad;struct zone_split zone_split[DDIR_RWDIR_CNT ][ZONESPLIT_MAX ];uint32_t zone_split_nr[DDIR_RWDIR_CNT ];
@@ -627,7 +630,7 @@ struct thread_options_pack {uint32_t lat_percentiles;uint32_t slat_percentiles;uint32_t percentile_precision; -uint32_t pad; +uint32_t pad2;fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN ];uint8_t read_iolog_file[FIO_TOP_STR_MAX ];
zbd.c +1 -0
@@ -2310,6 +2310,7 @@ retry:/* fall-through */ case DDIR_DATASYNC :case DDIR_SYNC_FILE_RANGE : +case DDIR_SYNCFS :case DDIR_WAIT :case DDIR_LAST :case DDIR_INVAL :
Signature · 1 line
2.53.0
PATCH v3 2/8 engines: sync: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the sync IO engine with the FIO_SYNCFS flag to indicate that syncfs operations are supported. No additional changes are needed to enable syncfs processing as this IO engine already processes all sync operation variants using do_io_u_sync().
--- engines/sync.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
engines/sync.c +5 -6
@@ -433,7 +433,7 @@ static struct ioengine_ops ioengine_rw = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO, + .flags = FIO_SYNCIO | FIO_SYNCFS, };static struct ioengine_ops ioengine_prw = {
@@ -443,7 +443,7 @@ static struct ioengine_ops ioengine_prw = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO, + .flags = FIO_SYNCIO | FIO_SYNCFS, };static struct ioengine_ops ioengine_vrw = {
@@ -458,7 +458,7 @@ static struct ioengine_ops ioengine_vrw = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO, + .flags = FIO_SYNCIO | FIO_SYNCFS, };#ifdef CONFIG_PWRITEV
@@ -471,7 +471,7 @@ static struct ioengine_ops ioengine_pvrw = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO, + .flags = FIO_SYNCIO | FIO_SYNCFS, };#endif
@@ -485,8 +485,7 @@ static struct ioengine_ops ioengine_pvrw2 = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO | - FIO_ATOMICWRITES, + .flags = FIO_SYNCIO | FIO_ATOMICWRITES | FIO_SYNCFS, .options = options, .option_struct_size = sizeof(struct psyncv2_options), };
Signature · 1 line
2.53.0
PATCH v3 3/8 engines: libaio: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the libaio engine with the FIO_ASYNCIO_SYNC_SYNCFS flag to indicate that the syncfs operation is supported, with synchronous processing. Modify fio_libaio_queue() to call do_io_u_syncfs() for an io_u that has the DDIR_SYNCFS data direction.
--- engines/libaio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
engines/libaio.c +6 -2
@@ -274,11 +274,14 @@ static enum fio_q_status fio_libaio_queue(struct thread_data *td,if (ld->queued == td->o.iodepth)return FIO_Q_BUSY ; -if (io_u->ddir ==DDIR_TRIM ) { +if (io_u->ddir ==DDIR_TRIM || io_u->ddir ==DDIR_SYNCFS ) {if (ld->queued)return FIO_Q_BUSY ; -do_io_u_trim (td, io_u); +if (io_u->ddir ==DDIR_TRIM ) +do_io_u_trim (td, io_u); +else +do_io_u_sync (td, io_u);io_u_mark_submit (td,1 );io_u_mark_complete (td,1 );return FIO_Q_COMPLETED ;
@@ -456,6 +459,7 @@ FIO_STATIC struct ioengine_ops ioengine = { .name = "libaio", .version = FIO_IOOPS_VERSION, .flags =FIO_ASYNCIO_SYNC_TRIM | +FIO_ASYNCIO_SYNC_SYNCFS |FIO_ASYNCIO_SETS_ISSUE_TIME | FIO_ATOMICWRITES, .init = fio_libaio_init,
Signature · 1 line
2.53.0
PATCH v3 4/8 engines: io_uring: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the io_uring engine with the FIO_ASYNCIO_SYNC_SYNCFS flag to indicate that the syncfs operation is supported, synchronously. Modify fio_ioring_queue() to call do_io_u_sync() for an io_u that has the DDIR_SYNCFS data direction.
--- engines/io_uring.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
engines/io_uring.c +12 -4
@@ -890,12 +890,19 @@ static enum fio_q_status fio_ioring_queue(struct thread_data *td,if (ld->queued == td->o.iodepth)return FIO_Q_BUSY ; -/* if async trim has been tried and failed, punt to sync */ -if (io_u->ddir ==DDIR_TRIM && ld->async_trim_fail) { +/* +* If this is a syncfs request, or if async trim has been tried and +* failed, punt to sync. +* */ +if (io_u->ddir ==DDIR_SYNCFS || + (io_u->ddir ==DDIR_TRIM && ld->async_trim_fail)) {if (ld->queued)return FIO_Q_BUSY ; -do_io_u_trim (td, io_u); +if (io_u->ddir ==DDIR_TRIM ) +do_io_u_trim (td, io_u); +else +do_io_u_sync (td, io_u);io_u_mark_submit (td,1 );io_u_mark_complete (td,1 );
@@ -2013,7 +2020,8 @@ static struct ioengine_ops ioengine_uring_cmd = { .version = FIO_IOOPS_VERSION, .flags =FIO_NO_OFFLOAD |FIO_MEMALIGN |FIO_RAWIO |FIO_ASYNCIO_SETS_ISSUE_TIME | - FIO_MULTI_RANGE_TRIM, +FIO_MULTI_RANGE_TRIM | + FIO_ASYNCIO_SYNC_SYNCFS, .init = fio_ioring_init, .post_init = fio_ioring_cmd_post_init, .io_u_init = fio_ioring_io_u_init,
Signature · 1 line
2.53.0
PATCH v3 5/8 engines: fallocate: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the fallocate IO engine with FIO_SYNCFS to indicate that it supports the syncfs operation. Also fix fio_fallocate_queue() to use ddir_sync() to include all variants of the sync operation for driving the call to do_io_u_sync(), instead of testing for DDIR_SYNC only, which leads to ignoring other sync variants.
--- engines/falloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
engines/falloc.c +2 -2
@@ -76,7 +76,7 @@ static enum fio_q_status fio_fallocate_queue(struct thread_data *td,fio_ro_check (td, io_u); -if (io_u->ddir !=DDIR_SYNC ) { +if (!ddir_sync (io_u->ddir)) {if (io_u->ddir ==DDIR_READ ) flags =FALLOC_FL_KEEP_SIZE ;else if (io_u->ddir ==DDIR_WRITE )
@@ -102,7 +102,7 @@ static struct ioengine_ops ioengine = { .open_file = open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO + .flags = FIO_SYNCIO | FIO_SYNCFS, }; static void fio_init fio_syncio_register(void)
Signature · 1 line
2.53.0
PATCH v3 6/8 engines: fileoperations: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the filecreate, filedelete, dircreate and dirdelete IO engines with FIO_SYNCFS to indicate that they support the syncfs operation. Change the queue_io() function to use ddir_sync() to include all variants of the sync operations for driving the call to do_io_u_sync(), instead of testing for DDIR_SYNC only, which leads to ignoring other sync variants.
--- engines/fileoperations.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
engines/fileoperations.c +4 -4
@@ -264,7 +264,7 @@ static int invalidate_do_nothing(struct thread_data *td, struct fio_file *f)static enum fio_q_status queue_io (struct thread_data *td,struct io_u *io_u) { -if (io_u->ddir ==DDIR_SYNC &&do_io_u_sync (td, io_u)) +if (ddir_sync (io_u->ddir) &&do_io_u_sync (td, io_u)) io_u->error = errno;return FIO_Q_COMPLETED ; }
@@ -329,7 +329,7 @@ static struct ioengine_ops ioengine_filecreate = { .open_file = open_file, .close_file = generic_close_file, .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO | - FIO_NOSTATS | FIO_NOFILEHASH, + FIO_SYNCFS | FIO_NOSTATS | FIO_NOFILEHASH, };static struct ioengine_ops ioengine_filestat = {
@@ -357,7 +357,7 @@ static struct ioengine_ops ioengine_filedelete = { .get_file_size = generic_get_file_size, .open_file = delete_file, .flags = FIO_SYNCIO | FIO_FAKEIO | - FIO_NOSTATS | FIO_NOFILEHASH, + FIO_SYNCFS | FIO_NOSTATS | FIO_NOFILEHASH, };static struct ioengine_ops ioengine_dircreate = {
@@ -403,7 +403,7 @@ static struct ioengine_ops ioengine_dirdelete = { .open_file = delete_file, .unlink_file = remove_dir, .flags = FIO_DISKLESSIO | FIO_SYNCIO | FIO_FAKEIO | - FIO_NOSTATS | FIO_NOFILEHASH, + FIO_SYNCFS | FIO_NOSTATS | FIO_NOFILEHASH, }; static void fio_init fio_fileoperations_register(void)
Signature · 1 line
2.53.0
PATCH v3 7/8 engines: ftruncate: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the ftruncate IO engine with FIO_SYNCFS to indicate that it supports the syncfs operation. Also change fio_ftruncate_queue() to use ddir_sync() to include all variants of the sync operation for driving the call to do_io_u_sync(), instead of testing for DDIR_SYNC only as that leads to ignoring other sync variants.
--- engines/ftruncate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
engines/ftruncate.c +2 -2
@@ -21,7 +21,7 @@ static enum fio_q_status fio_ftruncate_queue(struct thread_data *td,if (io_u->ddir ==DDIR_WRITE ) ret =ftruncate (f->fd, io_u->offset); -else if (io_u->ddir ==DDIR_SYNC ) +else if (ddir_sync (io_u->ddir)) ret =do_io_u_sync (td, io_u);else io_u->error =EINVAL ;
@@ -39,7 +39,7 @@ static struct ioengine_ops ioengine = { .open_file = generic_open_file, .close_file = generic_close_file, .get_file_size = generic_get_file_size, - .flags = FIO_SYNCIO | FIO_FAKEIO + .flags = FIO_SYNCIO | FIO_FAKEIO | FIO_SYNCFS, }; static void fio_init fio_syncio_register(void)
Signature · 1 line
2.53.0
PATCH v3 8/8 engines: posixaio: add support for DDIR_SYNCFS
In reply to Damien Le MoalFlag the posixaio IO engine with FIO_ASYNCIO_SYNC_SYNCFS to indicate that it supports the syncfs operation, synchronously. Also change fio_posixaio_queue() to execute aio_fsync() only for sync operations that are not a syncfs, in which case, we directly call do_io_u_sync().
--- engines/posixaio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
engines/posixaio.c +6 -2
@@ -142,7 +142,10 @@ static enum fio_q_status fio_posixaio_queue(struct thread_data *td,return FIO_Q_COMPLETED ; }else {#ifdef CONFIG_POSIXAIO_FSYNC - ret =aio_fsync (O_SYNC , aiocb); +if (io_u->ddir !=DDIR_SYNCFS ) + ret =aio_fsync (O_SYNC , aiocb); +else + ret =0 ;#else if (pd->queued)return FIO_Q_BUSY ;
@@ -196,7 +199,8 @@ static int fio_posixaio_init(struct thread_data *td)static struct ioengine_ops ioengine = { .name ="posixaio" , .version =FIO_IOOPS_VERSION , - .flags =FIO_ASYNCIO_SYNC_TRIM , + .flags =FIO_ASYNCIO_SYNC_TRIM | +FIO_ASYNCIO_SYNC_SYNCFS , .init = fio_posixaio_init, .prep = fio_posixaio_prep, .queue = fio_posixaio_queue,
Signature · 1 line
2.53.0
The result of fio's continuous integration tests was: failure
For more details see https://github.com/fiotestbot/fio/actions/runs/22474967521