Update core ZFS code from build 121 to build 141.
[zfs.git] / module / zfs / include / sys / zfs_sa.h
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _SYS_ZFS_SA_H
27 #define _SYS_ZFS_SA_H
28
29 #ifdef _KERNEL
30 #include <sys/types32.h>
31 #include <sys/list.h>
32 #include <sys/dmu.h>
33 #include <sys/zfs_acl.h>
34 #include <sys/zfs_znode.h>
35 #include <sys/sa.h>
36 #include <sys/zil.h>
37
38
39 #endif
40
41 #ifdef  __cplusplus
42 extern "C" {
43 #endif
44
45 /*
46  * This is the list of known attributes
47  * to the ZPL.  The values of the actual
48  * attributes are not defined by the order
49  * the enums.  It is controlled by the attribute
50  * registration mechanism.  Two different file system
51  * could have different numeric values for the same
52  * attributes.  this list is only used for dereferencing
53  * into the table that will hold the actual numeric value.
54  */
55 typedef enum zpl_attr {
56         ZPL_ATIME,
57         ZPL_MTIME,
58         ZPL_CTIME,
59         ZPL_CRTIME,
60         ZPL_GEN,
61         ZPL_MODE,
62         ZPL_SIZE,
63         ZPL_PARENT,
64         ZPL_LINKS,
65         ZPL_XATTR,
66         ZPL_RDEV,
67         ZPL_FLAGS,
68         ZPL_UID,
69         ZPL_GID,
70         ZPL_PAD,
71         ZPL_ZNODE_ACL,
72         ZPL_DACL_COUNT,
73         ZPL_SYMLINK,
74         ZPL_SCANSTAMP,
75         ZPL_DACL_ACES,
76         ZPL_END
77 } zpl_attr_t;
78
79 #define ZFS_OLD_ZNODE_PHYS_SIZE 0x108
80 #define ZFS_SA_BASE_ATTR_SIZE   (ZFS_OLD_ZNODE_PHYS_SIZE - \
81     sizeof (zfs_acl_phys_t))
82
83 #define SA_MODE_OFFSET          0
84 #define SA_SIZE_OFFSET          8
85 #define SA_GEN_OFFSET           16
86 #define SA_UID_OFFSET           24
87 #define SA_GID_OFFSET           32
88 #define SA_PARENT_OFFSET        40
89
90 extern sa_attr_reg_t zfs_attr_table[ZPL_END + 1];
91 extern sa_attr_reg_t zfs_legacy_attr_table[ZPL_END + 1];
92
93 /*
94  * This is a deprecated data structure that only exists for
95  * dealing with file systems create prior to ZPL version 5.
96  */
97 typedef struct znode_phys {
98         uint64_t zp_atime[2];           /*  0 - last file access time */
99         uint64_t zp_mtime[2];           /* 16 - last file modification time */
100         uint64_t zp_ctime[2];           /* 32 - last file change time */
101         uint64_t zp_crtime[2];          /* 48 - creation time */
102         uint64_t zp_gen;                /* 64 - generation (txg of creation) */
103         uint64_t zp_mode;               /* 72 - file mode bits */
104         uint64_t zp_size;               /* 80 - size of file */
105         uint64_t zp_parent;             /* 88 - directory parent (`..') */
106         uint64_t zp_links;              /* 96 - number of links to file */
107         uint64_t zp_xattr;              /* 104 - DMU object for xattrs */
108         uint64_t zp_rdev;               /* 112 - dev_t for VBLK & VCHR files */
109         uint64_t zp_flags;              /* 120 - persistent flags */
110         uint64_t zp_uid;                /* 128 - file owner */
111         uint64_t zp_gid;                /* 136 - owning group */
112         uint64_t zp_zap;                /* 144 - extra attributes */
113         uint64_t zp_pad[3];             /* 152 - future */
114         zfs_acl_phys_t zp_acl;          /* 176 - 263 ACL */
115         /*
116          * Data may pad out any remaining bytes in the znode buffer, eg:
117          *
118          * |<---------------------- dnode_phys (512) ------------------------>|
119          * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->|
120          *                      |<---- znode (264) ---->|<---- data (56) ---->|
121          *
122          * At present, we use this space for the following:
123          *  - symbolic links
124          *  - 32-byte anti-virus scanstamp (regular files only)
125          */
126 } znode_phys_t;
127
128 #ifdef _KERNEL
129 int zfs_sa_readlink(struct znode *, uio_t *);
130 void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *);
131 void zfs_sa_upgrade(struct sa_handle  *, dmu_tx_t *);
132 void zfs_sa_get_scanstamp(struct znode *, xvattr_t *);
133 void zfs_sa_set_scanstamp(struct znode *, xvattr_t *, dmu_tx_t *);
134 void zfs_sa_uprade_pre(struct sa_handle *, void *, dmu_tx_t *);
135 void zfs_sa_upgrade_post(struct sa_handle *, void *, dmu_tx_t *);
136 void zfs_sa_upgrade_txholds(dmu_tx_t *, struct znode *);
137 #endif
138
139 #ifdef  __cplusplus
140 }
141 #endif
142
143 #endif  /* _SYS_ZFS_SA_H */