snode.h revision e099bf07784b9aadc4cc8655e69d462397e99860
/*
* 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) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FS_SNODE_H
#define _SYS_FS_SNODE_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* The snode represents a special file in any filesystem. There is
* one snode for each active special file. Filesystems that support
* special files use specvp(vp, dev, type, cr) to convert a normal
* vnode to a special vnode in the ops lookup() and create().
*
* To handle having multiple snodes that represent the same
* underlying device vnode without cache aliasing problems,
* the s_commonvp is used to point to the "common" vnode used for
* caching data. If an snode is created internally by the kernel,
* then the s_realvp field is NULL and s_commonvp points to s_vnode.
* The other snodes which are created as a result of a lookup of a
* device in a file system have s_realvp pointing to the vp which
* represents the device in the file system while the s_commonvp points
* into the "common" vnode for the device in another snode.
*/
/*
* Include SUNDDI type definitions so that the s_dip tag doesn't urk.
*/
#include <sys/dditypes.h>
#ifdef __cplusplus
extern "C" {
#endif
struct snode {
/* These fields are protected by stable_lock */
/*
* These fields are initialized once.
*/
/*
* Doesn't always need to be updated atomically because it is a hint.
* No lock required.
*/
/* These fields are protected by spec_syncbusy */
/* These fields are protected by s_lock */
int s_count; /* count of opened references */
long s_mapcnt; /* count of mappings of pages */
/* The locks themselves */
};
/* flags */
/* the driver, even though it may */
/* not currently have an association */
/* with a specific hardware instance */
/* if s_dip is NULL */
/* been multiplexed */
#ifdef _KERNEL
/*
* Convert between vnode and snode
*/
/*
* Forward declarations
*/
struct vfssw;
struct cred;
extern struct vfsops spec_vfsops;
extern struct kmem_cache *snode_cache;
/*
* specfs functions
*/
struct vnodeops *spec_getvnodeops(void);
int specinit(int, char *);
struct cred *, dev_info_t *);
int spec_is_clone(struct vnode *);
int spec_is_selfclone(struct vnode *);
/*
* UNKNOWN_SIZE: If driver does not support the [Ss]ize or [Nn]blocks property
* then the size is assumed to be "infinite". Note that this "infinite" value
* may need to be converted to a smaller "infinite" value to avoid EOVERFLOW at
* field width conversion locations like the stat(2) and NFS code running
* against a special file. Special file code outside specfs may check the
* type of the vnode (VCHR|VBLK) and use MAXOFFSET_T directly to detect
* UNKNOWN_SIZE.
*/
#define UNKNOWN_SIZE MAXOFFSET_T
/*
* SPEC_MAXOFFSET_T: Solaris does not fully support 64-bit offsets for D_64BIT
* (SLOFFSET) block drivers on a 32-bit kernels: daddr_t is still a signed
* 32-bit quantity - which limits the byte offset to 1TB. This issue goes
* beyond a driver needing to convert from daddr_t to diskaddr_t if it sets
* D_64BIT. Many of the DDI interfaces which take daddr_t arguments have no
* 64-bit counterpart (bioclone, blkflush, bread, bread_common, breada, getblk,
* getblk_common). SPEC_MAXOFFSET_T is used by 32-bit kernel code to enforce
* this restriction.
*/
#ifdef _ILP32
#ifdef _LONGLONG_TYPE
#else /* !defined(_LONGLONG_TYPE) */
#define SPEC_MAXOFFSET_T MAXOFF_T
#endif /* _LONGLONG_TYPE */
#endif /* _ILP32 */
/*
* Snode lookup stuff.
* These routines maintain a table of snodes hashed by dev so
* that the snode for an dev can be found if it already exists.
* NOTE: STABLESIZE must be a power of 2 for STABLEHASH to work!
*/
#define STABLESIZE 256
extern kmutex_t stable_lock;
extern kmutex_t spec_syncbusy;
/*
* Variables used by during asynchronous VOP_PUTPAGE operations.
*/
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_SNODE_H */