#ifdef AFS_SUN5_ENV
#include <sys/fs/ufs_fs.h>
#else
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#include <ufs/ufs/dinode.h>
+#include <ufs/ffs/fs.h>
+#else
#include <ufs/fs.h>
#endif
+#endif
#else /* AFS_VFSINCL_ENV */
-#if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX20_ENV)
+#if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
#include <sys/fs.h>
#endif
#endif /* AFS_VFSINCL_ENV */
#if defined(AFS_SGI_ENV)
#include <fcntl.h>
#include <mntent.h>
-#ifndef AFS_SGI_XFS_IOPS_ENV
+#ifdef AFS_SGI_EFS_IOPS_ENV
#define ROOTINO EFS_ROOTINO
-#endif
-/*
#include <sys/fs/efs.h>
-*/
-#include "../sgiefs/efs.h" /* until 5.1 release */
+#include "../sgiefs/efs.h" /* until 5.1 release */
+#endif
+
#else
#ifndef AFS_LINUX20_ENV
if (vp->specialStatus == VBUSY)
isbusy = 1;
VDetachVolume_r(ec, vp);
+ if ( *ec ) {
+ Log("VAttachVolume: Error detaching volume (%s)\n", name);
+ }
}
}
if (!(partp = VGetPartition_r(partition, 0))) {
*ec = VNOVOL;
+ Log("VAttachVolume: Error getting partition (%s)\n", partition);
goto done;
}
if ((fd = open(path, O_RDONLY)) == -1 || fstat(fd,&status) == -1) {
close(fd);
VOL_LOCK
+ Log("VAttachVolume: Error opening/statting volume header file (%s)\n", path);
*ec = VNOVOL;
goto done;
}
#endif
VUpdateVolume_r(ec,vp);
if (*ec) {
+ Log("VAttachVolume: Error updating volume\n");
if (vp)
VPutVolume_r(vp);
goto done;
V_dontSalvage(vp) = DONT_SALVAGE;
VAddToVolumeUpdateList_r(ec,vp);
if (*ec) {
+ Log("VAttachVolume: Error adding volume to update list\n");
if (vp)
VPutVolume_r(vp);
goto done;
(char *)&V_disk(vp), sizeof(V_disk(vp)),
VOLUMEINFOMAGIC, VOLUMEINFOVERSION);
VOL_LOCK
+ if (*ec) {
+ Log("VAttachVolume: Error reading diskDataHandle vol header %s; error=%d\n",
+ path, *ec);
+ }
if (!*ec) {
struct IndexFileHeader iHead;
(char *)&iHead, sizeof(iHead),
SMALLINDEXMAGIC, SMALLINDEXVERSION);
VOL_LOCK
+ if (*ec) {
+ Log("VAttachVolume: Error reading smallVnode vol header %s; error=%d\n",
+ path, *ec);
+ }
}
if (!*ec) {
struct IndexFileHeader iHead;
(char *)&iHead, sizeof(iHead),
LARGEINDEXMAGIC, LARGEINDEXVERSION);
VOL_LOCK
+ if (*ec) {
+ Log("VAttachVolume: Error reading largeVnode vol header %s; error=%d\n",
+ path, *ec);
+ }
}
#ifdef AFS_NAMEI_ENV
if (!*ec) {
(char *)&stamp, sizeof(stamp),
LINKTABLEMAGIC, LINKTABLEVERSION);
VOL_LOCK
+ if (*ec) {
+ Log("VAttachVolume: Error reading namei vol header %s; error=%d\n",
+ path, *ec);
+ }
}
#endif
if (*ec) {
- Log("VAttachVolume: Error attaching volume %s; volume needs salvage\n",
- path);
+ Log("VAttachVolume: Error attaching volume %s; volume needs salvage; error=%d\n",
+ path, *ec);
FreeVolume(vp);
return NULL;
}
return NULL;
}
if (programType == fileServer) {
+#ifndef FAST_RESTART
if (V_inUse(vp) && VolumeWriteable(vp)) {
if (!V_needsSalvaged(vp)) {
V_needsSalvaged(vp) = 1;
*ec = VSALVAGE;
return NULL;
}
+#endif /* FAST_RESTART */
if (V_destroyMe(vp) == DESTROY_ME) {
FreeVolume(vp);
Log("VAttachVolume: volume %s is junk; it should be destroyed at next salvage\n", path);
AddVolumeToHashTable(vp, V_id(vp));
vp->nextVnodeUnique = V_uniquifier(vp);
vp->vnodeIndex[vSmall].bitmap = vp->vnodeIndex[vLarge].bitmap = NULL;
+#ifndef BITMAP_LATER
if (programType == fileServer && VolumeWriteable(vp)) {
int i;
for (i = 0; i<nVNODECLASSES; i++) {
VOL_LOCK
if (*ec) {
FreeVolume(vp);
+ Log("VAttachVolume: error getting bitmap for volume (%s)\n", path);
return NULL;
}
}
}
+#endif /* BITMAP_LATER */
if (programType == fileServer) {
if (vp->specialStatus) vp->specialStatus = 0;
*ec = VREADONLY;
return 0;
}
+#ifdef BITMAP_LATER
+ if ((programType == fileServer) && !index->bitmap) {
+ int i;
+ int wasVBUSY = 0;
+ if (vp->specialStatus == VBUSY) {
+ if (vp->goingOffline) { /* vos dump waiting for the volume to
+ go offline. We probably come here
+ from AddNewReadableResidency */
+ wasVBUSY = 1;
+ } else {
+ 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
+ }
+ }
+ 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) {
+ vp->specialStatus = 0;
+ vp->shuttingDown = 1; /* Let who has it free it. */
+ return NULL;
+ }
+ }
+ if (!wasVBUSY)
+ vp->specialStatus = 0; /* Allow others to have access. */
+ }
+ }
+#endif /* BITMAP_LATER */
bp = index->bitmap + index->bitmapOffset;
ep = index->bitmap + index->bitmapSize;
while (bp < ep) {
{
unsigned int offset;
*ec = 0;
+#ifdef BITMAP_LATER
+ if (!index->bitmap) return;
+#endif /* BITMAP_LATER */
offset = bitNumber>>3;
if (offset >= index->bitmapSize) {
*ec = VNOVNODE;
struct VnodeDiskObject *vnode;
unsigned int unique = 0;
FdHandle_t *fdP;
+#ifdef BITMAP_LATER
+ byte *BitMap = 0;
+#endif /* BITMAP_LATER */
*ec = 0;
the whole thing is rounded up to nearest 4
bytes, because the bit map allocator likes
it that way */
+#ifdef BITMAP_LATER
+ BitMap = (byte *) calloc(1, vip->bitmapSize);
+ assert(BitMap != NULL);
+#else /* BITMAP_LATER */
vip->bitmap = (byte *) calloc(1, vip->bitmapSize);
assert(vip->bitmap != NULL);
vip->bitmapOffset = 0;
+#endif /* BITMAP_LATER */
if (STREAM_SEEK(file,vcp->diskSize,0) != -1) {
int bitNumber = 0;
for (bitNumber = 0; bitNumber < nVnodes+100; bitNumber++) {
*ec = VSALVAGE;
break;
}
+#ifdef BITMAP_LATER
+ *(BitMap + (bitNumber>>3)) |= (1 << (bitNumber & 0x7));
+#else /* BITMAP_LATER */
*(vip->bitmap + (bitNumber>>3)) |= (1 << (bitNumber & 0x7));
+#endif /* BITMAP_LATER */
if (unique <= vnode->uniquifier)
unique = vnode->uniquifier + 1;
}
STREAM_CLOSE(file);
FDH_CLOSE(fdP);
free(vnode);
+#ifdef BITMAP_LATER
+ /* There may have been a racing condition with some other thread, both
+ * creating the bitmaps for this volume. If the other thread was faster
+ * the pointer to bitmap should already be filled and we can free ours.
+ */
+ if (vip->bitmap == NULL) {
+ vip->bitmap = BitMap;
+ vip->bitmapOffset = 0;
+ } else
+ free((byte *)BitMap);
+#endif /* BITMAP_LATER */
}
static void GetVolumePath(Error *ec, VolId volumeId, char **partitionp,