The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/include/sys/sa.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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 https://opensource.org/licenses/CDDL-1.0.
   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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
   23  */
   24 
   25 #ifndef _SYS_SA_H
   26 #define _SYS_SA_H
   27 
   28 #include <sys/dmu.h>
   29 
   30 /*
   31  * Currently available byteswap functions.
   32  * If it all possible new attributes should used
   33  * one of the already defined byteswap functions.
   34  * If a new byteswap function is added then the
   35  * ZPL/Pool version will need to be bumped.
   36  */
   37 
   38 typedef enum sa_bswap_type {
   39         SA_UINT64_ARRAY,
   40         SA_UINT32_ARRAY,
   41         SA_UINT16_ARRAY,
   42         SA_UINT8_ARRAY,
   43         SA_ACL,
   44 } sa_bswap_type_t;
   45 
   46 typedef uint16_t        sa_attr_type_t;
   47 
   48 /*
   49  * Attribute to register support for.
   50  */
   51 typedef struct sa_attr_reg {
   52         const char              *sa_name;       /* attribute name */
   53         uint16_t                sa_length;
   54         sa_bswap_type_t         sa_byteswap;    /* bswap function enum */
   55         sa_attr_type_t          sa_attr; /* filled in during registration */
   56 } sa_attr_reg_t;
   57 
   58 
   59 typedef void (sa_data_locator_t)(void **, uint32_t *, uint32_t,
   60     boolean_t, void *userptr);
   61 
   62 /*
   63  * array of attributes to store.
   64  *
   65  * This array should be treated as opaque/private data.
   66  * The SA_BULK_ADD_ATTR() macro should be used for manipulating
   67  * the array.
   68  *
   69  * When sa_replace_all_by_template() is used the attributes
   70  * will be stored in the order defined in the array, except that
   71  * the attributes may be split between the bonus and the spill buffer
   72  *
   73  */
   74 typedef struct sa_bulk_attr {
   75         void                    *sa_data;
   76         sa_data_locator_t       *sa_data_func;
   77         uint16_t                sa_length;
   78         sa_attr_type_t          sa_attr;
   79         /* the following are private to the sa framework */
   80         void                    *sa_addr;
   81         uint16_t                sa_buftype;
   82         uint16_t                sa_size;
   83 } sa_bulk_attr_t;
   84 
   85 /*
   86  * The on-disk format of sa_hdr_phys_t limits SA lengths to 16-bit values.
   87  */
   88 #define SA_ATTR_MAX_LEN UINT16_MAX
   89 
   90 /*
   91  * special macro for adding entries for bulk attr support
   92  * bulk - sa_bulk_attr_t
   93  * count - integer that will be incremented during each add
   94  * attr - attribute to manipulate
   95  * func - function for accessing data.
   96  * data - pointer to data.
   97  * len - length of data
   98  */
   99 
  100 #define SA_ADD_BULK_ATTR(b, idx, attr, func, data, len) \
  101 { \
  102         ASSERT3U(len, <=, SA_ATTR_MAX_LEN); \
  103         b[idx].sa_attr = attr;\
  104         b[idx].sa_data_func = func; \
  105         b[idx].sa_data = data; \
  106         b[idx++].sa_length = len; \
  107 }
  108 
  109 typedef struct sa_os sa_os_t;
  110 
  111 typedef enum sa_handle_type {
  112         SA_HDL_SHARED,
  113         SA_HDL_PRIVATE
  114 } sa_handle_type_t;
  115 
  116 struct sa_handle;
  117 typedef void *sa_lookup_tab_t;
  118 typedef struct sa_handle sa_handle_t;
  119 
  120 typedef void (sa_update_cb_t)(sa_handle_t *, dmu_tx_t *tx);
  121 
  122 int sa_handle_get(objset_t *, uint64_t, void *userp,
  123     sa_handle_type_t, sa_handle_t **);
  124 int sa_handle_get_from_db(objset_t *, dmu_buf_t *, void *userp,
  125     sa_handle_type_t, sa_handle_t **);
  126 void sa_handle_destroy(sa_handle_t *);
  127 int sa_buf_hold(objset_t *, uint64_t, const void *, dmu_buf_t **);
  128 void sa_buf_rele(dmu_buf_t *, const void *);
  129 int sa_lookup(sa_handle_t *, sa_attr_type_t, void *buf, uint32_t buflen);
  130 int sa_update(sa_handle_t *, sa_attr_type_t, void *buf,
  131     uint32_t buflen, dmu_tx_t *);
  132 int sa_remove(sa_handle_t *, sa_attr_type_t, dmu_tx_t *);
  133 int sa_bulk_lookup(sa_handle_t *, sa_bulk_attr_t *, int count);
  134 int sa_bulk_lookup_locked(sa_handle_t *, sa_bulk_attr_t *, int count);
  135 int sa_bulk_update(sa_handle_t *, sa_bulk_attr_t *, int count, dmu_tx_t *);
  136 int sa_size(sa_handle_t *, sa_attr_type_t, int *);
  137 void sa_object_info(sa_handle_t *, dmu_object_info_t *);
  138 void sa_object_size(sa_handle_t *, uint32_t *, u_longlong_t *);
  139 void *sa_get_userdata(sa_handle_t *);
  140 void sa_set_userp(sa_handle_t *, void *);
  141 dmu_buf_t *sa_get_db(sa_handle_t *);
  142 uint64_t sa_handle_object(sa_handle_t *);
  143 boolean_t sa_attr_would_spill(sa_handle_t *, sa_attr_type_t, int size);
  144 void sa_spill_rele(sa_handle_t *);
  145 void sa_register_update_callback(objset_t *, sa_update_cb_t *);
  146 int sa_setup(objset_t *, uint64_t, const sa_attr_reg_t *, int,
  147     sa_attr_type_t **);
  148 void sa_tear_down(objset_t *);
  149 int sa_replace_all_by_template(sa_handle_t *, sa_bulk_attr_t *,
  150     int, dmu_tx_t *);
  151 int sa_replace_all_by_template_locked(sa_handle_t *, sa_bulk_attr_t *,
  152     int, dmu_tx_t *);
  153 boolean_t sa_enabled(objset_t *);
  154 void sa_cache_init(void);
  155 void sa_cache_fini(void);
  156 int sa_set_sa_object(objset_t *, uint64_t);
  157 int sa_hdrsize(void *);
  158 void sa_handle_lock(sa_handle_t *);
  159 void sa_handle_unlock(sa_handle_t *);
  160 
  161 #ifdef _KERNEL
  162 int sa_lookup_uio(sa_handle_t *, sa_attr_type_t, zfs_uio_t *);
  163 int sa_add_projid(sa_handle_t *, dmu_tx_t *, uint64_t);
  164 #endif
  165 
  166 #ifdef  __cplusplus
  167 extern "C" {
  168 #endif
  169 
  170 
  171 #ifdef  __cplusplus
  172 }
  173 #endif
  174 
  175 #endif  /* _SYS_SA_H */

Cache object: 42bcb21401cdaa2e0e3e2780ae1f7a1d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.