summaryrefslogtreecommitdiff
path: root/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_maptbl.h
blob: 18a0f7d669c6a5777d0fd74c737e2e09d05cd1e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * 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
 * 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
 */
/*
 *
 *			cfsd_maptbl.h
 *
 * Include file for the maptbl class.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"
/* Copyright (c) 1994 by Sun Microsystems, Inc. */

#ifndef CFSD_MAPTBL
#define	CFSD_MAPTBL

typedef struct cfsd_maptbl_object {
	char		i_name[MAXPATHLEN * 3];	/* name of file */
	int		i_fid;			/* fid of file */
	off_t		i_size;			/* file size */
	int		i_entries;		/* number of entries */
	int		i_hash2mod;		/* second hash module value */
	int		i_stat_filled;		/* number of filled entries */
	int		i_stat_requests;	/* number of lookups done */
	int		i_stat_probes;		/* number of probes */
	int		i_stat_mapmove;		/* number of times map moved */
	long		i_stat_mapdist;		/* how far we move the map */
	caddr_t	i_pa;				/* address of mmap section */
	size_t	i_palen;			/* length of mmap section */
	off_t		i_paoff;		/* offset of mmap section */
	off_t		i_paend;		/* end offset of mmap section */
	long		i_pagesize;		/* size of a page */
	u_long	i_pagemask;			/* page alignment mask */
	long		i_maplen;		/* amount to map */
} cfsd_maptbl_object_t;

cfsd_maptbl_object_t *cfsd_maptbl_create(void);
void cfsd_maptbl_destroy(cfsd_maptbl_object_t *maptbl_object_p);

int maptbl_domap(cfsd_maptbl_object_t *maptbl_object_p, off_t off);
caddr_t maptbl_getaddr(cfsd_maptbl_object_t *maptbl_object_p, int index);
int maptbll_cidhashaddr(cfsd_maptbl_object_t *maptbl_object_p,
    cfs_cid_t cid, caddr_t *addrp);
int maptbl_hash1(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid);
int maptbl_hash2(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid,
    int index);

/* performs setup for the specified file */
int maptbl_setup(cfsd_maptbl_object_t *maptbl_object_p, const char *filename);
void maptbl_teardown(cfsd_maptbl_object_t *maptbl_object_p);

/* gets/sets cid mapping */
int maptbl_get(cfsd_maptbl_object_t *maptbl_object_p, cfs_cid_t cid,
    struct cfs_dlog_mapping_space *valuep);
int maptbl_set(cfsd_maptbl_object_t *maptbl_object_p,
    struct cfs_dlog_mapping_space *valuep, int insert);

/* prints out various stats about the hashing */
void maptbl_dumpstats(cfsd_maptbl_object_t *maptbl_object_p);

#endif /* CFSD_MAPTBL */