xref: /titanic_44/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_fscache.h (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
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  * Copyright (c) 1994-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_CFSD_FSCACHE_H
28 #define	_CFSD_FSCACHE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	CFS_MAXMNTOPTLEN	MAXPATHLEN * 4
37 
38 typedef struct cfsd_fscache_object {
39 	char	i_name[MAXNAMELEN];		/* fscache name */
40 	char	i_cachepath[MAXPATHLEN];	/* cache pathname */
41 	int	i_fscacheid;			/* fscache identifier */
42 
43 	char	i_mntpt[MAXPATHLEN];		/* mount point */
44 	char	i_backfs[MAXPATHLEN * 2];	/* back file system */
45 	char	i_backpath[MAXPATHLEN];		/* back file system path */
46 	char	i_backfstype[MAXNAMELEN];	/* back file system type */
47 	char	i_cfsopt[CFS_MAXMNTOPTLEN];	/* cachefs mount options */
48 	char	i_bfsopt[CFS_MAXMNTOPTLEN];	/* backfs mount options */
49 
50 	mutex_t		i_lock;			/* synchronizing lock */
51 	int		i_refcnt;		/* refs to object */
52 	volatile int	i_disconnectable:1;	/* 1 if okay to disconnect */
53 	volatile int	i_mounted:1;		/* 1 if fs is mounted */
54 	volatile int	i_threaded:1;		/* 1 if thread running */
55 	volatile int	i_connected:1;		/* 1 if connected */
56 	volatile int	i_reconcile:1;		/* 1 if reconciling */
57 	volatile int	i_changes:1;		/* 1 if changes to push back */
58 	volatile int	i_simdis:1;		/* 1 means sim disconnect */
59 	volatile int	i_tryunmount:1;		/* 1 if should try unmount */
60 	volatile int	i_backunmount:1;	/* 1 if need to umount backfs */
61 	time_t		i_time_state;		/* time of last dis/connect */
62 	time_t		i_time_mnt;		/* time of last u/mount */
63 	int		i_modify;		/* changed when modified */
64 
65 	int		i_ofd;			/* message file descriptor */
66 
67 	thread_t	i_threadid;		/* id of thread, if running */
68 	cond_t		i_cvwait;		/* cond var to wait on */
69 
70 	off_t		i_again_offset;		/* offset to head modify op */
71 	int		i_again_seq;		/* seq num of head modify op */
72 	struct cfsd_fscache_object *i_next;	/* next fscache object */
73 } cfsd_fscache_object_t;
74 
75 cfsd_fscache_object_t *cfsd_fscache_create(const char *name,
76     const char *cachepath, int fscacheid);
77 void cfsd_fscache_destroy(cfsd_fscache_object_t *fscache_object_p);
78 
79 void fscache_lock(cfsd_fscache_object_t *fscache_object_p);
80 void fscache_unlock(cfsd_fscache_object_t *fscache_object_p);
81 
82 void fscache_setup(cfsd_fscache_object_t *fscache_object_p);
83 void fscache_process(cfsd_fscache_object_t *fscache_object_p);
84 int fscache_simdisconnect(cfsd_fscache_object_t *fscache_object_p,
85     int disconnect);
86 int fscache_unmount(cfsd_fscache_object_t *fscache_object_p, int);
87 void fscache_server_alive(cfsd_fscache_object_t *fscache_object_p,
88     cfsd_kmod_object_t *kmod_object_p);
89 int fscache_pingserver(cfsd_fscache_object_t *fscache_object_p);
90 int fscache_roll(cfsd_fscache_object_t *fscache_object_p,
91     cfsd_kmod_object_t *kmod_object_p);
92 int fscache_rollone(cfsd_fscache_object_t *fscache_object_p,
93     cfsd_kmod_object_t *kmod_object_p,
94     cfsd_maptbl_object_t *maptbl_object_p,
95     cfsd_logfile_object_t *logfile_object_p,
96     ulong_t seq);
97 int fscache_addagain(cfsd_fscache_object_t *fscache_object_p,
98     cfsd_logfile_object_t *logfile_object_p,
99     ulong_t nseq);
100 void fscache_fsproblem(cfsd_fscache_object_t *fscache_object_p,
101     cfsd_kmod_object_t *kmod_object_p);
102 void fscache_changes(cfsd_fscache_object_t *fscache_object_p, int tt);
103 
104 #ifdef	__cplusplus
105 }
106 #endif
107 
108 #endif	/* _CFSD_FSCACHE_H */
109