aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys
diff options
context:
space:
mode:
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/trace_acl.h6
-rw-r--r--include/sys/zfs_rlock.h34
-rw-r--r--include/sys/zfs_znode.h5
3 files changed, 35 insertions, 10 deletions
diff --git a/include/sys/trace_acl.h b/include/sys/trace_acl.h
index 87ffecb4e..230894229 100644
--- a/include/sys/trace_acl.h
+++ b/include/sys/trace_acl.h
@@ -63,7 +63,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__field(uint32_t, z_sync_cnt)
__field(mode_t, z_mode)
__field(boolean_t, z_is_sa)
- __field(boolean_t, z_is_zvol)
__field(boolean_t, z_is_mapped)
__field(boolean_t, z_is_ctldir)
__field(boolean_t, z_is_stale)
@@ -101,7 +100,6 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__entry->z_sync_cnt = zn->z_sync_cnt;
__entry->z_mode = zn->z_mode;
__entry->z_is_sa = zn->z_is_sa;
- __entry->z_is_zvol = zn->z_is_zvol;
__entry->z_is_mapped = zn->z_is_mapped;
__entry->z_is_ctldir = zn->z_is_ctldir;
__entry->z_is_stale = zn->z_is_stale;
@@ -125,7 +123,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
"zn_prefetch %u moved %u blksz %u seq %u "
"mapcnt %llu gen %llu size %llu "
"links %llu pflags %llu uid %llu gid %llu "
- "sync_cnt %u mode 0x%x is_sa %d is_zvol %d "
+ "sync_cnt %u mode 0x%x is_sa %d "
"is_mapped %d is_ctldir %d is_stale %d inode { "
"ino %lu nlink %u version %llu size %lli blkbits %u "
"bytes %u mode 0x%x generation %x } } ace { type %u "
@@ -136,7 +134,7 @@ DECLARE_EVENT_CLASS(zfs_ace_class,
__entry->z_size,
__entry->z_links, __entry->z_pflags, __entry->z_uid,
__entry->z_gid, __entry->z_sync_cnt, __entry->z_mode,
- __entry->z_is_sa, __entry->z_is_zvol, __entry->z_is_mapped,
+ __entry->z_is_sa, __entry->z_is_mapped,
__entry->z_is_ctldir, __entry->z_is_stale, __entry->i_ino,
__entry->i_nlink, __entry->i_version, __entry->i_size,
__entry->i_blkbits, __entry->i_bytes, __entry->i_mode,
diff --git a/include/sys/zfs_rlock.h b/include/sys/zfs_rlock.h
index ea5e40369..5322f3bc7 100644
--- a/include/sys/zfs_rlock.h
+++ b/include/sys/zfs_rlock.h
@@ -32,7 +32,9 @@ extern "C" {
#ifdef _KERNEL
-#include <sys/zfs_znode.h>
+#include <sys/list.h>
+#include <sys/avl.h>
+#include <sys/condvar.h>
typedef enum {
RL_READER,
@@ -40,8 +42,16 @@ typedef enum {
RL_APPEND
} rl_type_t;
+typedef struct zfs_rlock {
+ kmutex_t zr_mutex; /* protects changes to zr_avl */
+ avl_tree_t zr_avl; /* avl tree of range locks */
+ uint64_t *zr_size; /* points to znode->z_size */
+ uint_t *zr_blksz; /* points to znode->z_blksz */
+ uint64_t *zr_max_blksz; /* points to zsb->z_max_blksz */
+} zfs_rlock_t;
+
typedef struct rl {
- znode_t *r_zp; /* znode this lock applies to */
+ zfs_rlock_t *r_zrl;
avl_node_t r_node; /* avl node link */
uint64_t r_off; /* file range offset */
uint64_t r_len; /* file range length */
@@ -61,7 +71,8 @@ typedef struct rl {
* is converted to RL_WRITER that specified to lock from the start of the
* end of file. Returns the range lock structure.
*/
-rl_t *zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len, rl_type_t type);
+rl_t *zfs_range_lock(zfs_rlock_t *zrl, uint64_t off, uint64_t len,
+ rl_type_t type);
/* Unlock range and destroy range lock structure. */
void zfs_range_unlock(rl_t *rl);
@@ -78,6 +89,23 @@ void zfs_range_reduce(rl_t *rl, uint64_t off, uint64_t len);
*/
int zfs_range_compare(const void *arg1, const void *arg2);
+static inline void
+zfs_rlock_init(zfs_rlock_t *zrl)
+{
+ mutex_init(&zrl->zr_mutex, NULL, MUTEX_DEFAULT, NULL);
+ avl_create(&zrl->zr_avl, zfs_range_compare,
+ sizeof (rl_t), offsetof(rl_t, r_node));
+ zrl->zr_size = NULL;
+ zrl->zr_blksz = NULL;
+ zrl->zr_max_blksz = NULL;
+}
+
+static inline void
+zfs_rlock_destroy(zfs_rlock_t *zrl)
+{
+ avl_destroy(&zrl->zr_avl);
+ mutex_destroy(&zrl->zr_mutex);
+}
#endif /* _KERNEL */
#ifdef __cplusplus
diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
index 65fa10399..30a6ec9f8 100644
--- a/include/sys/zfs_znode.h
+++ b/include/sys/zfs_znode.h
@@ -37,6 +37,7 @@
#include <sys/rrwlock.h>
#include <sys/zfs_sa.h>
#include <sys/zfs_stat.h>
+#include <sys/zfs_rlock.h>
#endif
#include <sys/zfs_acl.h>
#include <sys/zil.h>
@@ -187,8 +188,7 @@ typedef struct znode {
krwlock_t z_parent_lock; /* parent lock for directories */
krwlock_t z_name_lock; /* "master" lock for dirent locks */
zfs_dirlock_t *z_dirlocks; /* directory entry lock list */
- kmutex_t z_range_lock; /* protects changes to z_range_avl */
- avl_tree_t z_range_avl; /* avl tree of file range locks */
+ zfs_rlock_t z_range_lock; /* file range lock */
uint8_t z_unlinked; /* file has been unlinked */
uint8_t z_atime_dirty; /* atime needs to be synced */
uint8_t z_zn_prefetch; /* Prefetch znodes? */
@@ -212,7 +212,6 @@ typedef struct znode {
list_node_t z_link_node; /* all znodes in fs link */
sa_handle_t *z_sa_hdl; /* handle to sa data */
boolean_t z_is_sa; /* are we native sa? */
- boolean_t z_is_zvol; /* are we used by the zvol */
boolean_t z_is_mapped; /* are we mmap'ed */
boolean_t z_is_ctldir; /* are we .zfs entry */
boolean_t z_is_stale; /* are we stale due to rollback? */