1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * 24*0Sstevel@tonic-gate * cfsd_logfile.h 25*0Sstevel@tonic-gate * 26*0Sstevel@tonic-gate * Include file for the cfsd_logfile class. 27*0Sstevel@tonic-gate */ 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 30*0Sstevel@tonic-gate /* Copyright (c) 1994 by Sun Microsystems, Inc. */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifndef CFSD_LOGFILE 33*0Sstevel@tonic-gate #define CFSD_LOGFILE 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate /* should come up with a standard dlog version size */ 36*0Sstevel@tonic-gate /* XXX should move these to <sys/fs/cachefs_dlog.h> */ 37*0Sstevel@tonic-gate #define LOGFILE_ENTRY_START sizeof (long) 38*0Sstevel@tonic-gate #define CFS_DLOG_ENTRY_MINSIZE sizeof (long) 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* mmap info */ 41*0Sstevel@tonic-gate typedef struct mmap_info { 42*0Sstevel@tonic-gate caddr_t i_pa; /* address of mmap section */ 43*0Sstevel@tonic-gate size_t i_palen; /* length of mmap section */ 44*0Sstevel@tonic-gate off_t i_paoff; /* offset of mmap section */ 45*0Sstevel@tonic-gate off_t i_paend; /* end offset of mmap section */ 46*0Sstevel@tonic-gate }mmap_info_t; 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate typedef struct cfsd_logfile_object { 49*0Sstevel@tonic-gate char i_name[MAXPATHLEN * 3]; /* name of file */ 50*0Sstevel@tonic-gate int i_fid; /* fid of file */ 51*0Sstevel@tonic-gate off_t i_size; /* file size */ 52*0Sstevel@tonic-gate int i_stat_nextcnt; /* number of next calls */ 53*0Sstevel@tonic-gate int i_stat_offcnt; /* number of offset calls */ 54*0Sstevel@tonic-gate int i_stat_mapmove; /* number of times map moved */ 55*0Sstevel@tonic-gate long i_stat_mapdist; /* how far we move the map */ 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate mmap_info_t i_map_entry; /* mmap for log entries */ 58*0Sstevel@tonic-gate mmap_info_t i_map_offset; /* mmap for arbitrary offsets */ 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate off_t i_cur_offset; /* offset to log entry */ 61*0Sstevel@tonic-gate cfs_dlog_entry_t *i_cur_entry; /* ptr to log entry */ 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate long i_pagesize; /* size of a page */ 64*0Sstevel@tonic-gate u_long i_pagemask; /* page alignment mask */ 65*0Sstevel@tonic-gate long i_maplen; /* amount to map */ 66*0Sstevel@tonic-gate int i_maxmap; /* max amount referenced */ 67*0Sstevel@tonic-gate } cfsd_logfile_object_t; 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate cfsd_logfile_object_t *cfsd_logfile_create(void); 70*0Sstevel@tonic-gate void cfsd_logfile_destroy(cfsd_logfile_object_t *cfsd_logfile_object_p); 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate int logfile_domap(cfsd_logfile_object_t *logfile_object_p, off_t off, int map); 73*0Sstevel@tonic-gate caddr_t logfile_getaddr(cfsd_logfile_object_t *logfile_object_p, 74*0Sstevel@tonic-gate off_t start, int map); 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate /* performs setup for the specified file */ 77*0Sstevel@tonic-gate int logfile_setup(cfsd_logfile_object_t *logfile_object_p, 78*0Sstevel@tonic-gate const char *filename, int maxmap); 79*0Sstevel@tonic-gate void logfile_teardown(cfsd_logfile_object_t *logfile_object_p); 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* returns ptr to a log file entry */ 82*0Sstevel@tonic-gate int logfile_entry(cfsd_logfile_object_t *logfile_object_p, off_t offset, 83*0Sstevel@tonic-gate cfs_dlog_entry_t **entpp); 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* returns ptr to arbitrary point in log */ 86*0Sstevel@tonic-gate int logfile_offset(cfsd_logfile_object_t *logfile_object_p, off_t offset, 87*0Sstevel@tonic-gate caddr_t *addrp); 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* syncs the logfile to disk */ 90*0Sstevel@tonic-gate int logfile_sync(cfsd_logfile_object_t *logfile_object_p); 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* prints out various stats how the log file is used */ 93*0Sstevel@tonic-gate void logfile_dumpstats(cfsd_logfile_object_t *logfile_object_p); 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate #endif /* CFSD_LOGFILE */ 96