xref: /titanic_44/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_maptbl.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *
24  *			cfsd_maptbl.h
25  *
26  * Include file for the maptbl class.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 /* Copyright (c) 1994 by Sun Microsystems, Inc. */
31 
32 #ifndef CFSD_MAPTBL
33 #define	CFSD_MAPTBL
34 
35 typedef struct cfsd_maptbl_object {
36 	char		i_name[MAXPATHLEN * 3];	/* name of file */
37 	int		i_fid;			/* fid of file */
38 	off_t		i_size;			/* file size */
39 	int		i_entries;		/* number of entries */
40 	int		i_hash2mod;		/* second hash module value */
41 	int		i_stat_filled;		/* number of filled entries */
42 	int		i_stat_requests;	/* number of lookups done */
43 	int		i_stat_probes;		/* number of probes */
44 	int		i_stat_mapmove;		/* number of times map moved */
45 	long		i_stat_mapdist;		/* how far we move the map */
46 	caddr_t	i_pa;				/* address of mmap section */
47 	size_t	i_palen;			/* length of mmap section */
48 	off_t		i_paoff;		/* offset of mmap section */
49 	off_t		i_paend;		/* end offset of mmap section */
50 	long		i_pagesize;		/* size of a page */
51 	u_long	i_pagemask;			/* page alignment mask */
52 	long		i_maplen;		/* amount to map */
53 } cfsd_maptbl_object_t;
54 
55 cfsd_maptbl_object_t *cfsd_maptbl_create(void);
56 void cfsd_maptbl_destroy(cfsd_maptbl_object_t *maptbl_object_p);
57 
58 int maptbl_domap(cfsd_maptbl_object_t *maptbl_object_p, off_t off);
59 caddr_t maptbl_getaddr(cfsd_maptbl_object_t *maptbl_object_p, int index);
60 int maptbll_cidhashaddr(cfsd_maptbl_object_t *maptbl_object_p,
61     cfs_cid_t cid, caddr_t *addrp);
62 int maptbl_hash1(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid);
63 int maptbl_hash2(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid,
64     int index);
65 
66 /* performs setup for the specified file */
67 int maptbl_setup(cfsd_maptbl_object_t *maptbl_object_p, const char *filename);
68 void maptbl_teardown(cfsd_maptbl_object_t *maptbl_object_p);
69 
70 /* gets/sets cid mapping */
71 int maptbl_get(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid,
72     struct cfs_dlog_mapping_space *valuep);
73 int maptbl_set(cfsd_maptbl_object_t *maptbl_object_p,
74     struct cfs_dlog_mapping_space *valuep, int insert);
75 
76 /* prints out various stats about the hashing */
77 void maptbl_dumpstats(cfsd_maptbl_object_t *maptbl_object_p);
78 
79 #endif /* CFSD_MAPTBL */
80