Print this page
3742 zfs comments need cleaner, more consistent style
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>
Reviewed by:    George Wilson <george.wilson@delphix.com>
Reviewed by:    Eric Schrock <eric.schrock@delphix.com>


 133  * adding a completely new attribute is a very rare operation.
 134  */
 135 struct sa_os {
 136         kmutex_t        sa_lock;
 137         boolean_t       sa_need_attr_registration;
 138         boolean_t       sa_force_spill;
 139         uint64_t        sa_master_obj;
 140         uint64_t        sa_reg_attr_obj;
 141         uint64_t        sa_layout_attr_obj;
 142         int             sa_num_attrs;
 143         sa_attr_table_t *sa_attr_table;  /* private attr table */
 144         sa_update_cb_t  *sa_update_cb;
 145         avl_tree_t      sa_layout_num_tree;  /* keyed by layout number */
 146         avl_tree_t      sa_layout_hash_tree; /* keyed by layout hash value */
 147         int             sa_user_table_sz;
 148         sa_attr_type_t  *sa_user_table; /* user name->attr mapping table */
 149 };
 150 
 151 /*
 152  * header for all bonus and spill buffers.

 153  * The header has a fixed portion with a variable number
 154  * of "lengths" depending on the number of variable sized
 155  * attribues which are determined by the "layout number"
 156  */
 157 
 158 #define SA_MAGIC        0x2F505A  /* ZFS SA */
 159 typedef struct sa_hdr_phys {
 160         uint32_t sa_magic;
 161         uint16_t sa_layout_info;  /* Encoded with hdrsize and layout number */
 162         uint16_t sa_lengths[1]; /* optional sizes for variable length attrs */
 163         /* ... Data follows the lengths.  */
 164 } sa_hdr_phys_t;
 165 
 166 /*
 167  * sa_hdr_phys -> sa_layout_info
 168  *
 169  * 16      10       0
 170  * +--------+-------+
 171  * | hdrsz  |layout |
 172  * +--------+-------+
 173  *
 174  * Bits 0-10 are the layout number
 175  * Bits 11-16 are the size of the header.
 176  * The hdrsize is the number * 8
 177  *
 178  * For example.
 179  * hdrsz of 1 ==> 8 byte header
 180  *          2 ==> 16 byte header
 181  *
 182  */




 183 
 184 #define SA_HDR_LAYOUT_NUM(hdr) BF32_GET(hdr->sa_layout_info, 0, 10)
 185 #define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 6, 3, 0)
 186 #define SA_HDR_LAYOUT_INFO_ENCODE(x, num, size) \
 187 { \
 188         BF32_SET_SB(x, 10, 6, 3, 0, size); \
 189         BF32_SET(x, 0, 10, num); \
 190 }
 191 
 192 typedef enum sa_buf_type {
 193         SA_BONUS = 1,
 194         SA_SPILL = 2
 195 } sa_buf_type_t;
 196 
 197 typedef enum sa_data_op {
 198         SA_LOOKUP,
 199         SA_UPDATE,
 200         SA_ADD,
 201         SA_REPLACE,
 202         SA_REMOVE




 133  * adding a completely new attribute is a very rare operation.
 134  */
 135 struct sa_os {
 136         kmutex_t        sa_lock;
 137         boolean_t       sa_need_attr_registration;
 138         boolean_t       sa_force_spill;
 139         uint64_t        sa_master_obj;
 140         uint64_t        sa_reg_attr_obj;
 141         uint64_t        sa_layout_attr_obj;
 142         int             sa_num_attrs;
 143         sa_attr_table_t *sa_attr_table;  /* private attr table */
 144         sa_update_cb_t  *sa_update_cb;
 145         avl_tree_t      sa_layout_num_tree;  /* keyed by layout number */
 146         avl_tree_t      sa_layout_hash_tree; /* keyed by layout hash value */
 147         int             sa_user_table_sz;
 148         sa_attr_type_t  *sa_user_table; /* user name->attr mapping table */
 149 };
 150 
 151 /*
 152  * header for all bonus and spill buffers.
 153  *
 154  * The header has a fixed portion with a variable number
 155  * of "lengths" depending on the number of variable sized
 156  * attribues which are determined by the "layout number"
 157  */
 158 
 159 #define SA_MAGIC        0x2F505A  /* ZFS SA */
 160 typedef struct sa_hdr_phys {
 161         uint32_t sa_magic;
 162         /*
 163          * Encoded with hdrsize and layout number as follows:






 164          * 16      10       0
 165          * +--------+-------+
 166          * | hdrsz  |layout |
 167          * +--------+-------+
 168          *
 169          * Bits 0-10 are the layout number
 170          * Bits 11-16 are the size of the header.
 171          * The hdrsize is the number * 8
 172          *
 173          * For example.
 174          * hdrsz of 1 ==> 8 byte header
 175          *          2 ==> 16 byte header
 176          *
 177          */
 178         uint16_t sa_layout_info;
 179         uint16_t sa_lengths[1]; /* optional sizes for variable length attrs */
 180         /* ... Data follows the lengths.  */
 181 } sa_hdr_phys_t;
 182 
 183 #define SA_HDR_LAYOUT_NUM(hdr) BF32_GET(hdr->sa_layout_info, 0, 10)
 184 #define SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 6, 3, 0)
 185 #define SA_HDR_LAYOUT_INFO_ENCODE(x, num, size) \
 186 { \
 187         BF32_SET_SB(x, 10, 6, 3, 0, size); \
 188         BF32_SET(x, 0, 10, num); \
 189 }
 190 
 191 typedef enum sa_buf_type {
 192         SA_BONUS = 1,
 193         SA_SPILL = 2
 194 } sa_buf_type_t;
 195 
 196 typedef enum sa_data_op {
 197         SA_LOOKUP,
 198         SA_UPDATE,
 199         SA_ADD,
 200         SA_REPLACE,
 201         SA_REMOVE