#endif
#include <afs/opr.h>
+#ifdef AFS_PTHREAD_ENV
+#include <opr/lock.h>
+#endif
#include "rx/rx_queue.h"
#include <afs/afsint.h>
#include "nfs.h"
extern int LogLevel;
-
-
-
-#define BAD_IGET -1000
-
-/* There are two separate vnode queue types defined here:
- * Each hash conflict chain -- is singly linked, with a single head
- * pointer. New entries are added at the beginning. Old
- * entries are removed by linear search, which generally
- * only occurs after a disk read).
- * LRU chain -- is doubly linked, single head pointer.
- * Entries are added at the head, reclaimed from the tail,
- * or removed from anywhere in the queue.
- */
-
-
-/* Vnode hash table. Find hash chain by taking lower bits of
- * (volume_hash_offset + vnode).
- * This distributes the root inodes of the volumes over the
- * hash table entries and also distributes the vnodes of
- * volumes reasonably fairly. The volume_hash_offset field
- * for each volume is established as the volume comes on line
- * by using the VOLUME_HASH_OFFSET macro. This distributes the
- * volumes fairly among the cache entries, both when servicing
- * a small number of volumes and when servicing a large number.
- */
-
/* logging stuff for finding bugs */
#define THELOGSIZE 5120
static afs_int32 theLog[THELOGSIZE];
va_end(ap);
}
+
+
+
+/* Vnode hash table. Find hash chain by taking lower bits of
+ * (volume_hash_offset + vnode).
+ * This distributes the root inodes of the volumes over the
+ * hash table entries and also distributes the vnodes of
+ * volumes reasonably fairly. The volume_hash_offset field
+ * for each volume is established as the volume comes on line
+ * by using the VOLUME_HASH_OFFSET macro. This distributes the
+ * volumes fairly among the cache entries, both when servicing
+ * a small number of volumes and when servicing a large number.
+ */
+
/* VolumeHashOffset -- returns a new value to be stored in the
* volumeHashOffset of a Volume structure. Called when a
* volume is initialized. Sets the volumeHashOffset so that
((volumeptr->vnodeHashOffset + vnodenumber)&(VNODE_HASH_TABLE_SIZE-1))
+
+#define BAD_IGET -1000
+
+/* There are two separate vnode queue types defined here:
+ * Each hash conflict chain -- is singly linked, with a single head
+ * pointer. New entries are added at the beginning. Old
+ * entries are removed by linear search, which generally
+ * only occurs after a disk read).
+ * LRU chain -- is doubly linked, single head pointer.
+ * Entries are added at the head, reclaimed from the tail,
+ * or removed from anywhere in the queue.
+ */
+
/**
* add a vnode to the volume's vnode list.
*
*/
if (!in_vnode) {
+ int rollover = 0;
+
unique = vp->nextVnodeUnique++;
- if (!unique)
+ if (unique == 0) {
+ rollover = 1; /* nextVnodeUnique rolled over */
+ vp->nextVnodeUnique = 2; /* 1 is reserved for the root vnode */
unique = vp->nextVnodeUnique++;
+ }
- if (vp->nextVnodeUnique > V_uniquifier(vp)) {
+ if (vp->nextVnodeUnique > V_uniquifier(vp) || rollover) {
VUpdateVolume_r(ec, vp, 0);
if (*ec)
return NULL;
* this vnode number was free, so something is wrong. */
if (vnp->disk.type != vNull) {
Error tmp;
- Log("VAllocVnode: addled bitmap or vnode object! (vol %ld, "
- "vnode %p, number %ld, type %ld)\n", (long)vp->hashid, vnp,
+ Log("VAllocVnode: addled bitmap or vnode object! (vol %" AFS_VOLID_FMT ", "
+ "vnode %p, number %ld, type %ld)\n", afs_printable_VolumeId_lu(vp->hashid), vnp,
(long)Vn_id(vnp), (long)vnp->disk.type);
*ec = EIO;
VFreeBitMapEntry_r(&tmp, vp, &vp->vnodeIndex[class], bitNumber,
vnp->disk.uniquifier = unique;
vnp->handle = NULL;
vcp->allocs++;
- vp->header->diskstuff.filecount++;
+ V_filecount(vp)++;
#ifdef AFS_DEMAND_ATTACH_FS
VnChangeState_r(vnp, VN_STATE_EXCLUSIVE);
#endif
dosalv = 0;
} else if (nBytes == -1 && errno == EIO) {
/* disk error; salvage */
- Log("VnLoad: Couldn't read vnode %u, volume %u (%s); volume needs salvage\n", Vn_id(vnp), V_id(vp), V_name(vp));
+ Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); volume needs salvage\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
} else {
/* vnode is not allocated */
if (LogLevel >= 5)
- Log("VnLoad: Couldn't read vnode %u, volume %u (%s); read %d bytes, errno %d\n",
- Vn_id(vnp), V_id(vp), V_name(vp), (int)nBytes, errno);
- *ec = VIO;
+ Log("VnLoad: Couldn't read vnode %u, volume %" AFS_VOLID_FMT " (%s); read %d bytes, errno %d\n",
+ Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp), (int)nBytes, errno);
+ *ec = VNOVNODE;
dosalv = 0;
}
goto error_encountered_nolock;
if ((offset >= index->bitmapSize)
|| ((*(index->bitmap + offset) & (1 << (bitNumber & 0x7)))
== 0)) {
- Log("VnLoad: Request for unallocated vnode %u, volume %u (%s) denied.\n", Vn_id(vnp), V_id(vp), V_name(vp));
+ Log("VnLoad: Request for unallocated vnode %u, volume %" AFS_VOLID_FMT " (%s) denied.\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
*ec = VNOVNODE;
dosalv = 0;
} else {
- Log("VnLoad: Bad magic number, vnode %u, volume %u (%s); volume needs salvage\n", Vn_id(vnp), V_id(vp), V_name(vp));
+ Log("VnLoad: Bad magic number, vnode %u, volume %" AFS_VOLID_FMT " (%s); volume needs salvage\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
}
}
goto error_encountered;
}
- IH_INIT(vnp->handle, V_device(vp), V_parentId(vp), VN_GET_INO(vnp));
+ IH_INIT(vnp->handle, V_device(vp), afs_printable_VolumeId_lu(V_parentId(vp)), VN_GET_INO(vnp));
VnUnlock(vnp, WRITE_LOCK);
#ifdef AFS_DEMAND_ATTACH_FS
VnChangeState_r(vnp, VN_STATE_ONLINE);
VnChangeState_r(vnp, VN_STATE_ERROR);
#endif
} else {
- Log("VnStore: Couldn't write vnode %u, volume %u (%s) (error %d)\n", Vn_id(vnp), V_id(Vn_volume(vnp)), V_name(Vn_volume(vnp)), (int)nBytes);
+ Log("VnStore: Couldn't write vnode %u, volume %" AFS_VOLID_FMT " (%s) (error %d)\n", Vn_id(vnp), afs_printable_VolumeId_lu(V_id(Vn_volume(vnp))), V_name(Vn_volume(vnp)), (int)nBytes);
#ifdef AFS_DEMAND_ATTACH_FS
goto error_encountered;
#else
if (vnp->changed_newTime)
{
V_updateDate(vp) = vp->updateTime = now;
- if(V_volUpCounter(vp)< UINT_MAX)
- V_volUpCounter(vp)++;
+ if(V_volUpdateCounter(vp)< UINT_MAX)
+ V_volUpdateCounter(vp)++;
}
/* The vnode has been changed. Write it out to disk */
* (doing so could cause a "addled bitmap" message).
*/
if (vnp->delete && !*ec) {
- if (Vn_volume(vnp)->header->diskstuff.filecount-- < 1)
- Vn_volume(vnp)->header->diskstuff.filecount = 0;
+ if (V_filecount(Vn_volume(vnp))-- < 1)
+ V_filecount(Vn_volume(vnp)) = 0;
VFreeBitMapEntry_r(ec, vp, &vp->vnodeIndex[class],
vnodeIdToBitNumber(Vn_id(vnp)),
VOL_FREE_BITMAP_WAIT);