record ioctl elapsed time in zpool history
authorMatthew Ahrens <matthew.ahrens@delphix.com>
Mon, 11 Jan 2021 17:29:25 +0000 (09:29 -0800)
committerGitHub <noreply@github.com>
Mon, 11 Jan 2021 17:29:25 +0000 (09:29 -0800)
commit2ac90457f503e84a3acf8b7c368cd8e44677f7d3
tree913420994b688cfaa273716844b2cfab9a465ec6
parentdc303dcf5b4230d3f53ba999ce3225fcd3b08943
record ioctl elapsed time in zpool history

Each zfs ioctl that changes on-disk state (e.g. set property, create
snapshot, destroy filesystem) is recorded in the zpool history, and is
printed by `zpool history -i`.

For performance diagnostic purposes, it would be useful to know how long
each of these ioctls took to run.  This commit adds that functionality,
with a new `ZPOOL_HIST_ELAPSED_NS` member of the history nvlist.

Additionally, the time recorded in this history log is currently the
time that the history record is written to disk.  But in many cases (CLI
args logging and ioctl logging), this happens asynchronously,
potentially many seconds after the operation completed.  This commit
changes the timestamp to reflect when the history event was created,
rather than when it was written to disk.

Reviewed-by: Mark Maybee <mmaybee@cray.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #11440
cmd/zpool/zpool_main.c
include/sys/fs/zfs.h
module/zfs/spa_history.c
module/zfs/zfs_ioctl.c