DARWIN: On macOS 12, mount afs on user's directory
[openafs.git] / src / WINNT / afsd / cm_volume.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
10 #ifndef OPENAFS_WINNT_AFSD_CM_VOLUME_H
11 #define OPENAFS_WINNT_AFSD_CM_VOLUME_H 1
12
13 #include <opr/jhash.h>
14
15 #define VL_MAXNAMELEN                   65
16
17 #define CM_VOLUME_MAGIC    ('V' | 'O' <<8 | 'L'<<16 | 'M'<<24)
18
19 /*
20  *
21  */
22
23 typedef struct cm_vol_state {
24     struct cm_volume *nextp;            /* volumeIDHashTable; by cm_volumeLock */
25     afs_uint32      ID;                 /* by rw */
26     struct cm_fid dotdotFid;            /* parent of volume root */
27     cm_serverRef_t *serversp;           /* by cm_serverLock */
28     enum volstatus  state;              /* by rw */
29     afs_uint32      flags;              /* by rw */
30     afs_uint32      qflags;             /* by cm_volumeLock */
31 } cm_vol_state_t;
32
33 /* RWVOL, ROVOL, BACKVOL are defined in cm.h */
34 #define NUM_VOL_TYPES 3
35
36 #define CM_VOL_STATE_FLAG_REPLICATED    1
37
38 typedef struct cm_volume {
39     osi_queue_t q;                      /* LRU queue; cm_volumeLock */
40     afs_uint32 qflags;                  /* by cm_volumeLock */
41     afs_uint32  magic;
42     struct cm_volume *allNextp;         /* allVolumes; by cm_volumeLock */
43     struct cm_volume *nameNextp;        /* volumeNameHashTable; by cm_volumeLock */
44     cm_cell_t *cellp;                   /* never changes */
45     char namep[VL_MAXNAMELEN];          /* name of the normal volume - assigned during allocation; */
46                                         /* by cm_volumeLock */
47     struct cm_vol_state vol[NUM_VOL_TYPES]; /* by cm_volumeLock */
48     osi_rwlock_t rw;
49     afs_uint32 flags;                   /* by rw */
50     afs_int32 refCount;                 /* by Interlocked operations */
51     struct cm_server *cbServerpRO;      /* server granting RO callback; by cm_scacheLock */
52     time_t cbExpiresRO;                 /* latest RO expiration time; by cm_scacheLock */
53     time_t cbIssuedRO;                  /* latest RO issue time; by cm_scacheLock */
54     time_t creationDateRO;              /* latest volume creation date; 0 if unknown; by cm_scacheLock */
55     time_t lastUpdateTime;              /* most recent volume location update cm_volumeLock */
56     afs_uint64 volumeSizeRO;            /* latest RO volume size */
57 } cm_volume_t;
58
59 #define CM_VOLUMEFLAG_RESET        1    /* reload this info on next use */
60 #define CM_VOLUMEFLAG_RO_MIXED     2
61 #define CM_VOLUMEFLAG_UPDATING_VL  8
62 #define CM_VOLUMEFLAG_DFS_VOLUME  16
63 #define CM_VOLUMEFLAG_NOEXIST     32
64 #define CM_VOLUMEFLAG_RO_SIZE_VALID 64
65
66 #define CM_VOLUME_QFLAG_IN_HASH      1
67 #define CM_VOLUME_QFLAG_IN_LRU_QUEUE 2
68
69 typedef struct cm_volumeRef {
70     struct cm_volumeRef * next;
71     afs_uint32  volID;
72 } cm_volumeRef_t;
73
74 extern void cm_InitVolume(int newFile, long maxVols);
75
76 extern long cm_FindVolumeByName(struct cm_cell *cellp, char *volNamep,
77                                struct cm_user *userp, struct cm_req *reqp,
78                                afs_uint32 flags, cm_volume_t **outVolpp);
79
80 extern long cm_FindVolumeByID(struct cm_cell *cellp, afs_uint32 volumeID,
81                              cm_user_t *userp, cm_req_t *reqp,
82                              afs_uint32 flags, cm_volume_t **outVolpp);
83
84 extern cm_volume_t *cm_FindVolumeByFID(cm_fid_t *fidp,
85                                        cm_user_t *userp, cm_req_t *reqp);
86
87 #define CM_GETVOL_FLAG_CREATE               1
88 #define CM_GETVOL_FLAG_NO_LRU_UPDATE        2
89 #define CM_GETVOL_FLAG_NO_RESET             4
90 #define CM_GETVOL_FLAG_IGNORE_LINKED_CELL   8
91
92 /* hash define.  Must not include the cell, since the callback revocation code
93  * doesn't necessarily know the cell in the case of a multihomed server
94  * contacting us from a mystery address.
95  */
96
97 #define CM_VOLUME_ID_HASH(volid) \
98     (opr_jhash_int((volid), 0) & (cm_data.volumeHashTableSize - 1))
99
100 #define CM_VOLUME_NAME_HASH(name)  (SDBMHash(name) % cm_data.volumeHashTableSize)
101
102 extern afs_uint32 SDBMHash(const char *);
103
104 extern void cm_GetVolume(cm_volume_t *volp);
105
106 extern cm_volume_t *cm_GetVolumeByFID(cm_fid_t *);
107
108 extern void cm_PutVolume(cm_volume_t *volp);
109
110 extern long cm_GetROVolumeID(cm_volume_t *volp);
111
112 extern LONG_PTR cm_ChecksumVolumeServerList(struct cm_fid *fidp,
113                                             cm_user_t *userp, cm_req_t *reqp);
114
115 extern long cm_ForceUpdateVolume(struct cm_fid *fidp, cm_user_t *userp,
116         cm_req_t *reqp);
117
118 extern cm_serverRef_t **cm_GetVolServers(cm_volume_t *volp, afs_uint32 volume,
119                                          cm_user_t *userp, cm_req_t *reqp, afs_uint32 *replicated);
120
121 extern void cm_ChangeRankVolume(cm_server_t *tsp);
122
123 extern void cm_RefreshVolumes(int lifetime);
124
125 extern long cm_ValidateVolume(void);
126
127 extern long cm_ShutdownVolume(void);
128
129 extern int cm_DumpVolumes(FILE *outputFile, char *cookie, int lock);
130
131 extern int cm_VolNameIsID(char *aname);
132
133 extern void cm_RemoveVolumeFromNameHashTable(cm_volume_t * volp);
134
135 extern void cm_RemoveVolumeFromIDHashTable(cm_volume_t * volp, afs_uint32 volType);
136
137 extern void cm_AddVolumeToNameHashTable(cm_volume_t * volp);
138
139 extern void cm_AddVolumeToIDHashTable(cm_volume_t * volp, afs_uint32 volType);
140
141 extern void cm_AdjustVolumeLRU(cm_volume_t *volp);
142
143 extern void cm_MoveVolumeToLRULast(cm_volume_t *volp);
144
145 extern void cm_RemoveVolumeFromLRU(cm_volume_t *volp);
146
147 extern void cm_CheckOfflineVolumes(void);
148
149 extern long cm_CheckOfflineVolume(cm_volume_t *volp, afs_uint32 volID);
150
151 extern void cm_CheckOfflineVolumeState(cm_volume_t *volp, cm_vol_state_t *statep,
152                                        afs_uint32 volID,  afs_uint32 *onlinep,
153                                        afs_uint32 *volumeUpdatedp);
154
155 extern void cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID);
156
157 extern void cm_VolumeStatusNotification(cm_volume_t * volp, afs_uint32 volID, enum volstatus oldState, enum volstatus newState);
158
159 extern enum volstatus cm_GetVolumeStatus(cm_volume_t *volp, afs_uint32 volID);
160
161 extern void cm_VolumeRenewROCallbacks(void);
162
163 extern cm_vol_state_t * cm_VolumeStateByType(cm_volume_t *volp, afs_uint32 type);
164
165 extern cm_vol_state_t * cm_VolumeStateByID(cm_volume_t *volp, afs_uint32 id);
166
167 extern cm_vol_state_t * cm_VolumeStateByName(cm_volume_t *volp, char *volname);
168
169 extern afs_int32 cm_VolumeType(cm_volume_t *volp, afs_uint32 id);
170
171 extern long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *reqp,
172                                     cm_volume_t *volp);
173
174 extern afs_int32 cm_IsVolumeReplicated(cm_fid_t *fidp);
175
176 extern osi_rwlock_t cm_volumeLock;
177 #endif /*  OPENAFS_WINNT_AFSD_CM_VOLUME_H */