]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
ZFS_IOC_COUNT_FILLED does unnecessary txg_wait_synced()
authorMatthew Ahrens <mahrens@delphix.com>
Tue, 14 Mar 2023 21:30:29 +0000 (14:30 -0700)
committerGitHub <noreply@github.com>
Tue, 14 Mar 2023 21:30:29 +0000 (14:30 -0700)
commit519851122b1703b8445ec17bc89b347cea965bb9
treed6a23896d587a3d1d4e80475e38088773ee02f48
parent78289b84589e632d87504df6a9c63b5ac694d2f9
ZFS_IOC_COUNT_FILLED does unnecessary txg_wait_synced()

`lseek(SEEK_DATA | SEEK_HOLE)` are only accurate when the on-disk blocks
reflect all writes, i.e. when there are no dirty data blocks.  To ensure
this, if the target dnode is dirty, they wait for the open txg to be
synced, so we can call them "stabilizing operations".  If they cause
txg_wait_synced often, it can be detrimental to performance.

Typically, a group of files are all modified, and then SEEK_DATA/HOLE
are performed on them.  In this case, the first SEEK does a
txg_wait_synced(), and subsequent SEEKs don't need to wait, so
performance is good.

However, if a workload involves an interleaved metadata modification,
the subsequent SEEK may do a txg_wait_synced() unnecessarily.  For
example, if we do a `read()` syscall to each file before we do its SEEK.
This applies even with `relatime=on`, when the `read()` is the first
read after the last write.  The txg_wait_synced() is unnecessary because
the SEEK operations only care that the structure of the tree of indirect
and data blocks is up to date on disk.  They don't care about metadata
like the contents of the bonus or spill blocks.  (They also don't care
if an existing data block is modified, but this would be more involved
to filter out.)

This commit changes the behavior of SEEK_DATA/HOLE operations such that
they do not call txg_wait_synced() if there is only a pending change to
the bonus or spill block.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #13368
Issue #14594
Issue #14512
Issue #14009
module/zfs/dnode.c