iolog: refactor flush_samples()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Thu, 29 Aug 2024 08:58:20 +0000 (17:58 +0900)
committerVincent Fu <vincent.fu@samsung.com>
Wed, 4 Sep 2024 17:59:44 +0000 (13:59 -0400)
commit3ec6b6da9cfe474589a7b3f9d70d047d242a66b7
treed7dcddc227c12620f04bd3448a013489fa956e7e
parent2e7da20db20584d2c894fc49a4ed1a7d94975a26
iolog: refactor flush_samples()

flush_samples() controls the log file format depending on the options
log_avg_msec, log_window_value, log_offset and log_prio. It has deeply
nested branches to check the options. These nested branches make it
difficult to add more fields to the log file format. For ease of the log
file format improvements, refactor the function. Instead of checking all
conditions at once, check each condition one by one, generate small
strings for each field and add them to the final string to output. For
this purpose, introduce the new function print_sample_fields() which
generates each field string.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20240829085826.999859-4-shinichiro.kawasaki@wdc.com
Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
iolog.c