From: Jens Axboe Date: Wed, 24 Oct 2018 00:05:41 +0000 (-0600) Subject: io_u: move trim error notification out-of-line X-Git-Tag: fio-3.12~9 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d7e92306bde2117702ed96b7c5647d9485869047 io_u: move trim error notification out-of-line Also kill dead code, we never touch BLOCK_STATE_WRITTEN as it was guarded by a check for ddir == DDIR_TRIM. The latter should probably be double checked... Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index a3540d14..56abe6fd 100644 --- a/io_u.c +++ b/io_u.c @@ -1798,6 +1798,16 @@ static inline bool gtod_reduce(struct thread_data *td) || td->o.gtod_reduce; } +static void trim_block_info(struct thread_data *td, struct io_u *io_u) +{ + uint32_t *info = io_u_block_info(td, io_u); + + if (BLOCK_INFO_STATE(*info) >= BLOCK_STATE_TRIM_FAILURE) + return; + + *info = BLOCK_INFO(BLOCK_STATE_TRIMMED, BLOCK_INFO_TRIMS(*info) + 1); +} + static void account_io_completion(struct thread_data *td, struct io_u *io_u, struct io_completion_data *icd, const enum fio_ddir idx, unsigned int bytes) @@ -1849,18 +1859,8 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u, } else if (ddir_sync(idx) && !td->o.disable_clat) add_sync_clat_sample(&td->ts, llnsec); - if (td->ts.nr_block_infos && io_u->ddir == DDIR_TRIM) { - uint32_t *info = io_u_block_info(td, io_u); - if (BLOCK_INFO_STATE(*info) < BLOCK_STATE_TRIM_FAILURE) { - if (io_u->ddir == DDIR_TRIM) { - *info = BLOCK_INFO(BLOCK_STATE_TRIMMED, - BLOCK_INFO_TRIMS(*info) + 1); - } else if (io_u->ddir == DDIR_WRITE) { - *info = BLOCK_INFO_SET_STATE(BLOCK_STATE_WRITTEN, - *info); - } - } - } + if (td->ts.nr_block_infos && io_u->ddir == DDIR_TRIM) + trim_block_info(td, io_u); } static void file_log_write_comp(const struct thread_data *td, struct fio_file *f,