config/dracut/90zfs: handle cases where hostid(1) returns all zeros
[zfs.git] / include / os / linux / zfs / sys / zfs_znode_impl.h
bloba886dd3bd36553bed786a33e178b43a68cebb8d2
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
27 #ifndef _SYS_ZFS_ZNODE_IMPL_H
28 #define _SYS_ZFS_ZNODE_IMPL_H
30 #ifndef _KERNEL
31 #error "no user serviceable parts within"
32 #endif
34 #include <sys/isa_defs.h>
35 #include <sys/types32.h>
36 #include <sys/list.h>
37 #include <sys/dmu.h>
38 #include <sys/sa.h>
39 #include <sys/zfs_vfsops.h>
40 #include <sys/rrwlock.h>
41 #include <sys/zfs_sa.h>
42 #include <sys/zfs_stat.h>
43 #include <sys/zfs_rlock.h>
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 #define ZNODE_OS_FIELDS \
51 struct inode z_inode;
55 * Convert between znode pointers and inode pointers
57 #define ZTOI(znode) (&((znode)->z_inode))
58 #define ITOZ(inode) (container_of((inode), znode_t, z_inode))
59 #define ZTOZSB(znode) ((zfsvfs_t *)(ZTOI(znode)->i_sb->s_fs_info))
60 #define ITOZSB(inode) ((zfsvfs_t *)((inode)->i_sb->s_fs_info))
62 #define ZTOTYPE(zp) (ZTOI(zp)->i_mode)
63 #define ZTOGID(zp) (ZTOI(zp)->i_gid)
64 #define ZTOUID(zp) (ZTOI(zp)->i_uid)
65 #define ZTONLNK(zp) (ZTOI(zp)->i_nlink)
67 #define Z_ISBLK(type) S_ISBLK(type)
68 #define Z_ISCHR(type) S_ISCHR(type)
69 #define Z_ISLNK(type) S_ISLNK(type)
70 #define Z_ISDEV(type) (S_ISCHR(type) || S_ISBLK(type) || S_ISFIFO(type))
71 #define Z_ISDIR(type) S_ISDIR(type)
73 #define zn_has_cached_data(zp) ((zp)->z_is_mapped)
74 #define zn_rlimit_fsize(zp, uio, td) (0)
76 #define zhold(zp) igrab(ZTOI((zp)))
77 #define zrele(zp) iput(ZTOI((zp)))
79 /* Called on entry to each ZFS inode and vfs operation. */
80 #define ZFS_ENTER_ERROR(zfsvfs, error) \
81 do { \
82 rrm_enter_read(&(zfsvfs)->z_teardown_lock, FTAG); \
83 if ((zfsvfs)->z_unmounted) { \
84 ZFS_EXIT(zfsvfs); \
85 return (error); \
86 } \
87 } while (0)
88 #define ZFS_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, EIO)
89 #define ZPL_ENTER(zfsvfs) ZFS_ENTER_ERROR(zfsvfs, -EIO)
91 /* Must be called before exiting the operation. */
92 #define ZFS_EXIT(zfsvfs) \
93 do { \
94 zfs_exit_fs(zfsvfs); \
95 rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG); \
96 } while (0)
98 #define ZPL_EXIT(zfsvfs) \
99 do { \
100 rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG); \
101 } while (0)
103 /* Verifies the znode is valid. */
104 #define ZFS_VERIFY_ZP_ERROR(zp, error) \
105 do { \
106 if ((zp)->z_sa_hdl == NULL) { \
107 ZFS_EXIT(ZTOZSB(zp)); \
108 return (error); \
110 } while (0)
111 #define ZFS_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, EIO)
112 #define ZPL_VERIFY_ZP(zp) ZFS_VERIFY_ZP_ERROR(zp, -EIO)
115 * Macros for dealing with dmu_buf_hold
117 #define ZFS_OBJ_MTX_SZ 64
118 #define ZFS_OBJ_MTX_MAX (1024 * 1024)
119 #define ZFS_OBJ_HASH(zfsvfs, obj) ((obj) & ((zfsvfs->z_hold_size) - 1))
121 extern unsigned int zfs_object_mutex_size;
124 * Encode ZFS stored time values from a struct timespec / struct timespec64.
126 #define ZFS_TIME_ENCODE(tp, stmp) \
127 do { \
128 (stmp)[0] = (uint64_t)(tp)->tv_sec; \
129 (stmp)[1] = (uint64_t)(tp)->tv_nsec; \
130 } while (0)
132 #if defined(HAVE_INODE_TIMESPEC64_TIMES)
134 * Decode ZFS stored time values to a struct timespec64
135 * 4.18 and newer kernels.
137 #define ZFS_TIME_DECODE(tp, stmp) \
138 do { \
139 (tp)->tv_sec = (time64_t)(stmp)[0]; \
140 (tp)->tv_nsec = (long)(stmp)[1]; \
141 } while (0)
142 #else
144 * Decode ZFS stored time values to a struct timespec
145 * 4.17 and older kernels.
147 #define ZFS_TIME_DECODE(tp, stmp) \
148 do { \
149 (tp)->tv_sec = (time_t)(stmp)[0]; \
150 (tp)->tv_nsec = (long)(stmp)[1]; \
151 } while (0)
152 #endif /* HAVE_INODE_TIMESPEC64_TIMES */
154 #define ZFS_ACCESSTIME_STAMP(zfsvfs, zp)
156 struct znode;
158 extern int zfs_sync(struct super_block *, int, cred_t *);
159 extern int zfs_inode_alloc(struct super_block *, struct inode **ip);
160 extern void zfs_inode_destroy(struct inode *);
161 extern void zfs_inode_update(struct znode *);
162 extern void zfs_mark_inode_dirty(struct inode *);
163 extern boolean_t zfs_relatime_need_update(const struct inode *);
165 #if defined(HAVE_UIO_RW)
166 extern caddr_t zfs_map_page(page_t *, enum seg_rw);
167 extern void zfs_unmap_page(page_t *, caddr_t);
168 #endif /* HAVE_UIO_RW */
170 extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE];
171 extern int zfsfstype;
173 #ifdef __cplusplus
175 #endif
177 #endif /* _SYS_ZFS_ZNODE_IMPL_H */