zfs_znode.h revision c9030f6c93613fe30ee0c16f92b96da7816ac052
/*
* 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
* 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) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_FS_ZFS_ZNODE_H
#define _SYS_FS_ZFS_ZNODE_H
#ifdef _KERNEL
#include <sys/isa_defs.h>
#include <sys/zfs_vfsops.h>
#include <sys/zfs_stat.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Additional file level attributes, that are stored
* in the upper half of zp_flags
*/
#define ZFS_READONLY 0x0000000100000000
#define ZFS_HIDDEN 0x0000000200000000
#define ZFS_SYSTEM 0x0000000400000000
#define ZFS_ARCHIVE 0x0000000800000000
#define ZFS_IMMUTABLE 0x0000001000000000
#define ZFS_NOUNLINK 0x0000002000000000
#define ZFS_APPENDONLY 0x0000004000000000
#define ZFS_NODUMP 0x0000008000000000
#define ZFS_OPAQUE 0x0000010000000000
#define ZFS_AV_QUARANTINED 0x0000020000000000
#define ZFS_AV_MODIFIED 0x0000040000000000
#define ZFS_REPARSE 0x0000080000000000
#define ZFS_OFFLINE 0x0000100000000000
#define ZFS_SPARSE 0x0000200000000000
{ \
if (value) \
else \
}
/*
* Define special zfs pflags
*/
/*
* Is ID ephemeral?
*/
#define IS_EPHEMERAL(x) (x > MAXUID)
/*
* Should we use FUIDs?
*/
#define MASTER_NODE_OBJ 1
/*
* Special attributes for master node.
* "userquota@" and "groupquota@" are also valid (from
* zfs_userquota_prop_prefixes[]).
*/
#define ZFS_FSID "FSID"
#define ZFS_UNLINKED_SET "DELETE_QUEUE"
#define ZFS_ROOT_OBJ "ROOT"
#define ZPL_VERSION_STR "VERSION"
#define ZFS_FUID_TABLES "FUID"
#define ZFS_SHARES_DIR "SHARES"
#define ZFS_SA_ATTRS "SA_ATTRS"
#define ZFS_MAX_BLOCKSIZE (SPA_MAXBLOCKSIZE)
/*
* Path component length
*
* The generic fs code uses MAXNAMELEN to represent
* what the largest component length is. Unfortunately,
* this length includes the terminating NULL. ZFS needs
* to tell the users via pathconf() and statvfs() what the
* true maximum length of a component is, excluding the NULL.
*/
/*
* Convert mode bits (zp_mode) to BSD-style DT_* values for storing in
* the directory entries.
*/
/*
* The directory entry has the type (currently unused on Solaris) in the
* top 4 bits, and the object number in the low 48 bits. The "middle"
* 12 bits are unused.
*/
/*
* Directory entry locks control access to directory entries.
* They are used to protect creates, deletes, and renames.
* Each directory znode has a mutex and a list of locked names.
*/
#ifdef _KERNEL
typedef struct zfs_dirlock {
char *dl_name; /* directory entry being locked */
typedef struct znode {
} znode_t;
/*
* Range locking rules
* --------------------
* 1. When truncating a file (zfs_create, zfs_setattr, zfs_space) the whole
* file range needs to be locked as RL_WRITER. Only then can the pages be
* freed etc and zp_size reset. zp_size must be set within range lock.
* 2. For writes and punching holes (zfs_write & zfs_space) just the range
* being written or freed needs to be locked as RL_WRITER.
* Multiple writes at the end of the file must coordinate zp_size updates
* to ensure data isn't lost. A compare and swap loop is currently used
* to ensure the file size is at least the offset last written.
* 3. For reads (zfs_read, zfs_get_data & zfs_putapage) just the range being
* read needs to be locked as RL_READER. A check against zp_size can then
* be made for reading beyond end of file.
*/
/*
* Convert between znode pointers and vnode pointers
*/
/* Called on entry to each ZFS vnode and vfs operation */
{ \
if ((zfsvfs)->z_unmounted) { \
return (EIO); \
} \
}
/* Must be called before exiting the vop */
/* Verifies the znode is valid */
#define ZFS_VERIFY_ZP(zp) \
return (EIO); \
} \
/*
* Macros for dealing with dmu_buf_hold
*/
/* Encode ZFS stored time values from a struct timespec */
{ \
}
/* Decode ZFS stored time values to a struct timespec */
{ \
}
/*
* Timestamp defines
*/
#define STATE_CHANGED (AT_CTIME)
extern void zfs_set_dataprop(objset_t *);
extern void zfs_znode_init(void);
extern void zfs_znode_fini(void);
extern int zfs_rezget(znode_t *);
extern void zfs_zinactive(znode_t *);
extern void zfs_znode_free(znode_t *);
extern void zfs_remove_op_tables();
extern int zfs_create_op_tables();
extern void zfs_znode_dmu_fini(znode_t *);
#define ZFS_NO_OBJECT 0 /* no object id */
extern zil_get_data_t zfs_get_data;
extern int zfsfstype;
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_ZFS_ZNODE_H */