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_logfile.h
25 *
26 * Include file for the cfsd_logfile class.
27 */
28
29 #pragma ident "%Z%%M% %I% %E% SMI"
30 /* Copyright (c) 1994 by Sun Microsystems, Inc. */
31
32 #ifndef CFSD_LOGFILE
33 #define CFSD_LOGFILE
34
35 /* should come up with a standard dlog version size */
36 /* XXX should move these to <sys/fs/cachefs_dlog.h> */
37 #define LOGFILE_ENTRY_START sizeof (long)
38 #define CFS_DLOG_ENTRY_MINSIZE sizeof (long)
39
40 /* mmap info */
41 typedef struct mmap_info {
42 caddr_t i_pa; /* address of mmap section */
43 size_t i_palen; /* length of mmap section */
44 off_t i_paoff; /* offset of mmap section */
45 off_t i_paend; /* end offset of mmap section */
46 }mmap_info_t;
47
48 typedef struct cfsd_logfile_object {
49 char i_name[MAXPATHLEN * 3]; /* name of file */
50 int i_fid; /* fid of file */
51 off_t i_size; /* file size */
52 int i_stat_nextcnt; /* number of next calls */
53 int i_stat_offcnt; /* number of offset calls */
54 int i_stat_mapmove; /* number of times map moved */
55 long i_stat_mapdist; /* how far we move the map */
56
57 mmap_info_t i_map_entry; /* mmap for log entries */
58 mmap_info_t i_map_offset; /* mmap for arbitrary offsets */
59
60 off_t i_cur_offset; /* offset to log entry */
61 cfs_dlog_entry_t *i_cur_entry; /* ptr to log entry */
62
63 long i_pagesize; /* size of a page */
64 u_long i_pagemask; /* page alignment mask */
65 long i_maplen; /* amount to map */
66 int i_maxmap; /* max amount referenced */
67 } cfsd_logfile_object_t;
68
69 cfsd_logfile_object_t *cfsd_logfile_create(void);
70 void cfsd_logfile_destroy(cfsd_logfile_object_t *cfsd_logfile_object_p);
71
72 int logfile_domap(cfsd_logfile_object_t *logfile_object_p, off_t off, int map);
73 caddr_t logfile_getaddr(cfsd_logfile_object_t *logfile_object_p,
74 off_t start, int map);
75
76 /* performs setup for the specified file */
77 int logfile_setup(cfsd_logfile_object_t *logfile_object_p,
78 const char *filename, int maxmap);
79 void logfile_teardown(cfsd_logfile_object_t *logfile_object_p);
80
81 /* returns ptr to a log file entry */
82 int logfile_entry(cfsd_logfile_object_t *logfile_object_p, off_t offset,
83 cfs_dlog_entry_t **entpp);
84
85 /* returns ptr to arbitrary point in log */
86 int logfile_offset(cfsd_logfile_object_t *logfile_object_p, off_t offset,
87 caddr_t *addrp);
88
89 /* syncs the logfile to disk */
90 int logfile_sync(cfsd_logfile_object_t *logfile_object_p);
91
92 /* prints out various stats how the log file is used */
93 void logfile_dumpstats(cfsd_logfile_object_t *logfile_object_p);
94
95 #endif /* CFSD_LOGFILE */