Home | History | Annotate | Line # | Download | only in fstat
      1 /*	$NetBSD: zfs_znode.h,v 1.1 2022/06/19 11:31:19 simonb Exp $	*/
      2 
      3 /*
      4  * XXX From: external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_znode.h
      5  *
      6  * Grotty hack to define a "simple" znode_t so we don't need to
      7  * try to include the real zfs_znode.h which isn't easily possible
      8  * from userland due to all sorts of kernel only defines and structs
      9  * being required.
     10  */
     11 
     12 /*
     13  * CDDL HEADER START
     14  *
     15  * The contents of this file are subject to the terms of the
     16  * Common Development and Distribution License (the "License").
     17  * You may not use this file except in compliance with the License.
     18  *
     19  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     20  * or http://www.opensolaris.org/os/licensing.
     21  * See the License for the specific language governing permissions
     22  * and limitations under the License.
     23  *
     24  * When distributing Covered Code, include this CDDL HEADER in each
     25  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     26  * If applicable, add the following below this CDDL HEADER, with the
     27  * fields enclosed by brackets "[]" replaced with your own identifying
     28  * information: Portions Copyright [yyyy] [name of copyright owner]
     29  *
     30  * CDDL HEADER END
     31  */
     32 /*
     33  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     34  * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
     35  * Copyright (c) 2014 Integros [integros.com]
     36  */
     37 
     38 
     39 #include <miscfs/genfs/genfs_node.h>
     40 
     41 #define	VTOZ(VP)	((znode_t *)(VP)->v_data)
     42 
     43 #define	ulong_t		unsigned long
     44 #define	uint_t		unsigned int
     45 #define	zfs_acl_t	void
     46 
     47 struct avl_node;
     48 typedef struct sa_handle sa_handle_t;
     49 typedef int boolean_t;
     50 
     51 typedef struct avl_tree {
     52 	struct avl_node	*avl_root;
     53 	int		(*avl_compar)(const void *, const void *);
     54 	size_t		avl_offset;
     55 	ulong_t		avl_numnodes;
     56 	size_t		avl_size;
     57 } avl_tree_t;
     58 
     59 typedef struct list_node {
     60 	struct list_node *list_next;
     61 	struct list_node *list_prev;
     62 } list_node_t;
     63 
     64 typedef struct znode {
     65 #ifdef __NetBSD__
     66 	struct genfs_node z_gnode;
     67 #endif
     68 	struct zfsvfs	*z_zfsvfs;
     69 	vnode_t		*z_vnode;
     70 	uint64_t	z_id;		/* object ID for this znode */
     71 #ifdef illumos
     72 	kmutex_t	z_lock;		/* znode modification lock */
     73 	krwlock_t	z_parent_lock;	/* parent lock for directories */
     74 	krwlock_t	z_name_lock;	/* "master" lock for dirent locks */
     75 	zfs_dirlock_t	*z_dirlocks;	/* directory entry lock list */
     76 #endif
     77 	kmutex_t	z_range_lock;	/* protects changes to z_range_avl */
     78 	avl_tree_t	z_range_avl;	/* avl tree of file range locks */
     79 	uint8_t		z_unlinked;	/* file has been unlinked */
     80 	uint8_t		z_atime_dirty;	/* atime needs to be synced */
     81 	uint8_t		z_zn_prefetch;	/* Prefetch znodes? */
     82 	uint8_t		z_moved;	/* Has this znode been moved? */
     83 	uint_t		z_blksz;	/* block size in bytes */
     84 	uint_t		z_seq;		/* modification sequence number */
     85 	uint64_t	z_mapcnt;	/* number of pages mapped to file */
     86 	uint64_t	z_gen;		/* generation (cached) */
     87 	uint64_t	z_size;		/* file size (cached) */
     88 	uint64_t	z_atime[2];	/* atime (cached) */
     89 	uint64_t	z_links;	/* file links (cached) */
     90 	uint64_t	z_pflags;	/* pflags (cached) */
     91 	uint64_t	z_uid;		/* uid fuid (cached) */
     92 	uint64_t	z_gid;		/* gid fuid (cached) */
     93 	mode_t		z_mode;		/* mode (cached) */
     94 	uint32_t	z_sync_cnt;	/* synchronous open count */
     95 	kmutex_t	z_acl_lock;	/* acl data lock */
     96 	zfs_acl_t	*z_acl_cached;	/* cached acl */
     97 	list_node_t	z_link_node;	/* all znodes in fs link */
     98 	sa_handle_t	*z_sa_hdl;	/* handle to sa data */
     99 	boolean_t	z_is_sa;	/* are we native sa? */
    100 #ifdef __NetBSD__
    101 	struct lockf	*z_lockf;	/* head of byte-level lock list */
    102 #endif
    103 } znode_t;
    104