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/os/freebsd/zfs/sys/zfs_vfsops_os.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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   23  * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
   24  * All rights reserved.
   25  */
   26 
   27 #ifndef _SYS_FS_ZFS_VFSOPS_H
   28 #define _SYS_FS_ZFS_VFSOPS_H
   29 
   30 #if __FreeBSD_version >= 1300125
   31 #define TEARDOWN_RMS
   32 #endif
   33 
   34 #if __FreeBSD_version >= 1300109
   35 #define TEARDOWN_INACTIVE_RMS
   36 #endif
   37 
   38 #include <sys/dataset_kstats.h>
   39 #include <sys/list.h>
   40 #include <sys/vfs.h>
   41 #include <sys/zil.h>
   42 #include <sys/sa.h>
   43 #include <sys/rrwlock.h>
   44 #ifdef TEARDOWN_INACTIVE_RMS
   45 #include <sys/rmlock.h>
   46 #endif
   47 #include <sys/zfs_ioctl.h>
   48 
   49 #ifdef  __cplusplus
   50 extern "C" {
   51 #endif
   52 
   53 #ifdef TEARDOWN_RMS
   54 typedef struct rmslock zfs_teardown_lock_t;
   55 #else
   56 #define zfs_teardown_lock_t             rrmlock_t
   57 #endif
   58 
   59 #ifdef TEARDOWN_INACTIVE_RMS
   60 typedef struct rmslock zfs_teardown_inactive_lock_t;
   61 #else
   62 #define zfs_teardown_inactive_lock_t krwlock_t
   63 #endif
   64 
   65 typedef struct zfsvfs zfsvfs_t;
   66 struct znode;
   67 
   68 struct zfsvfs {
   69         vfs_t           *z_vfs;         /* generic fs struct */
   70         zfsvfs_t        *z_parent;      /* parent fs */
   71         objset_t        *z_os;          /* objset reference */
   72         uint64_t        z_flags;        /* super_block flags */
   73         uint64_t        z_root;         /* id of root znode */
   74         uint64_t        z_unlinkedobj;  /* id of unlinked zapobj */
   75         uint64_t        z_max_blksz;    /* maximum block size for files */
   76         uint64_t        z_fuid_obj;     /* fuid table object number */
   77         uint64_t        z_fuid_size;    /* fuid table size */
   78         avl_tree_t      z_fuid_idx;     /* fuid tree keyed by index */
   79         avl_tree_t      z_fuid_domain;  /* fuid tree keyed by domain */
   80         krwlock_t       z_fuid_lock;    /* fuid lock */
   81         boolean_t       z_fuid_loaded;  /* fuid tables are loaded */
   82         boolean_t       z_fuid_dirty;   /* need to sync fuid table ? */
   83         struct zfs_fuid_info    *z_fuid_replay; /* fuid info for replay */
   84         zilog_t         *z_log;         /* intent log pointer */
   85         uint_t          z_acl_type;     /* type of acl usable on this fs */
   86         uint_t          z_acl_mode;     /* acl chmod/mode behavior */
   87         uint_t          z_acl_inherit;  /* acl inheritance behavior */
   88         zfs_case_t      z_case;         /* case-sense */
   89         boolean_t       z_utf8;         /* utf8-only */
   90         int             z_norm;         /* normalization flags */
   91         boolean_t       z_atime;        /* enable atimes mount option */
   92         boolean_t       z_unmounted;    /* unmounted */
   93         zfs_teardown_lock_t z_teardown_lock;
   94         zfs_teardown_inactive_lock_t z_teardown_inactive_lock;
   95         list_t          z_all_znodes;   /* all vnodes in the fs */
   96         uint64_t        z_nr_znodes;    /* number of znodes in the fs */
   97         kmutex_t        z_znodes_lock;  /* lock for z_all_znodes */
   98         struct zfsctl_root      *z_ctldir;      /* .zfs directory pointer */
   99         boolean_t       z_show_ctldir;  /* expose .zfs in the root dir */
  100         boolean_t       z_issnap;       /* true if this is a snapshot */
  101         boolean_t       z_use_fuids;    /* version allows fuids */
  102         boolean_t       z_replay;       /* set during ZIL replay */
  103         boolean_t       z_use_sa;       /* version allow system attributes */
  104         boolean_t       z_xattr_sa;     /* allow xattrs to be stores as SA */
  105         boolean_t       z_use_namecache; /* make use of FreeBSD name cache */
  106         uint8_t         z_xattr;        /* xattr type in use */
  107         uint64_t        z_version;      /* ZPL version */
  108         uint64_t        z_shares_dir;   /* hidden shares dir */
  109         dataset_kstats_t        z_kstat;        /* fs kstats */
  110         kmutex_t        z_lock;
  111         uint64_t        z_userquota_obj;
  112         uint64_t        z_groupquota_obj;
  113         uint64_t        z_userobjquota_obj;
  114         uint64_t        z_groupobjquota_obj;
  115         uint64_t        z_projectquota_obj;
  116         uint64_t        z_projectobjquota_obj;
  117         uint64_t        z_replay_eof;   /* New end of file - replay only */
  118         sa_attr_type_t  *z_attr_table;  /* SA attr mapping->id */
  119 #define ZFS_OBJ_MTX_SZ  64
  120         kmutex_t        z_hold_mtx[ZFS_OBJ_MTX_SZ];     /* znode hold locks */
  121         struct task     z_unlinked_drain_task;
  122 };
  123 
  124 #ifdef TEARDOWN_RMS
  125 #define ZFS_TEARDOWN_INIT(zfsvfs)               \
  126         rms_init(&(zfsvfs)->z_teardown_lock, "zfs teardown")
  127 
  128 #define ZFS_TEARDOWN_DESTROY(zfsvfs)            \
  129         rms_destroy(&(zfsvfs)->z_teardown_lock)
  130 
  131 #define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag)    \
  132         rms_rlock(&(zfsvfs)->z_teardown_lock);
  133 
  134 #define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag)     \
  135         rms_runlock(&(zfsvfs)->z_teardown_lock)
  136 
  137 #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag)   \
  138         rms_wlock(&(zfsvfs)->z_teardown_lock)
  139 
  140 #define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs)         \
  141         rms_wunlock(&(zfsvfs)->z_teardown_lock)
  142 
  143 #define ZFS_TEARDOWN_EXIT(zfsvfs, tag)          \
  144         rms_unlock(&(zfsvfs)->z_teardown_lock)
  145 
  146 #define ZFS_TEARDOWN_READ_HELD(zfsvfs)          \
  147         rms_rowned(&(zfsvfs)->z_teardown_lock)
  148 
  149 #define ZFS_TEARDOWN_WRITE_HELD(zfsvfs)         \
  150         rms_wowned(&(zfsvfs)->z_teardown_lock)
  151 
  152 #define ZFS_TEARDOWN_HELD(zfsvfs)               \
  153         rms_owned_any(&(zfsvfs)->z_teardown_lock)
  154 #else
  155 #define ZFS_TEARDOWN_INIT(zfsvfs)               \
  156         rrm_init(&(zfsvfs)->z_teardown_lock, B_FALSE)
  157 
  158 #define ZFS_TEARDOWN_DESTROY(zfsvfs)            \
  159         rrm_destroy(&(zfsvfs)->z_teardown_lock)
  160 
  161 #define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag)    \
  162         rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag);
  163 
  164 #define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag)     \
  165         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  166 
  167 #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag)   \
  168         rrm_enter(&(zfsvfs)->z_teardown_lock, RW_WRITER, tag)
  169 
  170 #define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs)         \
  171         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  172 
  173 #define ZFS_TEARDOWN_EXIT(zfsvfs, tag)          \
  174         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  175 
  176 #define ZFS_TEARDOWN_READ_HELD(zfsvfs)          \
  177         RRM_READ_HELD(&(zfsvfs)->z_teardown_lock)
  178 
  179 #define ZFS_TEARDOWN_WRITE_HELD(zfsvfs)         \
  180         RRM_WRITE_HELD(&(zfsvfs)->z_teardown_lock)
  181 
  182 #define ZFS_TEARDOWN_HELD(zfsvfs)               \
  183         RRM_LOCK_HELD(&(zfsvfs)->z_teardown_lock)
  184 #endif
  185 
  186 #ifdef TEARDOWN_INACTIVE_RMS
  187 #define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs)              \
  188         rms_init(&(zfsvfs)->z_teardown_inactive_lock, "zfs teardown inactive")
  189 
  190 #define ZFS_TEARDOWN_INACTIVE_DESTROY(zfsvfs)           \
  191         rms_destroy(&(zfsvfs)->z_teardown_inactive_lock)
  192 
  193 #define ZFS_TEARDOWN_INACTIVE_TRY_ENTER_READ(zfsvfs)    \
  194         rms_try_rlock(&(zfsvfs)->z_teardown_inactive_lock)
  195 
  196 #define ZFS_TEARDOWN_INACTIVE_ENTER_READ(zfsvfs)        \
  197         rms_rlock(&(zfsvfs)->z_teardown_inactive_lock)
  198 
  199 #define ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs)         \
  200         rms_runlock(&(zfsvfs)->z_teardown_inactive_lock)
  201 
  202 #define ZFS_TEARDOWN_INACTIVE_ENTER_WRITE(zfsvfs)       \
  203         rms_wlock(&(zfsvfs)->z_teardown_inactive_lock)
  204 
  205 #define ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs)        \
  206         rms_wunlock(&(zfsvfs)->z_teardown_inactive_lock)
  207 
  208 #define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs)        \
  209         rms_wowned(&(zfsvfs)->z_teardown_inactive_lock)
  210 #else
  211 #define ZFS_TEARDOWN_INACTIVE_INIT(zfsvfs)              \
  212         rw_init(&(zfsvfs)->z_teardown_inactive_lock, NULL, RW_DEFAULT, NULL)
  213 
  214 #define ZFS_TEARDOWN_INACTIVE_DESTROY(zfsvfs)           \
  215         rw_destroy(&(zfsvfs)->z_teardown_inactive_lock)
  216 
  217 #define ZFS_TEARDOWN_INACTIVE_TRY_ENTER_READ(zfsvfs)    \
  218         rw_tryenter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER)
  219 
  220 #define ZFS_TEARDOWN_INACTIVE_ENTER_READ(zfsvfs)        \
  221         rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_READER)
  222 
  223 #define ZFS_TEARDOWN_INACTIVE_EXIT_READ(zfsvfs)         \
  224         rw_exit(&(zfsvfs)->z_teardown_inactive_lock)
  225 
  226 #define ZFS_TEARDOWN_INACTIVE_ENTER_WRITE(zfsvfs)       \
  227         rw_enter(&(zfsvfs)->z_teardown_inactive_lock, RW_WRITER)
  228 
  229 #define ZFS_TEARDOWN_INACTIVE_EXIT_WRITE(zfsvfs)        \
  230         rw_exit(&(zfsvfs)->z_teardown_inactive_lock)
  231 
  232 #define ZFS_TEARDOWN_INACTIVE_WRITE_HELD(zfsvfs)        \
  233         RW_WRITE_HELD(&(zfsvfs)->z_teardown_inactive_lock)
  234 #endif
  235 
  236 #define ZSB_XATTR       0x0001          /* Enable user xattrs */
  237 /*
  238  * Normal filesystems (those not under .zfs/snapshot) have a total
  239  * file ID size limited to 12 bytes (including the length field) due to
  240  * NFSv2 protocol's limitation of 32 bytes for a filehandle.  For historical
  241  * reasons, this same limit is being imposed by the Solaris NFSv3 implementation
  242  * (although the NFSv3 protocol actually permits a maximum of 64 bytes).  It
  243  * is not possible to expand beyond 12 bytes without abandoning support
  244  * of NFSv2.
  245  *
  246  * For normal filesystems, we partition up the available space as follows:
  247  *      2 bytes         fid length (required)
  248  *      6 bytes         object number (48 bits)
  249  *      4 bytes         generation number (32 bits)
  250  *
  251  * We reserve only 48 bits for the object number, as this is the limit
  252  * currently defined and imposed by the DMU.
  253  */
  254 typedef struct zfid_short {
  255         uint16_t        zf_len;
  256         uint8_t         zf_object[6];           /* obj[i] = obj >> (8 * i) */
  257         uint8_t         zf_gen[4];              /* gen[i] = gen >> (8 * i) */
  258 } zfid_short_t;
  259 
  260 /*
  261  * Filesystems under .zfs/snapshot have a total file ID size of 22[*] bytes
  262  * (including the length field).  This makes files under .zfs/snapshot
  263  * accessible by NFSv3 and NFSv4, but not NFSv2.
  264  *
  265  * For files under .zfs/snapshot, we partition up the available space
  266  * as follows:
  267  *      2 bytes         fid length (required)
  268  *      6 bytes         object number (48 bits)
  269  *      4 bytes         generation number (32 bits)
  270  *      6 bytes         objset id (48 bits)
  271  *      4 bytes[**]     currently just zero (32 bits)
  272  *
  273  * We reserve only 48 bits for the object number and objset id, as these are
  274  * the limits currently defined and imposed by the DMU.
  275  *
  276  * [*] 20 bytes on FreeBSD to fit into the size of struct fid.
  277  * [**] 2 bytes on FreeBSD for the above reason.
  278  */
  279 typedef struct zfid_long {
  280         zfid_short_t    z_fid;
  281         uint8_t         zf_setid[6];            /* obj[i] = obj >> (8 * i) */
  282         uint8_t         zf_setgen[2];           /* gen[i] = gen >> (8 * i) */
  283 } zfid_long_t;
  284 
  285 #define SHORT_FID_LEN   (sizeof (zfid_short_t) - sizeof (uint16_t))
  286 #define LONG_FID_LEN    (sizeof (zfid_long_t) - sizeof (uint16_t))
  287 
  288 extern uint_t zfs_fsyncer_key;
  289 extern int zfs_super_owner;
  290 
  291 extern void zfs_init(void);
  292 extern void zfs_fini(void);
  293 
  294 extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
  295 extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
  296 extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
  297 extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers);
  298 extern int zfsvfs_create(const char *name, boolean_t readonly, zfsvfs_t **zfvp);
  299 extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os);
  300 extern void zfsvfs_free(zfsvfs_t *zfsvfs);
  301 extern int zfs_check_global_label(const char *dsname, const char *hexsl);
  302 extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
  303 extern int zfs_get_temporary_prop(struct dsl_dataset *ds, zfs_prop_t zfs_prop,
  304     uint64_t *val, char *setpoint);
  305 extern int zfs_busy(void);
  306 
  307 #ifdef  __cplusplus
  308 }
  309 #endif
  310 
  311 #endif  /* _SYS_FS_ZFS_VFSOPS_H */

Cache object: 3a8a5860160cde0cd44e95c5a4576d8e


[ 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.