Coda Distributed File System
vol-salvage.private.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2021 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19#define readOnly(vsp) \
20 ((vsp)->header.type == ROVOL || (vsp)->header.type == BACKVOL)
21
22#include <rec_dlist.h>
23#include <bitmap.h>
24#include <recov_vollog.h>
25
26struct InodeSummary { /* Inode summary file: an entry for each volume in a partition */
27 VolumeId volumeId; /* Volume id */
28 VolumeId RWvolumeId; /* RW volume associated */
29 int index; /* index into inode file (0, 1, 2 ...) */
30 int nInodes; /* Number of inodes for this volume */
31 Unique_t
32 maxUniquifier; /* The max. uniquifier in all the inodes for this volume */
33};
34
35struct VolumeSummary { /* one entry for each volume */
36 char *fileName; /* File name on the partition for the volume header */
37 int volindex; /* volume's index in recoverable storage */
38 struct VolumeHeader header; /* volume number, rw volume number */
39 byte wouldNeedCallback; /* set if the file server should issue
40 call backs for all the files in this volume when
41 the volume goes back on line */
42 struct InodeSummary *inSummary; /* this volume's inodes */
43 recov_vol_log *vollog; // log storage for volume
44 bitmap *logbm; // bitmap for checking if volume log has no leaks
45};
46
48 short count; /* Number of references to vnode; MUST BE SIGNED */
49 unsigned claimed : 1; /* Set when a parent directory containing an entry
50 referencing this vnode is found. The claim
51 is that the parent in "parent" can point to
52 this vnode, and no other */
53 unsigned changed : 1; /* Set if any parameters (other than the count)
54 in the vnode change. It is determined if the
55 link count has changed by noting whether it is
56 0 after scanning all directories */
57 unsigned short
58 blockCount; /* Number of blocks (1K) used by this vnode, approximately */
59 VnodeId vparent; /* parent's id */
60 Unique_t uparent; /* uniquifier of parent */
61 Unique_t unique; /* own uniquifier; Must match entry! */
62 VnodeId vid; /* own vnode number */
63 rec_dlist *log; // for directories only
64};
65
66struct VnodeInfo {
67 int nVnodes; /* Total number of vnodes in index */
68 int nAllocatedVnodes; /* Total number actually used */
69 int volumeBlockCount; /* Total number of blocks used by volume */
70 PDirInode *dirnodes; /* Directory only */
72};
73
74struct DirSummary {
76 VnodeId vnodeNumber;
77 Unique_t unique;
79 VolumeId Vid;
80 int copied; /* If the copy-on-write stuff has been applied */
81 VnodeId vparent;
82 Unique_t uparent;
83};
84
85/* routines that get summaries */
86static int GetInodeSummary(char *fspath, char *path,
87 VolumeId singleVolumeNumber);
88static int GetVolumeSummary(VolumeId singleVolumeNumber) EXCLUDES_TRANSACTION;
89
90/* the checking routines */
91static int SalvageFileSys(char *path,
92 VolumeId singleVolumeNumber) EXCLUDES_TRANSACTION;
93static int SalvageVolumeGroup(struct VolumeSummary *vsp,
94 int nVols) REQUIRES_TRANSACTION;
95static int QuickCheck(struct VolumeSummary *vsp,
96 int nVols) REQUIRES_TRANSACTION;
97static int SalvageVolHead(struct VolumeSummary *vsp) REQUIRES_TRANSACTION;
98static int VnodeInodeCheck(int, struct ViceInodeInfo *, int,
101static void SanityCheckFreeLists() EXCLUDES_TRANSACTION;
102
103/* correcting/action routines */
104static void CleanInodes(struct InodeSummary *);
105static void ClearROInUseBit(struct VolumeSummary *summary) REQUIRES_TRANSACTION;
106static void FixInodeLinkcount(struct ViceInodeInfo *, struct InodeSummary *);
107static int DestroyBadVolumes() EXCLUDES_TRANSACTION;
108
109/* misc routines */
110int OnlyOneVolume(struct ViceInodeInfo *, VolumeId);
111int InSkipVolumeList(VolumeId, VolumeId *, int);
112static struct VnodeEssence *CheckVnodeNumber(VnodeId vnodeNumber, Unique_t);
113static int AskOffline(VolumeId volumeId) EXCLUDES_TRANSACTION;
114static int AskOnline(VolumeId volumeId) EXCLUDES_TRANSACTION;
115static void release_locks(int);
116static void GetSkipVolumeNumbers();
117static void zero_globals();
Definition: bitmap.h:52
Definition: rec_dlist.h:49
Definition: recov_vollog.h:47
#define REQUIRES_TRANSACTION
Definition: coda_tsa.h:107
#define EXCLUDES_TRANSACTION
Definition: coda_tsa.h:108
void path(char *pathname, char *direc, char *file)
Definition: path.c:53
Definition: dhcache.c:38
Definition: codadir.h:173
Definition: vol-salvage.private.h:74
int copied
Definition: vol-salvage.private.h:80
VolumeId Vid
Definition: vol-salvage.private.h:79
PDCEntry dirCache
Definition: vol-salvage.private.h:75
VnodeId vparent
Definition: vol-salvage.private.h:81
unsigned haveDot
Definition: vol-salvage.private.h:78
Unique_t unique
Definition: vol-salvage.private.h:77
Unique_t uparent
Definition: vol-salvage.private.h:82
VnodeId vnodeNumber
Definition: vol-salvage.private.h:76
unsigned haveDotDot
Definition: vol-salvage.private.h:78
Definition: vol-salvage.private.h:26
Unique_t maxUniquifier
Definition: vol-salvage.private.h:32
VolumeId volumeId
Definition: vol-salvage.private.h:27
VolumeId RWvolumeId
Definition: vol-salvage.private.h:28
int nInodes
Definition: vol-salvage.private.h:30
int index
Definition: vol-salvage.private.h:29
Definition: viceinode.h:59
Definition: vol-salvage.private.h:47
VnodeId vid
Definition: vol-salvage.private.h:62
rec_dlist * log
Definition: vol-salvage.private.h:63
unsigned changed
Definition: vol-salvage.private.h:53
Unique_t uparent
Definition: vol-salvage.private.h:60
Unique_t unique
Definition: vol-salvage.private.h:61
short count
Definition: vol-salvage.private.h:48
unsigned claimed
Definition: vol-salvage.private.h:49
VnodeId vparent
Definition: vol-salvage.private.h:59
unsigned short blockCount
Definition: vol-salvage.private.h:58
Definition: vol-salvage.private.h:66
int volumeBlockCount
Definition: vol-salvage.private.h:69
int nVnodes
Definition: vol-salvage.private.h:67
struct VnodeEssence * vnodes
Definition: vol-salvage.private.h:71
PDirInode * dirnodes
Definition: vol-salvage.private.h:70
int nAllocatedVnodes
Definition: vol-salvage.private.h:68
Definition: volume.h:92
Definition: vol-salvage.private.h:35
byte wouldNeedCallback
Definition: vol-salvage.private.h:39
char * fileName
Definition: vol-salvage.private.h:36
recov_vol_log * vollog
Definition: vol-salvage.private.h:43
struct InodeSummary * inSummary
Definition: vol-salvage.private.h:42
int volindex
Definition: vol-salvage.private.h:37
struct VolumeHeader header
Definition: vol-salvage.private.h:38
bitmap * logbm
Definition: vol-salvage.private.h:44
int DirCompletenessCheck(struct VolumeSummary *vsp)
Definition: vol-salvage.cc:954
int OnlyOneVolume(struct ViceInodeInfo *, VolumeId)
Definition: vol-salvage.cc:1443
int InSkipVolumeList(VolumeId, VolumeId *, int)
Definition: vol-salvage.cc:1256