xref: /titanic_44/usr/src/uts/common/avs/ns/sdbc/sd_ft.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SD_FT_H
27 #define	_SD_FT_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/ncall/ncall.h>
34 
35 typedef struct _sd_ft_info {
36 	char 	fi_crashed;		/* mirror cache state */
37 	char 	fi_host_state;		/* mirror node state */
38 	kmutex_t	fi_lock;
39 	kcondvar_t	fi_rem_sv;
40 	volatile int 	fi_numio;
41 	kmutex_t fi_sleep;
42 
43 } _sd_ft_info_t;
44 
45 
46 #define	_SD_MIRROR_CONFIGD	(_sd_ft_data.fi_host_state ==\
47 				_SD_HOST_CONFIGURED)
48 #define	_SD_MIRROR_DECONFIGD	(_sd_ft_data.fi_host_state == \
49 				_SD_HOST_DECONFIGURED)
50 #define	_SD_MIRROR_NOCACHE	(_sd_ft_data.fi_host_state == \
51 				_SD_HOST_NOCACHE)
52 
53 #define	_SD_HOST_NONE		0x00	/* mirror node dead or state unknown */
54 #define	_SD_HOST_CONFIGURED	0x01	/* mirror cache configured */
55 #define	_SD_HOST_DECONFIGURED	0x02	/* mirror cache deconfigured */
56 #define	_SD_HOST_NOCACHE	0x03	/* mirror cache deconfigured and */
57 					/* waiting for node down or re-enable */
58 
59 /*
60  * mirror node has paniced with cache enabled,
61  * or mirror cache has been deconfigured.
62  */
63 #define	_sd_is_mirror_crashed()	((!_INFSD_NODE_UP(_SD_MIRROR_HOST) &&\
64 				_SD_MIRROR_CONFIGD) || _SD_MIRROR_DECONFIGD)
65 
66 /*
67  * mirror node has shutdown having previously
68  * deconfigured its cache.
69  */
70 #define	_sd_is_mirror_node_down()	\
71 				(!_INFSD_NODE_UP(_SD_MIRROR_HOST) &&\
72 				_SD_MIRROR_NOCACHE)
73 
74 #define	_sd_is_mirror_down()	(_sd_ft_data.fi_crashed)
75 #define	_sd_mirror_cache_down()	(_sd_ft_data.fi_crashed = 1,\
76 				_sd_ft_data.fi_host_state = _SD_HOST_NOCACHE)
77 #define	_sd_mirror_down()	(_sd_ft_data.fi_crashed = 1,\
78 				_sd_ft_data.fi_host_state = _SD_HOST_NONE)
79 #define	_sd_mirror_up()		(_sd_ft_data.fi_crashed = 0)
80 #ifdef _KERNEL
81 
82 extern _sd_ft_info_t _sd_ft_data;
83 extern int _sd_node_recovery;
84 
85 extern void _sdbc_ft_unload(void);
86 extern int _sdbc_ft_load(void);
87 extern int _sdbc_ft_configure(void);
88 extern void _sdbc_ft_deconfigure(void);
89 extern int _sd_recovery_wait(void);
90 extern int _sd_recovery_wblk_wait(int cd);
91 extern void _sd_mirror_iodone(void);
92 extern int _sd_repin_cd(int);
93 extern void _sd_remote_disable(int);
94 extern void r_sd_ifs_cache_enable(ncall_t *, int *);
95 extern void r_sd_ifs_cache_disable(ncall_t *, int *);
96 extern void _sd_hash_invalidate_cd(int);
97 extern void r_cd_discard(ncall_t *, int *);
98 extern int _sd_uncommit(_sd_buf_handle_t *, nsc_off_t, nsc_size_t, int);
99 extern int _sd_uncommit_refresh(_sd_cctl_t *, int);
100 extern void r_sd_uncommit_refresh(ncall_t *, int *);
101 extern int _sd_wait_for_flush(int);
102 extern int _sdbc_warm_start(void);
103 extern void _sdbc_set_warm_start(void);
104 
105 #endif /* _KERNEL */
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif /* _SD_FT_H */
112