xmem.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FS_XMEM_H
#define _SYS_FS_XMEM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
/*
* xmemnode is the file system dependent node for xmemfs.
*
* xn_rwlock protects access of the directory list at xn_dir
* as well as syncronizing read and writes to the xmemnode
*
* xn_contents protects growing, shrinking, reading and writing
* the file along with xn_rwlock (see below).
*
* xn_tlock protects updates to xn_mode and xn_nlink
*
* xm_contents in the xmount filesystem data structure protects
* xn_forw and xn_back which are used to maintain a linked
* list of all xmemfs files associated with that file system
*
* XXX - valid ? The pp array represents the store for xmemfs.
* To grow or shrink the file or fill in holes requires
* manipulation of the pp array. These operations are protected
* by a combination of xn_rwlock and xn_contents. Growing or shrinking
* the array requires the write lock on xn_rwlock and xn_contents.
* Filling in a slot in the array requires the write lock on xn_contents.
* Reading the array requires the read lock on xn_contents.
*
* The ordering of the locking is:
* xn_rwlock -> xn_contents -> page locks on pages in file
*
* xn_tlock doesn't require any xmemnode locks
*/
struct xmemnode {
union {
struct {
} un_dirstruct;
char *un_symlink; /* pointer to symlink */
struct {
} un_ppstruct;
} un_xmemnode;
int xn_gen; /* pseudo gen number for xfid */
/* mods and directory updates */
};
/*
* each xn_ppa[] entry points to an array of page_t pointers.
*/
/*
* Attributes
*/
/*
* xmemfs directories are made up of a linked list of xdirent structures
* hanging off directory xmemnodes. File names are not fixed length,
* but are null terminated.
*/
struct xdirent {
char *xd_name; /* must be null terminated */
/* max length is MAXNAMELEN */
};
/*
* xfid overlays the fid structure (for VFS_VGET)
*/
struct xfid {
};
extern struct vnodeops *xmem_vnodeops;
extern const struct fs_operation_def xmem_vnodeops_template[];
/*
* xmemfs per-mount data structure.
*
* All fields are protected by xm_contents.
* File renames on a particular file system are protected xm_renamelck.
*/
struct xmount {
char *xm_mntpath; /* name of xmemfs mount point */
void **xm_xpgarray; /* array of pointers */
};
#ifndef DEBUG
#else
extern int xmemlevel;
/*PRINTFLIKE1*/
extern void xmemprintf(const char *, ...)
__KPRINTFLIKE(1);
#endif
#endif /* _KERNEL */
#pragma pack(4)
#endif
/*
* Make sizeof struct xmemfs_args the same on x86 and amd64.
*/
struct xmemfs_args {
};
#pragma pack()
#endif
/* Flag bits */
#ifdef _KERNEL
/*
* File system independent to xmemfs conversion macros
*/
/*
* enums
*/
/*
* xmemfs_minfree is the amount (in pages) of memory that xmemfs
* leaves free for the rest of the system.
* NB: If xmemfs allocates too much space, other processes will be
* unable to execute. 320 is chosen arbitrarily to be about right for
* an RDBMS environment with all of it's buffers coming from xmemfs.
*/
/*
* below. We cannot set it much higher as we expect typical block
* size to be 2MB or 4MB and we cannot afford to reserve and keep
* too much kernel virtual memory for ourselves.
*/
#define SEGXMEM_NUM_SIMULMAPS 4
struct cred *);
extern void *xmem_memalloc(size_t, int);
extern void xmem_memfree(void *, size_t);
extern int xmem_xaccess(void *, int, struct cred *);
offset_t, int);
struct cred *);
#endif /* _KERNEL */
#define XMEM_MUSTHAVE 1
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_XMEM_H */