]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix lseek(SEEK_DATA/SEEK_HOLE) mmap consistency
authorBrian Behlendorf <behlendorf1@llnl.gov>
Sun, 7 Nov 2021 21:27:44 +0000 (13:27 -0800)
committerGitHub <noreply@github.com>
Sun, 7 Nov 2021 21:27:44 +0000 (14:27 -0700)
commitde198f2d9507b6dcf3d0d8f037ba33940208733e
tree79cc6e16cae7527aa51672da56f4cb026053f3bf
parent4b87c1981d47655fd2eec2fb95179818240c4945
Fix lseek(SEEK_DATA/SEEK_HOLE) mmap consistency

When using lseek(2) to report data/holes memory mapped regions of
the file were ignored.  This could result in incorrect results.
To handle this zfs_holey_common() was updated to asynchronously
writeback any dirty mmap(2) regions prior to reporting holes.

Additionally, while not strictly required, the dn_struct_rwlock is
now held over the dirty check to prevent the dnode structure from
changing.  This ensures that a clean dnode can't be dirtied before
the data/hole is located.  The range lock is now also taken to
ensure the call cannot race with zfs_write().

Furthermore, the code was refactored to provide a dnode_is_dirty()
helper function which checks the dnode for any dirty records to
determine its dirtiness.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #11900
Closes #12724
18 files changed:
configure.ac
include/os/freebsd/spl/sys/vnode.h
include/os/freebsd/zfs/sys/zfs_znode_impl.h
include/os/linux/zfs/sys/zfs_znode_impl.h
include/sys/dnode.h
man/man4/zfs.4
module/zfs/dmu.c
module/zfs/dnode.c
module/zfs/zfs_vnops.c
tests/runfiles/common.run
tests/zfs-tests/cmd/Makefile.am
tests/zfs-tests/cmd/mmap_seek/.gitignore [new file with mode: 0644]
tests/zfs-tests/cmd/mmap_seek/Makefile.am [new file with mode: 0644]
tests/zfs-tests/cmd/mmap_seek/mmap_seek.c [new file with mode: 0644]
tests/zfs-tests/include/commands.cfg
tests/zfs-tests/include/tunables.cfg
tests/zfs-tests/tests/functional/mmap/Makefile.am
tests/zfs-tests/tests/functional/mmap/mmap_seek_001_pos.ksh [new file with mode: 0755]