]> 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)
committerTony Hutter <hutter2@llnl.gov>
Fri, 5 Nov 2021 15:08:55 +0000 (08:08 -0700)
commit664d487a5dbd758216ac613934a4080fcc1de347
treeecd0b7b292537ca1525155439e4fc3433a199a0e
parent5bf81fea2f899520f2015d2982072f64b7428f71
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]