Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / vol / vol-salvage.h
blob44d2ce27a81f8959875d815656f55a3f74962959
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
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 */
11 * Module: vol-salvage.h
14 #ifndef __vol_salvage_h_
15 #define __vol_salvage_h_
17 #define SalvageVersion "2.4"
19 #include "salvage.h"
20 #include "volinodes.h"
22 /* salvager data structures */
23 struct InodeSummary { /* Inode summary file--an entry for each
24 * volume in the inode file for a partition */
25 VolId volumeId; /* Volume id */
26 VolId 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 */
49 #define readOnly(isp) ((isp)->volumeId != (isp)->RWvolumeId)
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? */
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;
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;
114 struct SalvInfo;
116 #define ORPH_IGNORE 0
117 #define ORPH_REMOVE 1
118 #define ORPH_ATTACH 2
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;
136 #ifndef AFS_NT40_ENV
137 extern int useSyslog; /* -syslog flag */
138 extern int useSyslogFacility; /* -syslogfacility option */
139 #endif
141 #define MAXPARALLEL 32
143 extern int OKToZap; /* -o flag */
144 extern int ForceSalvage; /* If salvage should occur despite the DONT_SALVAGE flag
145 * in the volume header */
148 #define ROOTINODE 2 /* Root inode of a 4.2 Unix file system
149 * partition */
153 extern char * tmpdir;
154 extern FILE *logFile; /* one of {/usr/afs/logs,/vice/file}/SalvageLog */
157 #ifdef AFS_NT40_ENV
158 /* For NT, we can fork the per partition salvagers to gain the required
159 * safety against Aborts. But there's too many complex data structures at
160 * the per volume salvager layer to easilty copy the data across.
161 * childJobNumber is resset from -1 to the job number if this is a
162 * per partition child of the main salvager. This information is passed
163 * out-of-band in the extra data area setup for the now unused parent/child
164 * data transfer.
166 #define SALVAGER_MAGIC 0x00BBaaDD
167 #define NOT_CHILD -1 /* job numbers start at 0 */
168 /* If new options need to be passed to child, add them here. */
169 typedef struct {
170 int cj_magic;
171 int cj_number;
172 char cj_part[32];
173 } childJob_t;
175 /* Child job this process is running. */
176 extern childJob_t myjob;
178 extern int nt_SalvagePartition(char *partName, int jobn);
179 extern int nt_SetupPartitionSalvage(void *datap, int len);
181 typedef struct {
182 struct InodeSummary *svgp_inodeSummaryp;
183 int svgp_count;
184 struct SalvInfo *svgp_salvinfo;
185 } SVGParms_t;
186 #endif /* AFS_NT40_ENV */
188 extern int canfork;
191 /* prototypes */
192 extern void Exit(int code) AFS_NORETURN;
193 extern int Fork(void);
194 extern int Wait(char *prog);
195 extern char *ToString(const char *s);
196 extern int AskDAFS(void);
197 extern void AskOffline(struct SalvInfo *salvinfo, VolumeId volumeId);
198 extern void AskOnline(struct SalvInfo *salvinfo, VolumeId volumeId);
199 extern void AskDelete(struct SalvInfo *salvinfo, VolumeId volumeId);
200 extern void CheckLogFile(char * log_path);
201 #ifndef AFS_NT40_ENV
202 extern void TimeStampLogFile(char * log_path);
203 #endif
204 extern void ClearROInUseBit(struct VolumeSummary *summary);
205 extern void CopyAndSalvage(struct SalvInfo *salvinfo, struct DirSummary *dir);
206 extern int CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume);
207 extern void CopyOnWrite(struct SalvInfo *salvinfo, struct DirSummary *dir);
208 extern void CountVolumeInodes(register struct ViceInodeInfo *ip, int maxInodes,
209 register struct InodeSummary *summary);
210 extern void DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo,
211 struct VolumeSummary *vsp);
212 extern void DistilVnodeEssence(struct SalvInfo *salvinfo, VolumeId vid,
213 VnodeClass class, Inode ino, Unique * maxu);
214 extern int GetInodeSummary(struct SalvInfo *salvinfo, FILE *inodeFile,
215 VolumeId singleVolumeNumber);
216 extern int GetVolumeSummary(struct SalvInfo *salvinfo,
217 VolumeId singleVolumeNumber);
218 extern int JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber,
219 afs_int32 unique);
220 extern void MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
221 char *message, int deleteMe, int check);
222 extern void ObtainSalvageLock(void);
223 extern void ObtainSharedSalvageLock(void);
224 extern void PrintInodeList(struct SalvInfo *salvinfo);
225 extern void PrintInodeSummary(struct SalvInfo *salvinfo);
226 extern int QuickCheck(struct SalvInfo *salvinfo, struct InodeSummary *isp,
227 int nVols);
228 extern void RemoveTheForce(char *path);
229 extern void SalvageDir(struct SalvInfo *salvinfo, char *name, VolumeId rwVid,
230 struct VnodeInfo *dirVnodeInfo, IHandle_t * alinkH,
231 int i, struct DirSummary *rootdir, int *rootdirfound);
232 extern void SalvageFileSysParallel(struct DiskPartition64 *partP);
233 extern void SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber);
234 extern void SalvageFileSys1(struct DiskPartition64 *partP,
235 VolumeId singleVolumeNumber);
236 extern int SalvageHeader(struct SalvInfo *salvinfo, struct afs_inode_info *sp,
237 struct InodeSummary *isp, int check, int *deleteMe);
238 extern int SalvageIndex(struct SalvInfo *salvinfo, Inode ino, VnodeClass class,
239 int RW, struct ViceInodeInfo *ip, int nInodes,
240 struct VolumeSummary *volSummary, int check);
241 extern int SalvageVnodes(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
242 struct InodeSummary *thisIsp,
243 struct ViceInodeInfo *inodes, int check);
244 extern int SalvageVolume(struct SalvInfo *salvinfo, struct InodeSummary *rwIsp,
245 IHandle_t * alinkH);
246 extern void DoSalvageVolumeGroup(struct SalvInfo *salvinfo,
247 struct InodeSummary *isp, int nVols);
248 #ifdef AFS_NT40_ENV
249 extern void SalvageVolumeGroup(struct SalvInfo *salvinfo, struct InodeSummary *isp, int nVols);
250 #else
251 #define SalvageVolumeGroup DoSalvageVolumeGroup
252 #endif
253 extern int SalvageVolumeHeaderFile(struct SalvInfo *salvinfo,
254 struct InodeSummary *isp,
255 struct ViceInodeInfo *inodes, int RW,
256 int check, int *deleteMe);
257 extern void showlog(void);
258 extern int UseTheForceLuke(char *path);
262 #endif /* __vol_salvage_h_ */