Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / vol / vol-salvage.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 /*
11 * Module: vol-salvage.h
12 */
13
14 #ifndef __vol_salvage_h_
15 #define __vol_salvage_h_
16
17 #define SalvageVersion "2.4"
18
19 #include "salvage.h"
20 #include "volinodes.h"
21
22 /* salvager data structures */
23 struct InodeSummary { /* Inode summary file--an entry for each
24 * volume in the inode file for a partition */
25 VolumeId volumeId; /* Volume id */
26 VolumeId RWvolumeId; /* RW volume associated */
27 int index; /* index into inode file (0, 1, 2 ...) */
28 int nInodes; /* Number of inodes for this volume */
29 int nSpecialInodes; /* Number of special inodes, i.e. volume
30 * header, index, etc. These are all
31 * marked (viceinode.h) and will all be sorted
32 * to the beginning of the information for
33 * this volume. Read-only volumes should
34 * ONLY have special inodes (all the other
35 * inodes look as if they belong to the
36 * original RW volume). */
37 Unique maxUniquifier; /* The maximum uniquifier found in all the inodes.
38 * This is only useful for RW volumes and is used
39 * to compute a new volume uniquifier in the event
40 * that the header needs to be recreated. The inode
41 * uniquifier may be a truncated version of vnode
42 * uniquifier (AFS_3DISPARES). The real maxUniquifer
43 * is from the vnodes and later calcuated from it */
44 struct VolumeSummary *volSummary;
45 /* Either a pointer to the original volume
46 * header summary, or constructed summary
47 * information */
48 };
49 #define readOnly(isp) ((isp)->volumeId != (isp)->RWvolumeId)
50
51 struct VolumeSummary { /* Volume summary an entry for each
52 * volume in a volume directory.
53 * Assumption: one volume directory per
54 * partition */
55 struct VolumeHeader header;
56 /* volume number, rw volume number, inode
57 * numbers of each major component of
58 * the volume */
59 IHandle_t *volumeInfoHandle;
60 char deleted; /* did we delete this volume? */
61 byte wouldNeedCallback; /* set if the file server should issue
62 * call backs for all the files in this volume when
63 * the volume goes back on line */
64 byte unused; /* is this volume 'extra'? i.e. not referenced
65 * by anything? */
66 };
67
68 struct VnodeInfo {
69 IHandle_t *handle; /* Inode containing this index */
70 afs_sfsize_t nVnodes; /* Total number of vnodes in index */
71 afs_sfsize_t nAllocatedVnodes; /* Total number actually used */
72 int volumeBlockCount; /* Total number of blocks used by volume */
73 Inode *inodes; /* Directory only */
74 struct VnodeEssence {
75 short count; /* Number of references to vnode; MUST BE SIGNED */
76 unsigned claimed:1; /* Set when a parent directory containing an entry
77 * referencing this vnode is found. The claim
78 * is that the parent in "parent" can point to
79 * this vnode, and no other */
80 unsigned changed:1; /* Set if any parameters (other than the count)
81 * in the vnode change. It is determined if the
82 * link count has changed by noting whether it is
83 * 0 after scanning all directories */
84 unsigned salvaged:1; /* Set if this directory vnode has already been salvaged. */
85 unsigned todelete:1; /* Set if this vnode is to be deleted (should not be claimed) */
86 afs_fsize_t blockCount;
87 /* Number of blocks (1K) used by this vnode,
88 * approximately */
89 VnodeId parent; /* parent in vnode */
90 Unique unique; /* Must match entry! */
91 char *name; /* Name of directory entry */
92 int modeBits; /* File mode bits */
93 Inode InodeNumber; /* file's inode */
94 int type; /* File type */
95 int author; /* File author */
96 int owner; /* File owner */
97 int group; /* File group */
98 } *vnodes;
99 };
100
101 struct DirSummary {
102 struct DirHandle dirHandle;
103 VnodeId vnodeNumber;
104 Unique unique;
105 unsigned haveDot, haveDotDot;
106 VolumeId rwVid;
107 int copied; /* If the copy-on-write stuff has been applied */
108 VnodeId parent;
109 char *name;
110 char *vname;
111 IHandle_t *ds_linkH;
112 };
113
114 struct SalvInfo;
115
116 #define ORPH_IGNORE 0
117 #define ORPH_REMOVE 1
118 #define ORPH_ATTACH 2
119
120
121 /* command line options */
122 extern int debug; /* -d flag */
123 extern int Testing; /* -n flag */
124 extern int ListInodeOption; /* -i flag */
125 extern int ShowRootFiles; /* -r flag */
126 extern int RebuildDirs; /* -sal flag */
127 extern int Parallel; /* -para X flag */
128 extern int PartsPerDisk; /* Salvage up to 8 partitions on same disk sequentially */
129 extern int forceR; /* -b flag */
130 extern int ShowLog; /* -showlog flag */
131 extern int ShowSuid; /* -showsuid flag */
132 extern int ShowMounts; /* -showmounts flag */
133 extern int orphans; /* -orphans option */
134 extern int Showmode;
135
136 #define MAXPARALLEL 32
137
138 extern int OKToZap; /* -o flag */
139 extern int ForceSalvage; /* If salvage should occur despite the DONT_SALVAGE flag
140 * in the volume header */
141
142
143 #define ROOTINODE 2 /* Root inode of a 4.2 Unix file system
144 * partition */
145
146
147
148 extern char * tmpdir;
149
150
151 #ifdef AFS_NT40_ENV
152 /* For NT, we can fork the per partition salvagers to gain the required
153 * safety against Aborts. But there's too many complex data structures at
154 * the per volume salvager layer to easilty copy the data across.
155 * childJobNumber is resset from -1 to the job number if this is a
156 * per partition child of the main salvager. This information is passed
157 * out-of-band in the extra data area setup for the now unused parent/child
158 * data transfer.
159 */
160 #define SALVAGER_MAGIC 0x00BBaaDD
161 #define NOT_CHILD -1 /* job numbers start at 0 */
162 /* If new options need to be passed to child, add them here. */
163 typedef struct {
164 int cj_magic;
165 int cj_number;
166 char cj_part[32];
167 } childJob_t;
168
169 /* Child job this process is running. */
170 extern childJob_t myjob;
171
172 extern int nt_SalvagePartition(char *partName, int jobn);
173 extern int nt_SetupPartitionSalvage(void *datap, int len);
174
175 typedef struct {
176 struct InodeSummary *svgp_inodeSummaryp;
177 int svgp_count;
178 struct SalvInfo *svgp_salvinfo;
179 } SVGParms_t;
180 #endif /* AFS_NT40_ENV */
181
182 extern int canfork;
183
184
185 /* prototypes */
186 extern void Exit(int code) AFS_NORETURN;
187 extern int Fork(void);
188 extern int Wait(char *prog);
189 extern char *ToString(const char *s);
190 extern int AskDAFS(void);
191 extern void AskOffline(struct SalvInfo *salvinfo, VolumeId volumeId);
192 extern void AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId);
193 extern void AskDelete(struct SalvInfo *salvinfo, VolumeId volumeId);
194 extern void CheckLogFile(char * log_path);
195 extern void ClearROInUseBit(struct VolumeSummary *summary);
196 extern void CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir);
197 extern int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume);
198 extern void CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir);
199 extern void CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes,
200 register struct InodeSummary *summary);
201 extern void DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo,
202 struct VolumeSummary *vsp);
203 extern void DistilVnodeEssence(struct SalvInfo *salvinfo, VolumeId vid,
204 VnodeClass class, Inode ino, Unique * maxu);
205 extern int GetInodeSummary(struct SalvInfo *salvinfo, FD_t inodeFile,
206 VolumeId singleVolumeNumber);
207 extern int GetVolumeSummary(struct SalvInfo *salvinfo,
208 VolumeId singleVolumeNumber);
209 extern int JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
210 afs_int32 unique);
211 extern void MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
212 char *message, int deleteMe, int check);
213 extern void ObtainSalvageLock(void);
214 extern void ObtainSharedSalvageLock(void);
215 extern void PrintInodeList(struct SalvInfo *salvinfo);
216 extern void PrintInodeSummary(struct SalvInfo *salvinfo);
217 extern int QuickCheck(struct SalvInfo *salvinfo, struct InodeSummary *isp,
218 int nVols);
219 extern void RemoveTheForce(char *path);
220 extern void SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
221 struct VnodeInfo *dirVnodeInfo, IHandle_t * alinkH,
222 int i, struct DirSummary *rootdir, int *rootdirfound);
223 extern void SalvageFileSysParallel(struct DiskPartition64 *partP);
224 extern void SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber);
225 extern void SalvageFileSys1(struct DiskPartition64 *partP,
226 VolumeId singleVolumeNumber);
227 extern int SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
228 struct InodeSummary *isp, int check, int *deleteMe);
229 extern int SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class,
230 int RW, struct ViceInodeInfo *ip, int nInodes,
231 struct VolumeSummary *volSummary, int check);
232 extern int SalvageVnodes(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
233 struct InodeSummary *thisIsp,
234 struct ViceInodeInfo *inodes, int check);
235 extern int SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
236 IHandle_t * alinkH);
237 extern void DoSalvageVolumeGroup(struct SalvInfo *salvinfo,
238 struct InodeSummary *isp, int nVols);
239 #ifdef AFS_NT40_ENV
240 extern void nt_SalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nVols);
241 #endif
242 extern int SalvageVolumeHeaderFile(struct SalvInfo *salvinfo,
243 struct InodeSummary *isp,
244 struct ViceInodeInfo *inodes, int RW,
245 int check, int *deleteMe);
246 extern int UseTheForceLuke(char *path);
247
248
249
250 #endif /* __vol_salvage_h_ */