Move platform specific parts of zfs_znode.h to platform code

Some of the znode fields are different and functions
consuming an inode don't exist on FreeBSD.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9536
This commit is contained in:
Matthew Macy
2019-11-06 10:54:25 -08:00
committed by Brian Behlendorf
parent 1c47c2c42c
commit 27ece2ee4d
5 changed files with 194 additions and 139 deletions
+15
View File
@@ -38,6 +38,20 @@
* rangelock_reduce(lr, off, len); // optional
* rangelock_exit(lr);
*
* Range locking rules
* --------------------
* 1. When truncating a file (zfs_create, zfs_setattr, zfs_space) the whole
* file range needs to be locked as RL_WRITER. Only then can the pages be
* freed etc and zp_size reset. zp_size must be set within range lock.
* 2. For writes and punching holes (zfs_write & zfs_space) just the range
* being written or freed needs to be locked as RL_WRITER.
* Multiple writes at the end of the file must coordinate zp_size updates
* to ensure data isn't lost. A compare and swap loop is currently used
* to ensure the file size is at least the offset last written.
* 3. For reads (zfs_read, zfs_get_data & zfs_putapage) just the range being
* read needs to be locked as RL_READER. A check against zp_size can then
* be made for reading beyond end of file.
*
* AVL tree
* --------
* An AVL tree is used to maintain the state of the existing ranges
@@ -99,6 +113,7 @@
#include <sys/zfs_context.h>
#include <sys/zfs_rlock.h>
/*
* AVL comparison function used to order range locks
* Locks are ordered on the start offset of the range.