dafs-updates-20080612
[openafs.git] / src / vol / fssync.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  *
9  * Portions Copyright (c) 2006-2008 Sine Nomine Associates
10  */
11
12 /*
13         System:         VICE-TWO
14         Module:         fssync.h
15         Institution:    The Information Technology Center, Carnegie-Mellon University
16
17  */
18
19 #ifndef __fssync_h_
20 #define __fssync_h_
21
22
23 #define FSYNC_PROTO_VERSION     3
24
25
26 /**
27  * FSYNC command codes.
28  */
29 enum FSYNCOpCode {
30     FSYNC_VOL_ON              = SYNC_COM_CODE_DECL(0),  /**< bring Volume online */
31     FSYNC_VOL_OFF             = SYNC_COM_CODE_DECL(1),  /**< take Volume offline */
32     FSYNC_VOL_LISTVOLUMES     = SYNC_COM_CODE_DECL(2),  /**< Update local volume list */
33     FSYNC_VOL_NEEDVOLUME      = SYNC_COM_CODE_DECL(3),  /**< Put volume in whatever mode (offline, or whatever)
34                                                          *   best fits the attachment mode provided in reason */
35     FSYNC_VOL_MOVE            = SYNC_COM_CODE_DECL(4),  /**< Generate temporary relocation information
36                                                          *   for this volume to another site, to be used
37                                                          *   if this volume disappears */
38     FSYNC_VOL_BREAKCBKS       = SYNC_COM_CODE_DECL(5),  /**< Break all the callbacks on this volume */
39     FSYNC_VOL_DONE            = SYNC_COM_CODE_DECL(6),  /**< Done with this volume (used after a delete).
40                                                          *   Don't put online, but remove from list */
41     FSYNC_VOL_QUERY           = SYNC_COM_CODE_DECL(7),  /**< query the volume state */
42     FSYNC_VOL_QUERY_HDR       = SYNC_COM_CODE_DECL(8),  /**< query the volume disk data structure */
43     FSYNC_VOL_QUERY_VOP       = SYNC_COM_CODE_DECL(9),  /**< query the volume for pending vol op info */
44     FSYNC_VOL_STATS_GENERAL   = SYNC_COM_CODE_DECL(10), /**< query the general volume package statistics */
45     FSYNC_VOL_STATS_VICEP     = SYNC_COM_CODE_DECL(11), /**< query the per-partition volume package stats */
46     FSYNC_VOL_STATS_HASH      = SYNC_COM_CODE_DECL(12), /**< query the per hash-chain volume package stats */
47     FSYNC_VOL_STATS_HDR       = SYNC_COM_CODE_DECL(13), /**< query the volume header cache statistics */
48     FSYNC_VOL_STATS_VLRU      = SYNC_COM_CODE_DECL(14), /**< query the VLRU statistics */
49     FSYNC_VOL_ATTACH          = SYNC_COM_CODE_DECL(15), /**< Force volume online */
50     FSYNC_VOL_FORCE_ERROR     = SYNC_COM_CODE_DECL(16), /**< force volume into error state */
51     FSYNC_VOL_LEAVE_OFF       = SYNC_COM_CODE_DECL(17), /**< end vol op, but leave volume offline */
52     FSYNC_VOL_QUERY_VNODE     = SYNC_COM_CODE_DECL(18), /**< query vnode state */
53     FSYNC_OP_CODE_END
54 };
55
56 /**
57  * FSYNC reason codes. 
58  */
59 enum FSYNCReasonCode {
60     FSYNC_WHATEVER            = SYNC_REASON_CODE_DECL(0), /**< XXXX */
61     FSYNC_SALVAGE             = SYNC_REASON_CODE_DECL(1), /**< volume is being salvaged */
62     FSYNC_MOVE                = SYNC_REASON_CODE_DECL(2), /**< volume is being moved */
63     FSYNC_OPERATOR            = SYNC_REASON_CODE_DECL(3), /**< operator forced volume offline */
64     FSYNC_EXCLUSIVE           = SYNC_REASON_CODE_DECL(4), /**< somebody else has the volume offline */
65     FSYNC_UNKNOWN_VOLID       = SYNC_REASON_CODE_DECL(5), /**< volume id not known by fileserver */
66     FSYNC_HDR_NOT_ATTACHED    = SYNC_REASON_CODE_DECL(6), /**< volume header not currently attached */
67     FSYNC_NO_PENDING_VOL_OP   = SYNC_REASON_CODE_DECL(7), /**< no volume operation pending */
68     FSYNC_VOL_PKG_ERROR       = SYNC_REASON_CODE_DECL(8), /**< error in the volume package */
69     FSYNC_UNKNOWN_VNID        = SYNC_REASON_CODE_DECL(9), /**< vnode id not known by fileserver */
70     FSYNC_WRONG_PART          = SYNC_REASON_CODE_DECL(10),/**< volume attached on different partition */
71     FSYNC_BAD_STATE           = SYNC_REASON_CODE_DECL(11),/**< current volume state does not allow this operation */
72     FSYNC_REASON_CODE_END
73 };
74
75 /* FSYNC response codes */
76
77 /* FSYNC flag codes */
78
79 struct offlineInfo {
80     afs_uint32 volumeID;
81     char partName[16];
82 };
83
84 /**
85  * fssync protocol volume operation request message.
86  */
87 typedef struct FSSYNC_VolOp_hdr {
88     afs_uint32 volume;          /**< volume id associated with request */
89     char partName[16];          /**< partition name, e.g. /vicepa */
90 } FSSYNC_VolOp_hdr;
91
92 typedef struct FSSYNC_VolOp_command {
93     SYNC_command_hdr * hdr;
94     FSSYNC_VolOp_hdr * vop;
95     SYNC_command * com;
96     struct offlineInfo * v;
97     struct offlineInfo * volumes;
98 } FSSYNC_VolOp_command;
99
100 /**
101  * volume operation information node.
102  *
103  * @note this structure is attached to a struct Volume to signify that
104  *       a volume operation is in-progress.
105  *
106  * @see Volume
107  * @see VRegisterVolOp_r
108  * @see VDeregisterVolOp_r
109  */
110 typedef struct FSSYNC_VolOp_info {
111     SYNC_command_hdr com;
112     FSSYNC_VolOp_hdr vop;
113 } FSSYNC_VolOp_info;
114
115
116 /**
117  * fssync protocol volume package statistics request node.
118  */
119 typedef struct FSSYNC_StatsOp_hdr {
120     union {
121         afs_uint32 vlru_generation;     /**< vlru generation id */
122         afs_uint32 hash_bucket;         /**< volume hash bucket */
123         char partName[16];              /**< partition name */
124     } args;
125 } FSSYNC_StatsOp_hdr;
126
127 typedef struct FSSYNC_StatsOp_command {
128     SYNC_command_hdr * hdr;
129     FSSYNC_StatsOp_hdr * sop;
130     SYNC_command * com;
131 } FSSYNC_StatsOp_command;
132
133 /**
134  * fssync protocol vnode query request message.
135  */
136 typedef struct FSSYNC_VnQry_hdr {
137     afs_uint32 volume;          /**< volume id */
138     afs_uint32 vnode;           /**< vnode id */
139     afs_uint32 unique;          /**< uniqifier */
140     afs_uint32 spare;           /**< reserved for future use */
141     char partName[16];          /**< partition name */
142 } FSSYNC_VnQry_hdr;
143
144
145 #define FSSYNC_IN_PORT 2040
146 #define FSSYNC_UN_PATH "fssync.sock"
147 #define FSSYNC_ENDPOINT_DECL    SYNC_ENDPOINT_DECL(FSSYNC_IN_PORT, FSSYNC_UN_PATH)
148
149 /*
150  * common interfaces
151  */
152 extern void FSYNC_Init(void);
153
154 /* 
155  * fsync client interfaces 
156  */
157 extern void FSYNC_clientFinis(void);
158 extern int FSYNC_clientInit(void);
159 extern int FSYNC_clientChildProcReconnect(void);
160
161 /* generic low-level interface */
162 extern afs_int32 FSYNC_askfs(SYNC_command * com, SYNC_response * res);
163
164 /* generic higher-level interface */
165 extern afs_int32 FSYNC_GenericOp(void * ext_hdr, size_t ext_len,
166                                  int command, int reason,
167                                  SYNC_response * res);
168
169 /* volume operations interface */
170 extern afs_int32 FSYNC_VolOp(VolumeId volume, char *partName, int com, int reason, 
171                              SYNC_response * res);
172
173 /* statistics query interface */
174 extern afs_int32 FSYNC_StatsOp(FSSYNC_StatsOp_hdr * scom, int command, int reason,
175                                SYNC_response * res_in);
176
177 #endif /* __fssync_h_ */