mirror_zfs/include/os/linux/zfs/sys
adilger f734301d22
linux: add basic fallocate(mode=0/2) compatibility
Implement semi-compatible functionality for mode=0 (preallocation)
and mode=FALLOC_FL_KEEP_SIZE (preallocation beyond EOF) for ZPL.

Since ZFS does COW and snapshots, preallocating blocks for a file
cannot guarantee that writes to the file will not run out of space.
Even if the first overwrite was guaranteed, it would not handle any
later overwrite of blocks due to COW, so strict compliance is futile.
Instead, make a best-effort check that at least enough free space is
currently available in the pool (with a bit of margin), then create
a sparse file of the requested size and continue on with life.

This does not handle all cases (e.g. several fallocate() calls before
writing into the files when the filesystem is nearly full), which
would require a more complex mechanism to be implemented, probably
based on a modified version of dmu_prealloc(), but is usable as-is.

A new module option zfs_fallocate_reserve_percent is used to control
the reserve margin for any single fallocate call.  By default, this
is 110% of the requested preallocation size, so an additional 10% of
available space is reserved for overhead to allow the application a
good chance of finishing the write when the fallocate() succeeds.
If the heuristics of this basic fallocate implementation are not
desirable, the old non-functional behavior of returning EOPNOTSUPP
for calls can be restored by setting zfs_fallocate_reserve_percent=0.

The parameter of zfs_statvfs() is changed to take an inode instead
of a dentry, since no dentry is available in zfs_fallocate_common().

A few tests from @behlendorf cover basic fallocate functionality.

Reviewed-by: Richard Laager <rlaager@wiktel.com>
Reviewed-by: Arshad Hussain <arshad.super@gmail.com>
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Co-authored-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Issue #326
Closes #10408
2020-06-18 11:22:11 -07:00
..
Makefile.am Refactor zfs_context.h to build on FreeBSD 2019-12-04 13:12:57 -08:00
policy.h Add zfs_file_* interface, remove vnodes 2019-11-21 09:32:57 -08:00
sha2.h Move sha2.h to platform code 2019-10-31 15:45:58 -07:00
trace_acl.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_arc.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_common.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_dbgmsg.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
trace_dbuf.h Factor out some dbuf subroutines and add state change tracing 2020-02-18 11:21:37 -08:00
trace_dmu.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_dnode.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_multilist.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_rrwlock.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_txg.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_vdev.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zfs.h Enable use of DTRACE_PROBE* macros in "spl" module 2019-11-01 13:13:43 -07:00
trace_zil.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zio.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
trace_zrlock.h OpenZFS restructuring - move linux tracing code to platform directories 2019-09-11 14:25:53 -07:00
zfs_context_os.h Refactor zfs_context.h to build on FreeBSD 2019-12-04 13:12:57 -08:00
zfs_ctldir.h OpenZFS restructuring - move platform specific headers 2019-09-05 09:34:54 -07:00
zfs_dir.h Eliminate Linux specific inode usage from common code 2019-12-11 11:53:57 -08:00
zfs_vfsops.h linux: add basic fallocate(mode=0/2) compatibility 2020-06-18 11:22:11 -07:00
zfs_vnops.h Remove zfs_getattr and convoff dead code 2020-02-24 15:38:22 -08:00
zfs_znode_impl.h Eliminate Linux specific inode usage from common code 2019-12-11 11:53:57 -08:00
zpl.h Linux 5.6 compat: timestamp_truncate() 2020-02-07 11:04:32 -08:00