3558fd73b5
I appologize in advance why to many things ended up in this commit. When it could be seperated in to a whole series of commits teasing that all apart now would take considerable time and I'm not sure there's much merrit in it. As such I'll just summerize the intent of the changes which are all (or partly) in this commit. Broadly the intent is to remove as much Solaris specific code as possible and replace it with native Linux equivilants. More specifically: 1) Replace all instances of zfsvfs_t with zfs_sb_t. While the type is largely the same calling it private super block data rather than a zfsvfs is more consistent with how Linux names this. While non critical it makes the code easier to read when your thinking in Linux friendly VFS terms. 2) Replace vnode_t with struct inode. The Linux VFS doesn't have the notion of a vnode and there's absolutely no good reason to create one. There are in fact several good reasons to remove it. It just adds overhead on Linux if we were to manage one, it conplicates the code, and it likely will lead to bugs so there's a good change it will be out of date. The code has been updated to remove all need for this type. 3) Replace all vtype_t's with umode types. Along with this shift all uses of types to mode bits. The Solaris code would pass a vtype which is redundant with the Linux mode. Just update all the code to use the Linux mode macros and remove this redundancy. 4) Remove using of vn_* helpers and replace where needed with inode helpers. The big example here is creating iput_aync to replace vn_rele_async. Other vn helpers will be addressed as needed but they should be be emulated. They are a Solaris VFS'ism and should simply be replaced with Linux equivilants. 5) Update znode alloc/free code. Under Linux it's common to embed the inode specific data with the inode itself. This removes the need for an extra memory allocation. In zfs this information is called a znode and it now embeds the inode with it. Allocators have been updated accordingly. 6) Minimal integration with the vfs flags for setting up the super block and handling mount options has been added this code will need to be refined but functionally it's all there. This will be the first and last of these to large to review commits.
199 lines
7.2 KiB
C
199 lines
7.2 KiB
C
/*
|
|
* CDDL HEADER START
|
|
*
|
|
* The contents of this file are subject to the terms of the
|
|
* Common Development and Distribution License (the "License").
|
|
* You may not use this file except in compliance with the License.
|
|
*
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
* See the License for the specific language governing permissions
|
|
* and limitations under the License.
|
|
*
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
*
|
|
* CDDL HEADER END
|
|
*/
|
|
/*
|
|
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _SYS_FS_ZFS_VFSOPS_H
|
|
#define _SYS_FS_ZFS_VFSOPS_H
|
|
|
|
#include <sys/isa_defs.h>
|
|
#include <sys/types32.h>
|
|
#include <sys/list.h>
|
|
#include <sys/vfs.h>
|
|
#include <sys/zil.h>
|
|
#include <sys/sa.h>
|
|
#include <sys/rrwlock.h>
|
|
#include <sys/zfs_ioctl.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
struct zfs_sb;
|
|
struct znode;
|
|
|
|
typedef struct zfs_sb {
|
|
struct vfsmount *z_vfs; /* generic vfs struct */
|
|
struct super_block *z_sb; /* generic super_block */
|
|
struct zfs_sb *z_parent; /* parent fs */
|
|
objset_t *z_os; /* objset reference */
|
|
uint64_t z_flags; /* super_block flags */
|
|
uint64_t z_root; /* id of root znode */
|
|
uint64_t z_unlinkedobj; /* id of unlinked zapobj */
|
|
uint64_t z_max_blksz; /* maximum block size for files */
|
|
uint64_t z_fuid_obj; /* fuid table object number */
|
|
uint64_t z_fuid_size; /* fuid table size */
|
|
avl_tree_t z_fuid_idx; /* fuid tree keyed by index */
|
|
avl_tree_t z_fuid_domain; /* fuid tree keyed by domain */
|
|
krwlock_t z_fuid_lock; /* fuid lock */
|
|
boolean_t z_fuid_loaded; /* fuid tables are loaded */
|
|
boolean_t z_fuid_dirty; /* need to sync fuid table ? */
|
|
struct zfs_fuid_info *z_fuid_replay; /* fuid info for replay */
|
|
zilog_t *z_log; /* intent log pointer */
|
|
uint_t z_acl_inherit; /* acl inheritance behavior */
|
|
zfs_case_t z_case; /* case-sense */
|
|
boolean_t z_utf8; /* utf8-only */
|
|
int z_norm; /* normalization flags */
|
|
boolean_t z_atime; /* enable atimes mount option */
|
|
boolean_t z_unmounted; /* unmounted */
|
|
rrwlock_t z_teardown_lock;
|
|
krwlock_t z_teardown_inactive_lock;
|
|
list_t z_all_znodes; /* all vnodes in the fs */
|
|
kmutex_t z_znodes_lock; /* lock for z_all_znodes */
|
|
struct inode *z_ctldir; /* .zfs directory inode */
|
|
boolean_t z_show_ctldir; /* expose .zfs in the root dir */
|
|
boolean_t z_issnap; /* true if this is a snapshot */
|
|
boolean_t z_vscan; /* virus scan on/off */
|
|
boolean_t z_use_fuids; /* version allows fuids */
|
|
boolean_t z_replay; /* set during ZIL replay */
|
|
boolean_t z_use_sa; /* version allow system attributes */
|
|
uint64_t z_version; /* ZPL version */
|
|
uint64_t z_shares_dir; /* hidden shares dir */
|
|
kmutex_t z_lock;
|
|
uint64_t z_userquota_obj;
|
|
uint64_t z_groupquota_obj;
|
|
uint64_t z_replay_eof; /* New end of file - replay only */
|
|
sa_attr_type_t *z_attr_table; /* SA attr mapping->id */
|
|
#define ZFS_OBJ_MTX_SZ 64
|
|
kmutex_t z_hold_mtx[ZFS_OBJ_MTX_SZ]; /* znode hold locks */
|
|
} zfs_sb_t;
|
|
|
|
#define ZFS_SUPER_MAGIC 0x2fc12fc1
|
|
|
|
#define ZSB_XATTR_USER 0x0001 /* Enable user xattrs */
|
|
|
|
|
|
/*
|
|
* Minimal snapshot helpers, the bulk of the Linux snapshot implementation
|
|
* lives in the zpl_snap.c file which is part of the zpl source.
|
|
*/
|
|
#define ZFS_CTLDIR_NAME ".zfs"
|
|
|
|
#define zfs_has_ctldir(zdp) \
|
|
((zdp)->z_id == ZTOZSB(zdp)->z_root && \
|
|
(ZTOZSB(zdp)->z_ctldir != NULL))
|
|
#define zfs_show_ctldir(zdp) \
|
|
(zfs_has_ctldir(zdp) && \
|
|
(ZTOZSB(zdp)->z_show_ctldir))
|
|
|
|
#define ZFSCTL_INO_ROOT 0x1
|
|
#define ZFSCTL_INO_SNAPDIR 0x2
|
|
#define ZFSCTL_INO_SHARES 0x3
|
|
|
|
/*
|
|
* Allow a maximum number of links. While ZFS does not internally limit
|
|
* this most Linux filesystems do. It's probably a good idea to limit
|
|
* this to a large value until it is validated that this is safe.
|
|
*/
|
|
#define ZFS_LINK_MAX 65536
|
|
|
|
/*
|
|
* Normal filesystems (those not under .zfs/snapshot) have a total
|
|
* file ID size limited to 12 bytes (including the length field) due to
|
|
* NFSv2 protocol's limitation of 32 bytes for a filehandle. For historical
|
|
* reasons, this same limit is being imposed by the Solaris NFSv3 implementation
|
|
* (although the NFSv3 protocol actually permits a maximum of 64 bytes). It
|
|
* is not possible to expand beyond 12 bytes without abandoning support
|
|
* of NFSv2.
|
|
*
|
|
* For normal filesystems, we partition up the available space as follows:
|
|
* 2 bytes fid length (required)
|
|
* 6 bytes object number (48 bits)
|
|
* 4 bytes generation number (32 bits)
|
|
*
|
|
* We reserve only 48 bits for the object number, as this is the limit
|
|
* currently defined and imposed by the DMU.
|
|
*/
|
|
typedef struct zfid_short {
|
|
uint16_t zf_len;
|
|
uint8_t zf_object[6]; /* obj[i] = obj >> (8 * i) */
|
|
uint8_t zf_gen[4]; /* gen[i] = gen >> (8 * i) */
|
|
} zfid_short_t;
|
|
|
|
/*
|
|
* Filesystems under .zfs/snapshot have a total file ID size of 22 bytes
|
|
* (including the length field). This makes files under .zfs/snapshot
|
|
* accessible by NFSv3 and NFSv4, but not NFSv2.
|
|
*
|
|
* For files under .zfs/snapshot, we partition up the available space
|
|
* as follows:
|
|
* 2 bytes fid length (required)
|
|
* 6 bytes object number (48 bits)
|
|
* 4 bytes generation number (32 bits)
|
|
* 6 bytes objset id (48 bits)
|
|
* 4 bytes currently just zero (32 bits)
|
|
*
|
|
* We reserve only 48 bits for the object number and objset id, as these are
|
|
* the limits currently defined and imposed by the DMU.
|
|
*/
|
|
typedef struct zfid_long {
|
|
zfid_short_t z_fid;
|
|
uint8_t zf_setid[6]; /* obj[i] = obj >> (8 * i) */
|
|
uint8_t zf_setgen[4]; /* gen[i] = gen >> (8 * i) */
|
|
} zfid_long_t;
|
|
|
|
#define SHORT_FID_LEN (sizeof (zfid_short_t) - sizeof (uint16_t))
|
|
#define LONG_FID_LEN (sizeof (zfid_long_t) - sizeof (uint16_t))
|
|
|
|
extern uint_t zfs_fsyncer_key;
|
|
|
|
extern int zfs_suspend_fs(zfs_sb_t *zsb);
|
|
extern int zfs_resume_fs(zfs_sb_t *zsb, const char *osname);
|
|
extern int zfs_userspace_one(zfs_sb_t *zsb, zfs_userquota_prop_t type,
|
|
const char *domain, uint64_t rid, uint64_t *valuep);
|
|
extern int zfs_userspace_many(zfs_sb_t *zsb, zfs_userquota_prop_t type,
|
|
uint64_t *cookiep, void *vbuf, uint64_t *bufsizep);
|
|
extern int zfs_set_userquota(zfs_sb_t *zsb, zfs_userquota_prop_t type,
|
|
const char *domain, uint64_t rid, uint64_t quota);
|
|
extern boolean_t zfs_owner_overquota(zfs_sb_t *zsb, struct znode *,
|
|
boolean_t isgroup);
|
|
extern boolean_t zfs_fuid_overquota(zfs_sb_t *zsb, boolean_t isgroup,
|
|
uint64_t fuid);
|
|
extern int zfs_set_version(zfs_sb_t *zsb, uint64_t newvers);
|
|
extern int zfs_sb_create(const char *name, zfs_sb_t **zsbp);
|
|
extern void zfs_sb_free(zfs_sb_t *zsb);
|
|
extern int zfs_check_global_label(const char *dsname, const char *hexsl);
|
|
|
|
extern int zfs_register_callbacks(zfs_sb_t *zsb);
|
|
extern void zfs_unregister_callbacks(zfs_sb_t *zsb);
|
|
extern int zfs_domount(struct super_block *sb, void *data, int silent);
|
|
extern int zfs_umount(struct super_block *sb);
|
|
extern int zfs_root(zfs_sb_t *zsb, struct inode **ipp);
|
|
extern int zfs_statvfs(struct dentry *dentry, struct kstatfs *statp);
|
|
extern int zfs_vget(struct vfsmount *vfsp, struct inode **ipp, fid_t *fidp);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SYS_FS_ZFS_VFSOPS_H */
|