1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 53461Sahrens * Common Development and Distribution License (the "License"). 63461Sahrens * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 21789Sahrens /* 2212164SMark.Shellenbaum@Sun.COM * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23789Sahrens */ 24789Sahrens 25789Sahrens #ifndef _SYS_FS_ZFS_VFSOPS_H 26789Sahrens #define _SYS_FS_ZFS_VFSOPS_H 27789Sahrens 28789Sahrens #include <sys/isa_defs.h> 29789Sahrens #include <sys/types32.h> 30789Sahrens #include <sys/list.h> 31789Sahrens #include <sys/vfs.h> 32789Sahrens #include <sys/zil.h> 3311935SMark.Shellenbaum@Sun.COM #include <sys/sa.h> 345326Sek110237 #include <sys/rrwlock.h> 355498Stimh #include <sys/zfs_ioctl.h> 36789Sahrens 37789Sahrens #ifdef __cplusplus 38789Sahrens extern "C" { 39789Sahrens #endif 40789Sahrens 41789Sahrens typedef struct zfsvfs zfsvfs_t; 4211935SMark.Shellenbaum@Sun.COM struct znode; 43789Sahrens 44789Sahrens struct zfsvfs { 45789Sahrens vfs_t *z_vfs; /* generic fs struct */ 46789Sahrens zfsvfs_t *z_parent; /* parent fs */ 47789Sahrens objset_t *z_os; /* objset reference */ 48789Sahrens uint64_t z_root; /* id of root znode */ 493461Sahrens uint64_t z_unlinkedobj; /* id of unlinked zapobj */ 50789Sahrens uint64_t z_max_blksz; /* maximum block size for files */ 515331Samw uint64_t z_fuid_obj; /* fuid table object number */ 525824Smarks uint64_t z_fuid_size; /* fuid table size */ 535331Samw avl_tree_t z_fuid_idx; /* fuid tree keyed by index */ 545331Samw avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */ 555331Samw krwlock_t z_fuid_lock; /* fuid lock */ 565331Samw boolean_t z_fuid_loaded; /* fuid tables are loaded */ 579179SMark.Shellenbaum@Sun.COM boolean_t z_fuid_dirty; /* need to sync fuid table ? */ 585331Samw struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */ 59789Sahrens zilog_t *z_log; /* intent log pointer */ 60789Sahrens uint_t z_acl_inherit; /* acl inheritance behavior */ 615498Stimh zfs_case_t z_case; /* case-sense */ 625498Stimh boolean_t z_utf8; /* utf8-only */ 635331Samw int z_norm; /* normalization flags */ 64789Sahrens boolean_t z_atime; /* enable atimes mount option */ 654787Sahrens boolean_t z_unmounted; /* unmounted */ 665326Sek110237 rrwlock_t z_teardown_lock; 675326Sek110237 krwlock_t z_teardown_inactive_lock; 68789Sahrens list_t z_all_znodes; /* all vnodes in the fs */ 69789Sahrens kmutex_t z_znodes_lock; /* lock for z_all_znodes */ 70789Sahrens vnode_t *z_ctldir; /* .zfs directory pointer */ 71789Sahrens boolean_t z_show_ctldir; /* expose .zfs in the root dir */ 72789Sahrens boolean_t z_issnap; /* true if this is a snapshot */ 735331Samw boolean_t z_vscan; /* virus scan on/off */ 745331Samw boolean_t z_use_fuids; /* version allows fuids */ 758227SNeil.Perrin@Sun.COM boolean_t z_replay; /* set during ZIL replay */ 7611935SMark.Shellenbaum@Sun.COM boolean_t z_use_sa; /* version allow system attributes */ 776083Sek110237 uint64_t z_version; /* ZPL version */ 788845Samw@Sun.COM uint64_t z_shares_dir; /* hidden shares dir */ 799030SMark.Shellenbaum@Sun.COM kmutex_t z_lock; 809396SMatthew.Ahrens@Sun.COM uint64_t z_userquota_obj; 819396SMatthew.Ahrens@Sun.COM uint64_t z_groupquota_obj; 82*12772SNeil.Perrin@Sun.COM uint64_t z_replay_eof; /* New end of file - replay only */ 8311935SMark.Shellenbaum@Sun.COM sa_attr_type_t *z_attr_table; /* SA attr mapping->id */ 84789Sahrens #define ZFS_OBJ_MTX_SZ 64 85789Sahrens kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */ 86789Sahrens }; 87789Sahrens 88789Sahrens /* 894820Sek110237 * Normal filesystems (those not under .zfs/snapshot) have a total 904820Sek110237 * file ID size limited to 12 bytes (including the length field) due to 914820Sek110237 * NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical 924820Sek110237 * reasons, this same limit is being imposed by the Solaris NFSv3 implementation 934820Sek110237 * (although the NFSv3 protocol actually permits a maximum of 64 bytes). It 944820Sek110237 * is not possible to expand beyond 12 bytes without abandoning support 954820Sek110237 * of NFSv2. 96789Sahrens * 974820Sek110237 * For normal filesystems, we partition up the available space as follows: 98789Sahrens * 2 bytes fid length (required) 99789Sahrens * 6 bytes object number (48 bits) 100789Sahrens * 4 bytes generation number (32 bits) 1014820Sek110237 * 102789Sahrens * We reserve only 48 bits for the object number, as this is the limit 103789Sahrens * currently defined and imposed by the DMU. 104789Sahrens */ 105789Sahrens typedef struct zfid_short { 106789Sahrens uint16_t zf_len; 107789Sahrens uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */ 108789Sahrens uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */ 109789Sahrens } zfid_short_t; 110789Sahrens 1114820Sek110237 /* 1124820Sek110237 * Filesystems under .zfs/snapshot have a total file ID size of 22 bytes 1134820Sek110237 * (including the length field). This makes files under .zfs/snapshot 1144820Sek110237 * accessible by NFSv3 and NFSv4, but not NFSv2. 1154820Sek110237 * 1164820Sek110237 * For files under .zfs/snapshot, we partition up the available space 1174820Sek110237 * as follows: 1184820Sek110237 * 2 bytes fid length (required) 1194820Sek110237 * 6 bytes object number (48 bits) 1204820Sek110237 * 4 bytes generation number (32 bits) 1214820Sek110237 * 6 bytes objset id (48 bits) 1224820Sek110237 * 4 bytes currently just zero (32 bits) 1234820Sek110237 * 1244820Sek110237 * We reserve only 48 bits for the object number and objset id, as these are 1254820Sek110237 * the limits currently defined and imposed by the DMU. 1264820Sek110237 */ 127789Sahrens typedef struct zfid_long { 128789Sahrens zfid_short_t z_fid; 129789Sahrens uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */ 130789Sahrens uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */ 131789Sahrens } zfid_long_t; 132789Sahrens 133789Sahrens #define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t)) 134789Sahrens #define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t)) 135789Sahrens 1364720Sfr157268 extern uint_t zfs_fsyncer_key; 1374720Sfr157268 13810298SMatthew.Ahrens@Sun.COM extern int zfs_suspend_fs(zfsvfs_t *zfsvfs); 13910298SMatthew.Ahrens@Sun.COM extern int zfs_resume_fs(zfsvfs_t *zfsvfs, const char *osname); 1409396SMatthew.Ahrens@Sun.COM extern int zfs_userspace_one(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 1419396SMatthew.Ahrens@Sun.COM const char *domain, uint64_t rid, uint64_t *valuep); 1429396SMatthew.Ahrens@Sun.COM extern int zfs_userspace_many(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 1439396SMatthew.Ahrens@Sun.COM uint64_t *cookiep, void *vbuf, uint64_t *bufsizep); 1449396SMatthew.Ahrens@Sun.COM extern int zfs_set_userquota(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type, 1459396SMatthew.Ahrens@Sun.COM const char *domain, uint64_t rid, uint64_t quota); 14611935SMark.Shellenbaum@Sun.COM extern boolean_t zfs_owner_overquota(zfsvfs_t *zfsvfs, struct znode *, 14711935SMark.Shellenbaum@Sun.COM boolean_t isgroup); 14811935SMark.Shellenbaum@Sun.COM extern boolean_t zfs_fuid_overquota(zfsvfs_t *zfsvfs, boolean_t isgroup, 14911935SMark.Shellenbaum@Sun.COM uint64_t fuid); 1509396SMatthew.Ahrens@Sun.COM extern int zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers); 15111185SSean.McEnroe@Sun.COM extern int zfsvfs_create(const char *name, zfsvfs_t **zfvp); 1529396SMatthew.Ahrens@Sun.COM extern void zfsvfs_free(zfsvfs_t *zfsvfs); 15310972SRic.Aleshire@Sun.COM extern int zfs_check_global_label(const char *dsname, const char *hexsl); 1545326Sek110237 155789Sahrens #ifdef __cplusplus 156789Sahrens } 157789Sahrens #endif 158789Sahrens 159789Sahrens #endif /* _SYS_FS_ZFS_VFSOPS_H */ 160