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/linux/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) 2013, 2018 by Delphix. All rights reserved.
   24  */
   25 
   26 #ifndef _SYS_FS_ZFS_VFSOPS_H
   27 #define _SYS_FS_ZFS_VFSOPS_H
   28 
   29 #include <sys/dataset_kstats.h>
   30 #include <sys/isa_defs.h>
   31 #include <sys/types32.h>
   32 #include <sys/list.h>
   33 #include <sys/vfs.h>
   34 #include <sys/zil.h>
   35 #include <sys/sa.h>
   36 #include <sys/rrwlock.h>
   37 #include <sys/dsl_dataset.h>
   38 #include <sys/zfs_ioctl.h>
   39 #include <sys/objlist.h>
   40 
   41 #ifdef  __cplusplus
   42 extern "C" {
   43 #endif
   44 
   45 typedef struct zfsvfs zfsvfs_t;
   46 struct znode;
   47 
   48 /*
   49  * This structure emulates the vfs_t from other platforms.  It's purpose
   50  * is to facilitate the handling of mount options and minimize structural
   51  * differences between the platforms.
   52  */
   53 typedef struct vfs {
   54         struct zfsvfs   *vfs_data;
   55         char            *vfs_mntpoint;  /* Primary mount point */
   56         uint64_t        vfs_xattr;
   57         boolean_t       vfs_readonly;
   58         boolean_t       vfs_do_readonly;
   59         boolean_t       vfs_setuid;
   60         boolean_t       vfs_do_setuid;
   61         boolean_t       vfs_exec;
   62         boolean_t       vfs_do_exec;
   63         boolean_t       vfs_devices;
   64         boolean_t       vfs_do_devices;
   65         boolean_t       vfs_do_xattr;
   66         boolean_t       vfs_atime;
   67         boolean_t       vfs_do_atime;
   68         boolean_t       vfs_relatime;
   69         boolean_t       vfs_do_relatime;
   70         boolean_t       vfs_nbmand;
   71         boolean_t       vfs_do_nbmand;
   72 } vfs_t;
   73 
   74 typedef struct zfs_mnt {
   75         const char      *mnt_osname;    /* Objset name */
   76         char            *mnt_data;      /* Raw mount options */
   77 } zfs_mnt_t;
   78 
   79 struct zfsvfs {
   80         vfs_t           *z_vfs;         /* generic fs struct */
   81         struct super_block *z_sb;       /* generic super_block */
   82         struct zfsvfs   *z_parent;      /* parent fs */
   83         objset_t        *z_os;          /* objset reference */
   84         uint64_t        z_flags;        /* super_block flags */
   85         uint64_t        z_root;         /* id of root znode */
   86         uint64_t        z_unlinkedobj;  /* id of unlinked zapobj */
   87         uint64_t        z_max_blksz;    /* maximum block size for files */
   88         uint64_t        z_fuid_obj;     /* fuid table object number */
   89         uint64_t        z_fuid_size;    /* fuid table size */
   90         avl_tree_t      z_fuid_idx;     /* fuid tree keyed by index */
   91         avl_tree_t      z_fuid_domain;  /* fuid tree keyed by domain */
   92         krwlock_t       z_fuid_lock;    /* fuid lock */
   93         boolean_t       z_fuid_loaded;  /* fuid tables are loaded */
   94         boolean_t       z_fuid_dirty;   /* need to sync fuid table ? */
   95         struct zfs_fuid_info    *z_fuid_replay; /* fuid info for replay */
   96         zilog_t         *z_log;         /* intent log pointer */
   97         uint_t          z_acl_mode;     /* acl chmod/mode behavior */
   98         uint_t          z_acl_inherit;  /* acl inheritance behavior */
   99         uint_t          z_acl_type;     /* type of ACL usable on this FS */
  100         zfs_case_t      z_case;         /* case-sense */
  101         boolean_t       z_utf8;         /* utf8-only */
  102         int             z_norm;         /* normalization flags */
  103         boolean_t       z_relatime;     /* enable relatime mount option */
  104         boolean_t       z_unmounted;    /* unmounted */
  105         rrmlock_t       z_teardown_lock;
  106         krwlock_t       z_teardown_inactive_lock;
  107         list_t          z_all_znodes;   /* all znodes in the fs */
  108         uint64_t        z_nr_znodes;    /* number of znodes in the fs */
  109         unsigned long   z_rollback_time; /* last online rollback time */
  110         unsigned long   z_snap_defer_time; /* last snapshot unmount deferral */
  111         kmutex_t        z_znodes_lock;  /* lock for z_all_znodes */
  112         arc_prune_t     *z_arc_prune;   /* called by ARC to prune caches */
  113         struct inode    *z_ctldir;      /* .zfs directory inode */
  114         boolean_t       z_show_ctldir;  /* expose .zfs in the root dir */
  115         boolean_t       z_issnap;       /* true if this is a snapshot */
  116         boolean_t       z_use_fuids;    /* version allows fuids */
  117         boolean_t       z_replay;       /* set during ZIL replay */
  118         boolean_t       z_use_sa;       /* version allow system attributes */
  119         boolean_t       z_xattr_sa;     /* allow xattrs to be stores as SA */
  120         boolean_t       z_draining;     /* is true when drain is active */
  121         boolean_t       z_drain_cancel; /* signal the unlinked drain to stop */
  122         uint64_t        z_version;      /* ZPL version */
  123         uint64_t        z_shares_dir;   /* hidden shares dir */
  124         dataset_kstats_t        z_kstat;        /* fs kstats */
  125         kmutex_t        z_lock;
  126         uint64_t        z_userquota_obj;
  127         uint64_t        z_groupquota_obj;
  128         uint64_t        z_userobjquota_obj;
  129         uint64_t        z_groupobjquota_obj;
  130         uint64_t        z_projectquota_obj;
  131         uint64_t        z_projectobjquota_obj;
  132         uint64_t        z_replay_eof;   /* New end of file - replay only */
  133         sa_attr_type_t  *z_attr_table;  /* SA attr mapping->id */
  134         uint64_t        z_hold_size;    /* znode hold array size */
  135         avl_tree_t      *z_hold_trees;  /* znode hold trees */
  136         kmutex_t        *z_hold_locks;  /* znode hold locks */
  137         taskqid_t       z_drain_task;   /* task id for the unlink drain task */
  138 };
  139 
  140 #define ZFS_TEARDOWN_INIT(zfsvfs)               \
  141         rrm_init(&(zfsvfs)->z_teardown_lock, B_FALSE)
  142 
  143 #define ZFS_TEARDOWN_DESTROY(zfsvfs)            \
  144         rrm_destroy(&(zfsvfs)->z_teardown_lock)
  145 
  146 #define ZFS_TEARDOWN_ENTER_READ(zfsvfs, tag)    \
  147         rrm_enter_read(&(zfsvfs)->z_teardown_lock, tag);
  148 
  149 #define ZFS_TEARDOWN_EXIT_READ(zfsvfs, tag)     \
  150         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  151 
  152 #define ZFS_TEARDOWN_ENTER_WRITE(zfsvfs, tag)   \
  153         rrm_enter(&(zfsvfs)->z_teardown_lock, RW_WRITER, tag)
  154 
  155 #define ZFS_TEARDOWN_EXIT_WRITE(zfsvfs)         \
  156         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  157 
  158 #define ZFS_TEARDOWN_EXIT(zfsvfs, tag)          \
  159         rrm_exit(&(zfsvfs)->z_teardown_lock, tag)
  160 
  161 #define ZFS_TEARDOWN_READ_HELD(zfsvfs)          \
  162         RRM_READ_HELD(&(zfsvfs)->z_teardown_lock)
  163 
  164 #define ZFS_TEARDOWN_WRITE_HELD(zfsvfs)         \
  165         RRM_WRITE_HELD(&(zfsvfs)->z_teardown_lock)
  166 
  167 #define ZFS_TEARDOWN_HELD(zfsvfs)               \
  168         RRM_LOCK_HELD(&(zfsvfs)->z_teardown_lock)
  169 
  170 #define ZSB_XATTR       0x0001          /* Enable user xattrs */
  171 
  172 /*
  173  * Allow a maximum number of links.  While ZFS does not internally limit
  174  * this the inode->i_nlink member is defined as an unsigned int.  To be
  175  * safe we use 2^31-1 as the limit.
  176  */
  177 #define ZFS_LINK_MAX            ((1U << 31) - 1U)
  178 
  179 /*
  180  * Normal filesystems (those not under .zfs/snapshot) have a total
  181  * file ID size limited to 12 bytes (including the length field) due to
  182  * NFSv2 protocol's limitation of 32 bytes for a filehandle.  For historical
  183  * reasons, this same limit is being imposed by the Solaris NFSv3 implementation
  184  * (although the NFSv3 protocol actually permits a maximum of 64 bytes).  It
  185  * is not possible to expand beyond 12 bytes without abandoning support
  186  * of NFSv2.
  187  *
  188  * For normal filesystems, we partition up the available space as follows:
  189  *      2 bytes         fid length (required)
  190  *      6 bytes         object number (48 bits)
  191  *      4 bytes         generation number (32 bits)
  192  *
  193  * We reserve only 48 bits for the object number, as this is the limit
  194  * currently defined and imposed by the DMU.
  195  */
  196 typedef struct zfid_short {
  197         uint16_t        zf_len;
  198         uint8_t         zf_object[6];           /* obj[i] = obj >> (8 * i) */
  199         uint8_t         zf_gen[4];              /* gen[i] = gen >> (8 * i) */
  200 } zfid_short_t;
  201 
  202 /*
  203  * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes
  204  * (including the length field).  This makes files under .zfs/snapshot
  205  * accessible by NFSv3 and NFSv4, but not NFSv2.
  206  *
  207  * For files under .zfs/snapshot, we partition up the available space
  208  * as follows:
  209  *      2 bytes         fid length (required)
  210  *      6 bytes         object number (48 bits)
  211  *      4 bytes         generation number (32 bits)
  212  *      6 bytes         objset id (48 bits)
  213  *      4 bytes         currently just zero (32 bits)
  214  *
  215  * We reserve only 48 bits for the object number and objset id, as these are
  216  * the limits currently defined and imposed by the DMU.
  217  */
  218 typedef struct zfid_long {
  219         zfid_short_t    z_fid;
  220         uint8_t         zf_setid[6];            /* obj[i] = obj >> (8 * i) */
  221         uint8_t         zf_setgen[4];           /* gen[i] = gen >> (8 * i) */
  222 } zfid_long_t;
  223 
  224 #define SHORT_FID_LEN   (sizeof (zfid_short_t) - sizeof (uint16_t))
  225 #define LONG_FID_LEN    (sizeof (zfid_long_t) - sizeof (uint16_t))
  226 
  227 extern void zfs_init(void);
  228 extern void zfs_fini(void);
  229 
  230 extern int zfs_suspend_fs(zfsvfs_t *zfsvfs);
  231 extern int zfs_resume_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
  232 extern int zfs_end_fs(zfsvfs_t *zfsvfs, struct dsl_dataset *ds);
  233 extern void zfs_exit_fs(zfsvfs_t *zfsvfs);
  234 extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers);
  235 extern int zfsvfs_create(const char *name, boolean_t readony, zfsvfs_t **zfvp);
  236 extern int zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os);
  237 extern void zfsvfs_free(zfsvfs_t *zfsvfs);
  238 extern int zfs_check_global_label(const char *dsname, const char *hexsl);
  239 
  240 extern boolean_t zfs_is_readonly(zfsvfs_t *zfsvfs);
  241 extern int zfs_domount(struct super_block *sb, zfs_mnt_t *zm, int silent);
  242 extern void zfs_preumount(struct super_block *sb);
  243 extern int zfs_umount(struct super_block *sb);
  244 extern int zfs_remount(struct super_block *sb, int *flags, zfs_mnt_t *zm);
  245 extern int zfs_statvfs(struct inode *ip, struct kstatfs *statp);
  246 extern int zfs_vget(struct super_block *sb, struct inode **ipp, fid_t *fidp);
  247 extern int zfs_prune(struct super_block *sb, unsigned long nr_to_scan,
  248     int *objects);
  249 extern int zfs_get_temporary_prop(dsl_dataset_t *ds, zfs_prop_t zfs_prop,
  250     uint64_t *val, char *setpoint);
  251 
  252 #ifdef  __cplusplus
  253 }
  254 #endif
  255 
  256 #endif  /* _SYS_FS_ZFS_VFSOPS_H */

Cache object: d8a5a3672756b14e6c795f374618caa5


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