fix-indent-bug-with-lock-macros-part-two-20040818

Add trailing semicolons to _LOCK and _UNLOCK macros and re-indent.
This should've been in fix-indent-bug-with-lock-macros-20030729
but somehow it slipped by and I've only found it now.
This commit is contained in:
Nickolai Zeldovich 2004-08-19 01:22:38 +00:00
parent 9a39ae21fe
commit 788ca86bdc
15 changed files with 387 additions and 257 deletions

View File

@ -403,8 +403,10 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
void
CloneVolume(Error * error, Volume * original, Volume * new, Volume * old)
{
VOL_LOCK CloneVolume_r(error, original, new, old);
VOL_UNLOCK}
VOL_LOCK;
CloneVolume_r(error, original, new, old);
VOL_UNLOCK;
}
void
CloneVolume_r(Error * rerror, Volume * original, Volume * new, Volume * old)

View File

@ -105,7 +105,7 @@ int (*V_BreakVolumeCallbacks) ();
#define MAXHANDLERS 4 /* Up to 4 clients; must be at least 2, so that
* move = dump+restore can run on single server */
#define MAXOFFLINEVOLUMES 128 /* This needs to be as big as the maximum
#define MAXOFFLINEVOLUMES 128 /* This needs to be as big as the maximum
* number that would be offline for 1 operation.
* Current winner is salvage, which needs all
* cloned read-only copies offline when salvaging
@ -214,7 +214,7 @@ FSYNC_askfs(VolumeId volume, char *partName, int com, int reason)
else
command.partName[0] = 0;
assert(FS_sd != -1);
VFSYNC_LOCK
VFSYNC_LOCK;
#ifdef AFS_NT40_ENV
if (send(FS_sd, (char *)&command, sizeof(command), 0) != sizeof(command)) {
printf("FSYNC_askfs: write to file server failed\n");
@ -247,9 +247,8 @@ FSYNC_askfs(VolumeId volume, char *partName, int com, int reason)
("FSYNC_askfs: negative response from file server; volume %u, command %d\n",
command.volume, (int)command.command);
}
done:
VFSYNC_UNLOCK
done:
VFSYNC_UNLOCK;
return response;
}
@ -406,7 +405,9 @@ FSYNC_com(int fd)
FSYNC_Drop(fd);
return;
}
VATTACH_LOCK VOL_LOCK volumes = OfflineVolumes[FindHandler(fd)];
VATTACH_LOCK;
VOL_LOCK;
volumes = OfflineVolumes[FindHandler(fd)];
for (v = 0, i = 0; i < MAXOFFLINEVOLUMES; i++) {
if (volumes[i].volumeID == command.volume
&& strcmp(volumes[i].partName, command.partName) == 0) {
@ -568,28 +569,35 @@ defect #2080 for details.
if (V_BreakVolumeCallbacks) {
Log("fssync: volume %u moved to %x; breaking all call backs\n",
command.volume, command.reason);
VOL_UNLOCK VATTACH_UNLOCK(*V_BreakVolumeCallbacks) (command.
volume);
VATTACH_LOCK VOL_LOCK}
VOL_UNLOCK;
VATTACH_UNLOCK;
(*V_BreakVolumeCallbacks) (command.volume);
VATTACH_LOCK;
VOL_LOCK;
}
break;
case FSYNC_RESTOREVOLUME:
/* if the volume is being restored, break all callbacks on it */
if (V_BreakVolumeCallbacks) {
Log("fssync: volume %u restored; breaking all call backs\n",
command.volume);
VOL_UNLOCK VATTACH_UNLOCK(*V_BreakVolumeCallbacks) (command.
volume);
VATTACH_LOCK VOL_LOCK}
VOL_UNLOCK;
VATTACH_UNLOCK;
(*V_BreakVolumeCallbacks) (command.volume);
VATTACH_LOCK;
VOL_LOCK;
}
break;
default:
rc = FSYNC_DENIED;
break;
}
VOL_UNLOCK VATTACH_UNLOCK
VOL_UNLOCK;
VATTACH_UNLOCK;
#ifdef AFS_NT40_ENV
(void) send(fd, &rc, 1, 0);
(void)send(fd, &rc, 1, 0);
#else
(void) write(fd, &rc, 1);
(void)write(fd, &rc, 1);
#endif
}
@ -601,7 +609,9 @@ FSYNC_Drop(int fd)
Error error;
char tvolName[VMAXPATHLEN];
VATTACH_LOCK VOL_LOCK p = OfflineVolumes[FindHandler(fd)];
VATTACH_LOCK;
VOL_LOCK;
p = OfflineVolumes[FindHandler(fd)];
for (i = 0; i < MAXOFFLINEVOLUMES; i++) {
if (p[i].volumeID) {
Volume *vp;
@ -615,7 +625,9 @@ FSYNC_Drop(int fd)
p[i].volumeID = 0;
}
}
VOL_UNLOCK VATTACH_UNLOCK RemoveHandler(fd);
VOL_UNLOCK;
VATTACH_UNLOCK;
RemoveHandler(fd);
#ifdef AFS_NT40_ENV
closesocket(fd);
#else

View File

@ -85,97 +85,97 @@ static fstabscan __P((void));
static
fstabscan()
{
if(_fs_count <= 0)
return(0);
_fs_fstab.fs_spec = _fs_ptr->f_mntfromname;
_fs_fstab.fs_file = _fs_ptr->f_mntonname;
_fs_fstab.fs_vfstype = _fs_ptr->f_fstypename;
_fs_fstab.fs_mntops = _fs_ptr->f_fstypename; // no mount options given
_fs_fstab.fs_type = (_fs_ptr->f_flags & MNT_RDONLY) ? FSTAB_RO : FSTAB_RW;
_fs_fstab.fs_freq = 0;
_fs_fstab.fs_passno = 0;
if (_fs_count <= 0)
return (0);
_fs_fstab.fs_spec = _fs_ptr->f_mntfromname;
_fs_fstab.fs_file = _fs_ptr->f_mntonname;
_fs_fstab.fs_vfstype = _fs_ptr->f_fstypename;
_fs_fstab.fs_mntops = _fs_ptr->f_fstypename; // no mount options given
_fs_fstab.fs_type = (_fs_ptr->f_flags & MNT_RDONLY) ? FSTAB_RO : FSTAB_RW;
_fs_fstab.fs_freq = 0;
_fs_fstab.fs_passno = 0;
_fs_ptr++;
_fs_count--;
return(1);
_fs_ptr++;
_fs_count--;
return (1);
}
struct fstab *
getfsent()
{
if (!_fs_buf && !setfsent() || !fstabscan())
return((struct fstab *)NULL);
return(&_fs_fstab);
if (!_fs_buf && !setfsent() || !fstabscan())
return ((struct fstab *)NULL);
return (&_fs_fstab);
}
struct fstab *
getfsspec(name)
register const char *name;
register const char *name;
{
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_spec, name))
return(&_fs_fstab);
return((struct fstab *)NULL);
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_spec, name))
return (&_fs_fstab);
return ((struct fstab *)NULL);
}
struct fstab *
getfsfile(name)
register const char *name;
register const char *name;
{
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_file, name))
return(&_fs_fstab);
return((struct fstab *)NULL);
if (setfsent())
while (fstabscan())
if (!strcmp(_fs_fstab.fs_file, name))
return (&_fs_fstab);
return ((struct fstab *)NULL);
}
setfsent()
{
long bufsize;
long bufsize;
if (_fs_buf) {
free(_fs_buf);
_fs_buf = NULL;
}
if((_fs_count = getfsstat(NULL, 0, MNT_WAIT)) < 0) {
error(errno);
return(0);
}
bufsize = (long)_fs_count * sizeof(struct statfs);
if((_fs_buf = malloc(bufsize)) == NULL) {
error(errno);
return(0);
}
if(getfsstat(_fs_buf, bufsize, MNT_WAIT) < 0) {
error(errno);
return(0);
}
_fs_ptr = _fs_buf;
return(1);
if (_fs_buf) {
free(_fs_buf);
_fs_buf = NULL;
}
if ((_fs_count = getfsstat(NULL, 0, MNT_WAIT)) < 0) {
error(errno);
return (0);
}
bufsize = (long)_fs_count *sizeof(struct statfs);
if ((_fs_buf = malloc(bufsize)) == NULL) {
error(errno);
return (0);
}
if (getfsstat(_fs_buf, bufsize, MNT_WAIT) < 0) {
error(errno);
return (0);
}
_fs_ptr = _fs_buf;
return (1);
}
void
endfsent()
{
if (_fs_buf) {
free(_fs_buf);
_fs_buf = NULL;
}
_fs_count = 0;
if (_fs_buf) {
free(_fs_buf);
_fs_buf = NULL;
}
_fs_count = 0;
}
static
error(err)
int err;
int err;
{
char *p;
char *p;
(void)write(STDERR_FILENO, "fstab: ", 7);
(void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
(void)write(STDERR_FILENO, ": ", 1);
p = strerror(err);
(void)write(STDERR_FILENO, p, strlen(p));
(void)write(STDERR_FILENO, "\n", 1);
(void)write(STDERR_FILENO, "fstab: ", 7);
(void)write(STDERR_FILENO, _PATH_FSTAB, sizeof(_PATH_FSTAB) - 1);
(void)write(STDERR_FILENO, ": ", 1);
p = strerror(err);
(void)write(STDERR_FILENO, p, strlen(p));
(void)write(STDERR_FILENO, "\n", 1);
}
#endif /* defined(AFS_DARWIN_ENV) */

View File

@ -297,7 +297,7 @@ ih_open(IHandle_t * ihP)
DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev);
ihP->ih_refcnt++;
IH_UNLOCK;
(void) FDH_SEEK(fdP, 0, SEEK_SET);
(void)FDH_SEEK(fdP, 0, SEEK_SET);
return fdP;
}
}

View File

@ -76,9 +76,9 @@ extern pthread_mutex_t ih_glock_mutex;
extern void ih_glock_init(void);
#define IH_LOCK \
assert(pthread_once(&ih_glock_once, ih_glock_init) == 0 && \
pthread_mutex_lock(&ih_glock_mutex) == 0);
pthread_mutex_lock(&ih_glock_mutex) == 0)
#define IH_UNLOCK \
assert(pthread_mutex_unlock(&ih_glock_mutex) == 0);
assert(pthread_mutex_unlock(&ih_glock_mutex) == 0)
#else /* AFS_PTHREAD_ENV */
#define IH_LOCK
#define IH_UNLOCK

View File

@ -696,14 +696,14 @@ namei_dec(IHandle_t * ih, Inode ino, int p1)
if (count == 0) {
IHandle_t *th;
IH_INIT(th, ih->ih_dev, ih->ih_vid, ino);
#if 0
#if 0
/* This triggers in the fileserver on the volume index vnodes */
if (th->ih_refcnt > 1)
Log("Warning: Leaked ref on ihandle dev %d vid %d ino %lld\n",
if (th->ih_refcnt > 1)
Log("Warning: Leaked ref on ihandle dev %d vid %d ino %lld\n",
th->ih_dev, th->ih_vid, (int64_t) th->ih_ino);
#endif
namei_HandleToName(&name, th);
IH_RELEASE(th);
namei_HandleToName(&name, th);
IH_RELEASE(th);
code = unlink(name.n_path);
}
FDH_CLOSE(fdP);

View File

@ -144,12 +144,12 @@ nuke(char *aname, afs_int32 avolid)
*lastDevComp = toupper(*lastDevComp);
#else
{
char *tfile = vol_DevName(tstat.st_dev, wpath);
if (!tfile) {
printf("volnuke: can't find %s's device.\n", aname);
return 1;
}
strcpy(devName, tfile); /* save this from the static buffer */
char *tfile = vol_DevName(tstat.st_dev, wpath);
if (!tfile) {
printf("volnuke: can't find %s's device.\n", aname);
return 1;
}
strcpy(devName, tfile); /* save this from the static buffer */
}
/* aim lastDevComp at the 'foo' of '/dev/foo' */
lastDevComp = strrchr(devName, '/');
@ -201,12 +201,12 @@ nuke(char *aname, afs_int32 avolid)
}
#else /* AFS_NAMEI_ENV */
IH_INIT(fileH, (int)tstat.st_dev, avolid, ti->inode[i]);
{
int j;
for (j = 0; j < ti->count[i]; j++) {
code = IH_DEC(fileH, ti->inode[i], avolid);
}
}
{
int j;
for (j = 0; j < ti->count[i]; j++) {
code = IH_DEC(fileH, ti->inode[i], avolid);
}
}
IH_RELEASE(fileH);
#endif /* AFS_NAMEI_ENV */
}

View File

@ -273,8 +273,10 @@ VInitPartition_r(char *path, char *devname, Device dev)
static void
VInitPartition(char *path, char *devname, Device dev)
{
VOL_LOCK VInitPartition_r(path, devname, dev);
VOL_UNLOCK}
VOL_LOCK;
VInitPartition_r(path, devname, dev);
VOL_UNLOCK;
}
#ifndef AFS_NT40_ENV
/* VAttachPartitions() finds the vice partitions on this server. Calls
@ -836,8 +838,10 @@ struct DiskPartition *
VGetPartition(char *name, int abortp)
{
struct DiskPartition *retVal;
VOL_LOCK retVal = VGetPartition_r(name, abortp);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VGetPartition_r(name, abortp);
VOL_UNLOCK;
return retVal;
}
#ifdef AFS_NT40_ENV
@ -933,8 +937,10 @@ VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
void
VSetPartitionDiskUsage(register struct DiskPartition *dp)
{
VOL_LOCK VSetPartitionDiskUsage_r(dp);
VOL_UNLOCK}
VOL_LOCK;
VSetPartitionDiskUsage_r(dp);
VOL_UNLOCK;
}
void
VResetDiskUsage_r(void)
@ -951,8 +957,10 @@ VResetDiskUsage_r(void)
void
VResetDiskUsage(void)
{
VOL_LOCK VResetDiskUsage_r();
VOL_UNLOCK}
VOL_LOCK;
VResetDiskUsage_r();
VOL_UNLOCK;
}
void
VAdjustDiskUsage_r(Error * ec, Volume * vp, afs_sfsize_t blocks,
@ -988,8 +996,10 @@ void
VAdjustDiskUsage(Error * ec, Volume * vp, afs_sfsize_t blocks,
afs_sfsize_t checkBlocks)
{
VOL_LOCK VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
VOL_UNLOCK}
VOL_LOCK;
VAdjustDiskUsage_r(ec, vp, blocks, checkBlocks);
VOL_UNLOCK;
}
int
VDiskUsage_r(Volume * vp, afs_sfsize_t blocks)
@ -1015,8 +1025,10 @@ int
VDiskUsage(Volume * vp, afs_sfsize_t blocks)
{
int retVal;
VOL_LOCK retVal = VDiskUsage_r(vp, blocks);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VDiskUsage_r(vp, blocks);
VOL_UNLOCK;
return retVal;
}
void
@ -1036,8 +1048,10 @@ VPrintDiskStats_r(void)
void
VPrintDiskStats(void)
{
VOL_LOCK VPrintDiskStats_r();
VOL_UNLOCK}
VOL_LOCK;
VPrintDiskStats_r();
VOL_UNLOCK;
}
#ifdef AFS_NT40_ENV
/* Need a separate lock file on NT, since NT only has mandatory file locks. */
@ -1208,11 +1222,15 @@ VUnlockPartition_r(char *name)
void
VLockPartition(char *name)
{
VOL_LOCK VLockPartition_r(name);
VOL_UNLOCK}
VOL_LOCK;
VLockPartition_r(name);
VOL_UNLOCK;
}
void
VUnlockPartition(char *name)
{
VOL_LOCK VUnlockPartition_r(name);
VOL_UNLOCK}
VOL_LOCK;
VUnlockPartition_r(name);
VOL_UNLOCK;
}

View File

@ -84,8 +84,10 @@ VPurgeVolume_r(Error * ec, Volume * vp)
void
VPurgeVolume(Error * ec, Volume * vp)
{
VOL_LOCK VPurgeVolume_r(ec, vp);
VOL_UNLOCK}
VOL_LOCK;
VPurgeVolume_r(ec, vp);
VOL_UNLOCK;
}
#define MAXOBLITATONCE 200
/* delete a portion of an index, adjusting offset appropriately. Returns 0 if
@ -162,8 +164,10 @@ ObliterateRegion(Volume * avp, VnodeClass aclass, StreamHandle_t * afile,
void
PurgeIndex(Volume * vp, VnodeClass class)
{
VOL_LOCK PurgeIndex_r(vp, class);
VOL_UNLOCK}
VOL_LOCK;
PurgeIndex_r(vp, class);
VOL_UNLOCK;
}
void
PurgeIndex_r(Volume * vp, VnodeClass class)
@ -198,8 +202,10 @@ PurgeIndex_r(Volume * vp, VnodeClass class)
void
PurgeHeader(Volume * vp)
{
VOL_LOCK PurgeHeader_r(vp);
VOL_UNLOCK}
VOL_LOCK;
PurgeHeader_r(vp);
VOL_UNLOCK;
}
void
PurgeHeader_r(Volume * vp)

View File

@ -266,8 +266,10 @@ Vnode *
VAllocVnode(Error * ec, Volume * vp, VnodeType type)
{
Vnode *retVal;
VOL_LOCK retVal = VAllocVnode_r(ec, vp, type);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VAllocVnode_r(ec, vp, type);
VOL_UNLOCK;
return retVal;
}
Vnode *
@ -344,8 +346,10 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type)
ObtainWriteLock(&vnp->lock);
} else {
/* follow locking hierarchy */
VOL_UNLOCK ObtainWriteLock(&vnp->lock);
VOL_LOCK}
VOL_UNLOCK;
ObtainWriteLock(&vnp->lock);
VOL_LOCK;
}
#ifdef AFS_PTHREAD_ENV
vnp->writer = pthread_self();
#else /* AFS_PTHREAD_ENV */
@ -381,7 +385,8 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type)
FdHandle_t *fdP;
off_t off = vnodeIndexOffset(vcp, vnodeNumber);
VOL_UNLOCK fdP = IH_OPEN(ihP);
VOL_UNLOCK;
fdP = IH_OPEN(ihP);
if (fdP == NULL)
Abort("VAllocVnode: can't open index file!\n");
if ((size = FDH_SIZE(fdP)) < 0)
@ -403,7 +408,8 @@ VAllocVnode_r(Error * ec, Volume * vp, VnodeType type)
free(buf);
}
FDH_CLOSE(fdP);
VOL_LOCK}
VOL_LOCK;
}
VNLog(4, 2, vnodeNumber, (afs_int32) vnp);
}
@ -429,8 +435,10 @@ Vnode *
VGetVnode(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
{ /* READ_LOCK or WRITE_LOCK, as defined in lock.h */
Vnode *retVal;
VOL_LOCK retVal = VGetVnode_r(ec, vp, vnodeNumber, locktype);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VGetVnode_r(ec, vp, vnodeNumber, locktype);
VOL_UNLOCK;
return retVal;
}
Vnode *
@ -520,7 +528,8 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
#endif /* AFS_PTHREAD_ENV */
/* Read vnode from volume index */
VOL_UNLOCK fdP = IH_OPEN(ihP);
VOL_UNLOCK;
fdP = IH_OPEN(ihP);
if (fdP == NULL) {
Log("VGetVnode: can't open index dev=%u, i=%s\n", vp->device,
PrintInode(NULL, vp->vnodeIndex[class].handle->ih_ino));
@ -537,7 +546,8 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
/* Don't take volume off line if the inumber is out of range
* or the inode table is full. */
FDH_REALLYCLOSE(fdP);
VOL_LOCK if (n == BAD_IGET) {
VOL_LOCK;
if (n == BAD_IGET) {
Log("VGetVnode: bad inumber %s\n",
PrintInode(NULL, vp->vnodeIndex[class].handle->ih_ino));
*ec = VIO;
@ -561,9 +571,9 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
return NULL;
}
FDH_CLOSE(fdP);
VOL_LOCK
/* Quick check to see that the data is reasonable */
if (vnp->disk.vnodeMagic != vcp->magic || vnp->disk.type == vNull) {
VOL_LOCK;
/* Quick check to see that the data is reasonable */
if (vnp->disk.vnodeMagic != vcp->magic || vnp->disk.type == vNull) {
if (vnp->disk.type == vNull) {
*ec = VNOVNODE;
mlkReason = 6;
@ -613,7 +623,8 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
vnp->lruNext->lruPrev = vnp->lruPrev;
}
}
VOL_UNLOCK if (locktype == READ_LOCK)
VOL_UNLOCK;
if (locktype == READ_LOCK)
ObtainReadLock(&vnp->lock);
else {
ObtainWriteLock(&vnp->lock);
@ -623,10 +634,10 @@ VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
LWP_CurrentProcess(&vnp->writer);
#endif /* AFS_PTHREAD_ENV */
}
VOL_LOCK
/* Check that the vnode hasn't been removed while we were obtaining
* the lock */
VNLog(102, 2, vnodeNumber, (afs_int32) vnp);
VOL_LOCK;
/* Check that the vnode hasn't been removed while we were obtaining
* the lock */
VNLog(102, 2, vnodeNumber, (afs_int32) vnp);
if ((vnp->disk.type == vNull) || (vnp->cacheCheck == 0)) {
if (vnp->nUsers-- == 1)
StickOnLruChain_r(vnp, vcp);
@ -652,8 +663,10 @@ int TrustVnodeCacheEntry = 1;
void
VPutVnode(Error * ec, register Vnode * vnp)
{
VOL_LOCK VPutVnode_r(ec, vnp);
VOL_UNLOCK}
VOL_LOCK;
VPutVnode_r(ec, vnp);
VOL_UNLOCK;
}
void
VPutVnode_r(Error * ec, register Vnode * vnp)
@ -709,7 +722,8 @@ VPutVnode_r(Error * ec, register Vnode * vnp)
} else {
IHandle_t *ihP = vp->vnodeIndex[class].handle;
FdHandle_t *fdP;
VOL_UNLOCK fdP = IH_OPEN(ihP);
VOL_UNLOCK;
fdP = IH_OPEN(ihP);
if (fdP == NULL)
Abort("VPutVnode: can't open index file!\n");
offset = vnodeIndexOffset(vcp, vnp->vnodeNumber);
@ -723,7 +737,8 @@ VPutVnode_r(Error * ec, register Vnode * vnp)
/* Don't force volume offline if the inumber is out of
* range or the inode table is full.
*/
VOL_LOCK if (code == BAD_IGET) {
VOL_LOCK;
if (code == BAD_IGET) {
Log("VPutVnode: bad inumber %s\n",
PrintInode(NULL,
vp->vnodeIndex[class].handle->ih_ino));
@ -733,17 +748,18 @@ VPutVnode_r(Error * ec, register Vnode * vnp)
VForceOffline_r(vp);
*ec = VSALVAGE;
}
VOL_UNLOCK FDH_REALLYCLOSE(fdP);
VOL_UNLOCK;
FDH_REALLYCLOSE(fdP);
} else {
FDH_CLOSE(fdP);
}
VOL_LOCK
/* If the vnode is to be deleted, and we wrote the vnode out,
* free its bitmap entry. Do after the vnode is written so we
* don't allocate from bitmap before the vnode is written
* (doing so could cause a "addled bitmap" message).
*/
if (vnp->delete && !*ec) {
VOL_LOCK;
/* If the vnode is to be deleted, and we wrote the vnode out,
* free its bitmap entry. Do after the vnode is written so we
* don't allocate from bitmap before the vnode is written
* (doing so could cause a "addled bitmap" message).
*/
if (vnp->delete && !*ec) {
VFreeBitMapEntry_r(ec, &vp->vnodeIndex[class],
vnodeIdToBitNumber(vnp->vnodeNumber));
}
@ -779,8 +795,10 @@ int
VVnodeWriteToRead(Error * ec, register Vnode * vnp)
{
int retVal;
VOL_LOCK retVal = VVnodeWriteToRead_r(ec, vnp);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VVnodeWriteToRead_r(ec, vnp);
VOL_UNLOCK;
return retVal;
}
int
@ -818,7 +836,8 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp)
changed_oldTime) << 1) | vnp->
delete);
if (thisProcess != vnp->writer)
Abort("VPutVnode: Vnode at 0x%x locked by another process!\n", (int)vnp);
Abort("VPutVnode: Vnode at 0x%x locked by another process!\n",
(int)vnp);
if (vnp->delete) {
return 0;
}
@ -839,7 +858,8 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp)
IHandle_t *ihP = vp->vnodeIndex[class].handle;
FdHandle_t *fdP;
off_t off = vnodeIndexOffset(vcp, vnp->vnodeNumber);
VOL_UNLOCK fdP = IH_OPEN(ihP);
VOL_UNLOCK;
fdP = IH_OPEN(ihP);
if (fdP == NULL)
Abort("VPutVnode: can't open index file!\n");
code = FDH_SEEK(fdP, off, SEEK_SET);
@ -851,18 +871,22 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp)
* Don't force volume offline if the inumber is out of
* range or the inode table is full.
*/
VOL_LOCK if (code == BAD_IGET) {
VOL_LOCK;
if (code == BAD_IGET) {
Log("VPutVnode: bad inumber %s\n",
PrintInode(NULL, vp->vnodeIndex[class].handle->ih_ino));
PrintInode(NULL,
vp->vnodeIndex[class].handle->ih_ino));
*ec = VIO;
} else {
Log("VPutVnode: Couldn't write vnode %u, volume %u (%s)\n", vnp->vnodeNumber, V_id(vnp->volumePtr), V_name(vnp->volumePtr));
VForceOffline_r(vp);
*ec = VSALVAGE;
}
VOL_UNLOCK}
VOL_UNLOCK;
}
FDH_CLOSE(fdP);
VOL_LOCK}
VOL_LOCK;
}
vcp->writes++;
vnp->changed_newTime = vnp->changed_oldTime = 0;
}

View File

@ -608,8 +608,9 @@ HandleVolume(struct DiskPartition *dp, char *name)
if (saveinodes)
printf
("Volume-Id\t Volsize Auxsize Inodesize AVolsize SizeDiff (VolName)\n");
printf("%u\t%9d%9d%10d%10d%9d\t%24s\n", V_id(vp), Vdiskused, Vauxsize_k,
Vvnodesize_k, totvolsize, totvolsize - Vdiskused, V_name(vp));
printf("%u\t%9d%9d%10d%10d%9d\t%24s\n", V_id(vp), Vdiskused,
Vauxsize_k, Vvnodesize_k, totvolsize, totvolsize - Vdiskused,
V_name(vp));
}
}

View File

@ -519,14 +519,14 @@ handleit(struct cmd_syndesc *as)
#ifdef FAST_RESTART
{
afs_int32 i;
for (i = 0; i < CMD_MAXPARMS; i++) {
if (as->parms[i].items) {
seenany = 1;
break;
afs_int32 i;
for (i = 0; i < CMD_MAXPARMS; i++) {
if (as->parms[i].items) {
seenany = 1;
break;
}
}
}
}
if (!seenany) {
char *msg =
"Exiting immediately without salvage. Look into the FileLog to find volumes which really need to be salvaged!";
@ -1602,7 +1602,7 @@ GetInodeSummary(char *path, VolumeId singleVolumeNumber)
GetVolumeSummary(singleVolumeNumber);
for (i = 0,vsp = volumeSummaryp; i < nVolumes; i++) {
for (i = 0, vsp = volumeSummaryp; i < nVolumes; i++) {
if (vsp->fileName)
DeleteExtraVolumeHeaderFile(vsp);
}
@ -3066,7 +3066,7 @@ JudgeEntry(struct DirSummary *dir, char *name, VnodeId vnodeNumber,
if (dirOrphaned) {
Log("dir vnode %u: %s/%s parent vnode is %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
} else if (vnodeNumber == 1) {
Log("dir vnode %d: %s/%s is invalid (vnode %d, unique %d) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing?"would have been ":""));
Log("dir vnode %d: %s/%s is invalid (vnode %d, unique %d) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "would have been " : ""));
} else {
Log("dir vnode %u: %s/%s already claimed by directory vnode %u (vnode %u, unique %u) -- %sdeleted\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeEssence->parent, vnodeNumber, unique, (Testing ? "would have been " : ""));
}

View File

@ -339,8 +339,10 @@ int
VConnectFS(void)
{
int retVal;
VOL_LOCK retVal = VConnectFS_r();
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VConnectFS_r();
VOL_UNLOCK;
return retVal;
}
int
@ -365,8 +367,10 @@ VDisconnectFS_r(void)
void
VDisconnectFS(void)
{
VOL_LOCK VDisconnectFS_r();
VOL_UNLOCK}
VOL_LOCK;
VDisconnectFS_r();
VOL_UNLOCK;
}
void
VShutdown_r(void)
@ -409,8 +413,10 @@ VShutdown_r(void)
void
VShutdown(void)
{
VOL_LOCK VShutdown_r();
VOL_UNLOCK}
VOL_LOCK;
VShutdown_r();
VOL_UNLOCK;
}
static void
@ -556,9 +562,12 @@ Volume *
VAttachVolumeByName(Error * ec, char *partition, char *name, int mode)
{
Volume *retVal;
VATTACH_LOCK VOL_LOCK retVal =
VAttachVolumeByName_r(ec, partition, name, mode);
VOL_UNLOCK VATTACH_UNLOCK return retVal;
VATTACH_LOCK;
VOL_LOCK;
retVal = VAttachVolumeByName_r(ec, partition, name, mode);
VOL_UNLOCK;
VATTACH_UNLOCK;
return retVal;
}
Volume *
@ -601,18 +610,20 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode)
strcpy(path, VPartitionPath(partp));
strcat(path, "/");
strcat(path, name);
VOL_UNLOCK if ((fd = afs_open(path, O_RDONLY)) == -1
|| afs_fstat(fd, &status) == -1) {
VOL_UNLOCK;
if ((fd = afs_open(path, O_RDONLY)) == -1 || afs_fstat(fd, &status) == -1) {
Log("VAttachVolume: Failed to open %s (errno %d)\n", path, errno);
if (fd > -1)
close(fd);
VOL_LOCK *ec = VNOVOL;
VOL_LOCK;
*ec = VNOVOL;
goto done;
}
n = read(fd, &diskHeader, sizeof(diskHeader));
close(fd);
VOL_LOCK if (n != sizeof(diskHeader)
|| diskHeader.stamp.magic != VOLUMEHEADERMAGIC) {
VOL_LOCK;
if (n != sizeof(diskHeader)
|| diskHeader.stamp.magic != VOLUMEHEADERMAGIC) {
Log("VAttachVolume: Error reading volume header %s\n", path);
*ec = VSALVAGE;
goto done;
@ -711,7 +722,8 @@ attach2(Error * ec, char *path, register struct VolumeHeader * header,
{
register Volume *vp;
VOL_UNLOCK vp = (Volume *) calloc(1, sizeof(Volume));
VOL_UNLOCK;
vp = (Volume *) calloc(1, sizeof(Volume));
assert(vp != NULL);
vp->specialStatus = (byte) (isbusy ? VBUSY : 0);
vp->device = partp->device;
@ -730,11 +742,13 @@ attach2(Error * ec, char *path, register struct VolumeHeader * header,
vp->shuttingDown = 0;
vp->goingOffline = 0;
vp->nUsers = 1;
VOL_LOCK GetVolumeHeader(vp);
VOL_UNLOCK(void) ReadHeader(ec, V_diskDataHandle(vp), (char *)&V_disk(vp),
sizeof(V_disk(vp)), VOLUMEINFOMAGIC,
VOLUMEINFOVERSION);
VOL_LOCK if (*ec) {
VOL_LOCK;
GetVolumeHeader(vp);
VOL_UNLOCK;
(void)ReadHeader(ec, V_diskDataHandle(vp), (char *)&V_disk(vp),
sizeof(V_disk(vp)), VOLUMEINFOMAGIC, VOLUMEINFOVERSION);
VOL_LOCK;
if (*ec) {
Log("VAttachVolume: Error reading diskDataHandle vol header %s; error=%u\n", path, *ec);
}
if (!*ec) {
@ -751,29 +765,34 @@ attach2(Error * ec, char *path, register struct VolumeHeader * header,
V_stat_initialized(vp) = 1;
}
#endif /* OPENAFS_VOL_STATS */
VOL_UNLOCK(void) ReadHeader(ec, vp->vnodeIndex[vSmall].handle,
(char *)&iHead, sizeof(iHead),
SMALLINDEXMAGIC, SMALLINDEXVERSION);
VOL_LOCK if (*ec) {
VOL_UNLOCK;
(void)ReadHeader(ec, vp->vnodeIndex[vSmall].handle,
(char *)&iHead, sizeof(iHead),
SMALLINDEXMAGIC, SMALLINDEXVERSION);
VOL_LOCK;
if (*ec) {
Log("VAttachVolume: Error reading smallVnode vol header %s; error=%u\n", path, *ec);
}
}
if (!*ec) {
struct IndexFileHeader iHead;
VOL_UNLOCK(void) ReadHeader(ec, vp->vnodeIndex[vLarge].handle,
(char *)&iHead, sizeof(iHead),
LARGEINDEXMAGIC, LARGEINDEXVERSION);
VOL_LOCK if (*ec) {
VOL_UNLOCK;
(void)ReadHeader(ec, vp->vnodeIndex[vLarge].handle,
(char *)&iHead, sizeof(iHead),
LARGEINDEXMAGIC, LARGEINDEXVERSION);
VOL_LOCK;
if (*ec) {
Log("VAttachVolume: Error reading largeVnode vol header %s; error=%u\n", path, *ec);
}
}
#ifdef AFS_NAMEI_ENV
if (!*ec) {
struct versionStamp stamp;
VOL_UNLOCK(void) ReadHeader(ec, V_linkHandle(vp), (char *)&stamp,
sizeof(stamp), LINKTABLEMAGIC,
LINKTABLEVERSION);
VOL_LOCK if (*ec) {
VOL_UNLOCK;
(void)ReadHeader(ec, V_linkHandle(vp), (char *)&stamp,
sizeof(stamp), LINKTABLEMAGIC, LINKTABLEVERSION);
VOL_LOCK;
if (*ec) {
Log("VAttachVolume: Error reading namei vol header %s; error=%u\n", path, *ec);
}
}
@ -819,8 +838,10 @@ attach2(Error * ec, char *path, register struct VolumeHeader * header,
if (programType == fileServer && VolumeWriteable(vp)) {
int i;
for (i = 0; i < nVNODECLASSES; i++) {
VOL_UNLOCK GetBitmap(ec, vp, i);
VOL_LOCK if (*ec) {
VOL_UNLOCK;
GetBitmap(ec, vp, i);
VOL_LOCK;
if (*ec) {
FreeVolume(vp);
Log("VAttachVolume: error getting bitmap for volume (%s)\n",
path);
@ -851,8 +872,12 @@ Volume *
VAttachVolume(Error * ec, VolumeId volumeId, int mode)
{
Volume *retVal;
VATTACH_LOCK VOL_LOCK retVal = VAttachVolume_r(ec, volumeId, mode);
VOL_UNLOCK VATTACH_UNLOCK return retVal;
VATTACH_LOCK;
VOL_LOCK;
retVal = VAttachVolume_r(ec, volumeId, mode);
VOL_UNLOCK;
VATTACH_UNLOCK;
return retVal;
}
Volume *
@ -901,8 +926,10 @@ static int
VHold(register Volume * vp)
{
int retVal;
VOL_LOCK retVal = VHold_r(vp);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VHold_r(vp);
VOL_UNLOCK;
return retVal;
}
void
@ -917,8 +944,10 @@ VTakeOffline_r(register Volume * vp)
void
VTakeOffline(register Volume * vp)
{
VOL_LOCK VTakeOffline_r(vp);
VOL_UNLOCK}
VOL_LOCK;
VTakeOffline_r(vp);
VOL_UNLOCK;
}
void
VPutVolume_r(register Volume * vp)
@ -962,8 +991,10 @@ VPutVolume_r(register Volume * vp)
void
VPutVolume(register Volume * vp)
{
VOL_LOCK VPutVolume_r(vp);
VOL_UNLOCK}
VOL_LOCK;
VPutVolume_r(vp);
VOL_UNLOCK;
}
/* Get a pointer to an attached volume. The pointer is returned regardless
of whether or not the volume is in service or on/off line. An error
@ -972,8 +1003,10 @@ Volume *
VGetVolume(Error * ec, VolId volumeId)
{
Volume *retVal;
VOL_LOCK retVal = VGetVolume_r(ec, volumeId);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VGetVolume_r(ec, volumeId);
VOL_UNLOCK;
return retVal;
}
Volume *
@ -1126,8 +1159,10 @@ VForceOffline_r(Volume * vp)
void
VForceOffline(Volume * vp)
{
VOL_LOCK VForceOffline_r(vp);
VOL_UNLOCK}
VOL_LOCK;
VForceOffline_r(vp);
VOL_UNLOCK;
}
/* The opposite of VAttachVolume. The volume header is written to disk, with
the inUse bit turned off. A copy of the header is maintained in memory,
@ -1156,8 +1191,10 @@ VOffline_r(Volume * vp, char *message)
void
VOffline(Volume * vp, char *message)
{
VOL_LOCK VOffline_r(vp, message);
VOL_UNLOCK}
VOL_LOCK;
VOffline_r(vp, message);
VOL_UNLOCK;
}
/* For VDetachVolume, we close all cached file descriptors, but keep
* the Inode handles in case we need to read from a busy volume.
@ -1237,8 +1274,10 @@ VDetachVolume_r(Error * ec, Volume * vp)
void
VDetachVolume(Error * ec, Volume * vp)
{
VOL_LOCK VDetachVolume_r(ec, vp);
VOL_UNLOCK}
VOL_LOCK;
VDetachVolume_r(ec, vp);
VOL_UNLOCK;
}
VnodeId
@ -1262,19 +1301,23 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, register struct vnodeIndex
* from AddNewReadableResidency */
wasVBUSY = 1;
} else {
VOL_UNLOCK while (vp->specialStatus == VBUSY)
VOL_UNLOCK;
while (vp->specialStatus == VBUSY)
#ifdef AFS_PTHREAD_ENV
sleep(2);
#else /* AFS_PTHREAD_ENV */
IOMGR_Sleep(2);
#endif /* AFS_PTHREAD_ENV */
VOL_LOCK}
VOL_LOCK;
}
}
if (!index->bitmap) {
vp->specialStatus = VBUSY; /* Stop anyone else from using it. */
for (i = 0; i < nVNODECLASSES; i++) {
VOL_UNLOCK GetBitmap(ec, vp, i);
VOL_LOCK if (*ec) {
VOL_UNLOCK;
GetBitmap(ec, vp, i);
VOL_LOCK;
if (*ec) {
vp->specialStatus = 0;
vp->shuttingDown = 1; /* Let who has it free it. */
return NULL;
@ -1316,8 +1359,10 @@ VnodeId
VAllocBitmapEntry(Error * ec, Volume * vp, register struct vnodeIndex * index)
{
VnodeId retVal;
VOL_LOCK retVal = VAllocBitmapEntry_r(ec, vp, index);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VAllocBitmapEntry_r(ec, vp, index);
VOL_UNLOCK;
return retVal;
}
void
@ -1344,8 +1389,10 @@ void
VFreeBitMapEntry(Error * ec, register struct vnodeIndex *index,
unsigned bitNumber)
{
VOL_LOCK VFreeBitMapEntry_r(ec, index, bitNumber);
VOL_UNLOCK}
VOL_LOCK;
VFreeBitMapEntry_r(ec, index, bitNumber);
VOL_UNLOCK;
}
void
VUpdateVolume_r(Error * ec, Volume * vp)
@ -1367,8 +1414,10 @@ VUpdateVolume_r(Error * ec, Volume * vp)
void
VUpdateVolume(Error * ec, Volume * vp)
{
VOL_LOCK VUpdateVolume_r(ec, vp);
VOL_UNLOCK}
VOL_LOCK;
VUpdateVolume_r(ec, vp);
VOL_UNLOCK;
}
void
VSyncVolume_r(Error * ec, Volume * vp)
@ -1388,8 +1437,10 @@ VSyncVolume_r(Error * ec, Volume * vp)
void
VSyncVolume(Error * ec, Volume * vp)
{
VOL_LOCK VSyncVolume_r(ec, vp);
VOL_UNLOCK}
VOL_LOCK;
VSyncVolume_r(ec, vp);
VOL_UNLOCK;
}
static void
FreeVolume(Volume * vp)
@ -1609,8 +1660,10 @@ int
VAdjustVolumeStatistics(register Volume * vp)
{
int retVal;
VOL_LOCK retVal = VAdjustVolumeStatistics_r(vp);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VAdjustVolumeStatistics_r(vp);
VOL_UNLOCK;
return retVal;
}
void
@ -1631,8 +1684,10 @@ VBumpVolumeUsage_r(register Volume * vp)
void
VBumpVolumeUsage(register Volume * vp)
{
VOL_LOCK VBumpVolumeUsage_r(vp);
VOL_UNLOCK}
VOL_LOCK;
VBumpVolumeUsage_r(vp);
VOL_UNLOCK;
}
void
VSetDiskUsage_r(void)
@ -1660,8 +1715,10 @@ VSetDiskUsage_r(void)
void
VSetDiskUsage(void)
{
VOL_LOCK VSetDiskUsage_r();
VOL_UNLOCK}
VOL_LOCK;
VSetDiskUsage_r();
VOL_UNLOCK;
}
/* The number of minutes that a volume hasn't been updated before the
* "Dont salvage" flag in the volume header will be turned on */
@ -1883,5 +1940,7 @@ VPrintCacheStats_r(void)
void
VPrintCacheStats(void)
{
VOL_LOCK VPrintCacheStats_r();
VOL_UNLOCK}
VOL_LOCK;
VPrintCacheStats_r();
VOL_UNLOCK;
}

View File

@ -35,21 +35,21 @@ extern pthread_mutex_t vol_trans_mutex;
extern pthread_cond_t vol_put_volume_cond;
extern pthread_cond_t vol_sleep_cond;
#define VATTACH_LOCK \
assert(pthread_mutex_lock(&vol_attach_mutex) == 0);
assert(pthread_mutex_lock(&vol_attach_mutex) == 0)
#define VATTACH_UNLOCK \
assert(pthread_mutex_unlock(&vol_attach_mutex) == 0);
assert(pthread_mutex_unlock(&vol_attach_mutex) == 0)
#define VOL_LOCK \
assert(pthread_mutex_lock(&vol_glock_mutex) == 0);
assert(pthread_mutex_lock(&vol_glock_mutex) == 0)
#define VOL_UNLOCK \
assert(pthread_mutex_unlock(&vol_glock_mutex) == 0);
assert(pthread_mutex_unlock(&vol_glock_mutex) == 0)
#define VFSYNC_LOCK \
assert(pthread_mutex_lock(&vol_fsync_mutex) == 0);
assert(pthread_mutex_lock(&vol_fsync_mutex) == 0)
#define VFSYNC_UNLOCK \
assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0);
assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0)
#define VTRANS_LOCK \
assert(pthread_mutex_lock(&vol_trans_mutex) == 0);
assert(pthread_mutex_lock(&vol_trans_mutex) == 0)
#define VTRANS_UNLOCK \
assert(pthread_mutex_unlock(&vol_trans_mutex) == 0);
assert(pthread_mutex_unlock(&vol_trans_mutex) == 0)
#else /* AFS_PTHREAD_ENV */
#define VATTACH_LOCK
#define VATTACH_UNLOCK

View File

@ -109,8 +109,10 @@ VCreateVolume(Error * ec, char *partname, VolId volumeId, VolId parentId)
{ /* Should be the same as volumeId if there is
* no parent */
Volume *retVal;
VOL_LOCK retVal = VCreateVolume_r(ec, partname, volumeId, parentId);
VOL_UNLOCK return retVal;
VOL_LOCK;
retVal = VCreateVolume_r(ec, partname, volumeId, parentId);
VOL_UNLOCK;
return retVal;
}
Volume *
@ -289,8 +291,10 @@ VCreateVolume_r(Error * ec, char *partname, VolId volumeId, VolId parentId)
void
AssignVolumeName(register VolumeDiskData * vol, char *name, char *ext)
{
VOL_LOCK AssignVolumeName_r(vol, name, ext);
VOL_UNLOCK}
VOL_LOCK;
AssignVolumeName_r(vol, name, ext);
VOL_UNLOCK;
}
void
AssignVolumeName_r(register VolumeDiskData * vol, char *name, char *ext)
@ -335,15 +339,19 @@ CopyVolumeHeader(VolumeDiskData * from, VolumeDiskData * to)
{
afs_int32 code;
VOL_LOCK code = CopyVolumeHeader_r(from, to);
VOL_UNLOCK return (code);
VOL_LOCK;
code = CopyVolumeHeader_r(from, to);
VOL_UNLOCK;
return (code);
}
void
ClearVolumeStats(register VolumeDiskData * vol)
{
VOL_LOCK ClearVolumeStats_r(vol);
VOL_UNLOCK}
VOL_LOCK;
ClearVolumeStats_r(vol);
VOL_UNLOCK;
}
void
ClearVolumeStats_r(register VolumeDiskData * vol)