# include <opr/lockstub.h>
#endif
#include <opr/ffs.h>
+#include <opr/jhash.h>
#include <afs/afsint.h>
static Volume * GetVolume(Error * ec, Error * client_ec, VolumeId volumeId,
Volume * hint, const struct timespec *ts);
-int LogLevel; /* Vice loglevel--not defined as extern so that it will be
- * defined when not linked with vice, XXXX */
ProgramType programType; /* The type of program using the package */
static VolumePackageOptions vol_opts;
* an AVL or splay tree might work a lot better, but we'll just increase
* the default hash table size for now
*/
-#define DEFAULT_VOLUME_HASH_SIZE 256 /* Must be a power of 2!! */
-#define DEFAULT_VOLUME_HASH_MASK (DEFAULT_VOLUME_HASH_SIZE-1)
-#define VOLUME_HASH(volumeId) (volumeId&(VolumeHashTable.Mask))
+#define DEFAULT_VOLUME_HASH_BITS 10
+#define DEFAULT_VOLUME_HASH_SIZE opr_jhash_size(DEFAULT_VOLUME_HASH_BITS)
+#define DEFAULT_VOLUME_HASH_MASK opr_jhash_mask(DEFAULT_VOLUME_HASH_BITS)
+#define VOLUME_HASH(volumeId) \
+ (opr_jhash_int(volumeId, 0) & VolumeHashTable.Mask)
/*
* turn volume hash chains into partially ordered lists.
(*(vp ? nAttached : nUnattached))++;
if (error == VOFFLINE)
Log("Volume %d stays offline (/vice/offline/%s exists)\n", VolumeNumber(dp->d_name), dp->d_name);
- else if (LogLevel >= 5) {
+ else if (GetLogLevel() >= 5) {
Log("Partition %s: attached volume %d (%s)\n",
diskP->name, VolumeNumber(dp->d_name),
dp->d_name);
for (queue_Scan(&VolumeHashTable.Table[i],vp,np,Volume)) {
code = VHold_r(vp);
if (code == 0) {
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
VCreateReservation_r(vp);
- if (LogLevel >= 5) {
+ if (GetLogLevel() >= 5) {
Log("VShutdownVolume_r: vid=%" AFS_VOLID_FMT ", device=%d, state=%u\n",
afs_printable_VolumeId_lu(vp->hashid), vp->partition->device,
(unsigned int) V_attachState(vp));
case VOL_STATE_ATTACHED:
code = VHold_r(vp);
if (!code) {
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VShutdown: Attempting to take volume %" AFS_VOLID_FMT " offline.\n",
afs_printable_VolumeId_lu(vp->hashid));
VLRU_Init_Node_r(vp);
VChangeState_r(vp, VOL_STATE_PREATTACHED);
- if (LogLevel >= 5)
+ if (GetLogLevel() >= 5)
Log("VPreAttachVolumeByVp_r: volume %" AFS_VOLID_FMT " pre-attached\n", afs_printable_VolumeId_lu(vp->hashid));
done:
goto done;
}
}
- if (LogLevel)
+ if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n", afs_printable_VolumeId_lu(V_id(vp)),
V_name(vp));
}
goto done;
}
}
- if (LogLevel)
+ if (GetLogLevel() != 0)
Log("VOnline: volume %" AFS_VOLID_FMT " (%s) attached and online\n",
afs_printable_VolumeId_lu(V_id(vp)), V_name(vp));
done:
FreeVolumeHeader(vp);
} else if (!V_inService(vp)) {
Log("Volume %lu offline: not in service\n", afs_printable_uint32_lu(V_id(vp)));
+ /* the volume is offline and should be unattached */
+ *ec = VOFFLINE;
+ error_state = VOL_STATE_UNATTACHED;
FreeVolumeHeader(vp);
} else {
Log("Volume %lu offline: needs salvage\n", afs_printable_uint32_lu(V_id(vp)));
VGET_CTR_INC(V6);
/* Only log the error if it was a totally unexpected error. Simply
* a missing inode is likely to be caused by the volume being deleted */
- if (errno != ENXIO || LogLevel)
+ if (errno != ENXIO || GetLogLevel() != 0)
Log("Volume %" AFS_VOLID_FMT ": couldn't reread volume header\n",
afs_printable_VolumeId_lu(vp->hashid));
#ifdef AFS_DEMAND_ATTACH_FS
#endif /* AFS_DEMAND_ATTACH_FS */
for(queue_Scan(&vp->rx_call_list, cbv, ncbv, VCallByVol)) {
- if (LogLevel > 0) {
+ if (GetLogLevel() != 0) {
struct rx_peer *peer;
char hoststr[16];
peer = rx_PeerOf(rx_ConnectionOf(cbv->call));
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
- if (LogLevel) {
+ if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
V_inUse(vp) = 0;
VUpdateVolume_r(&error, vp, 0);
VCloseVolumeHandles_r(vp);
- if (LogLevel) {
+ if (GetLogLevel() != 0) {
if (V_offlineMessage(vp)[0]) {
Log("VOffline: Volume %lu (%s) is now offline (%s)\n",
afs_printable_uint32_lu(V_id(vp)), V_name(vp),
done:
#ifdef AFS_DEMAND_ATTACH_FS
- VCancelReservation_r(vp);
+ if (flags & VOL_FREE_BITMAP_WAIT) {
+ VCancelReservation_r(vp);
+ }
#endif
return; /* make the compiler happy for non-DAFS */
}
/* setup the timing constants */
VLRU_ComputeConstants();
- /* XXX put inside LogLevel check? */
+ /* XXX put inside log level check? */
Log("VLRU: starting scanner with the following configuration parameters:\n");
Log("VLRU: offlining volumes after minimum of %d seconds of inactivity\n", VLRU_offline_thresh);
Log("VLRU: running VLRU soft detach pass every %d seconds\n", VLRU_offline_interval);
}
if (!VInit) {
- VolumeHashTable.Size = 1 << logsize;
- VolumeHashTable.Mask = VolumeHashTable.Size - 1;
+ VolumeHashTable.Size = opr_jhash_size(logsize);
+ VolumeHashTable.Mask = opr_jhash_mask(logsize);
} else {
/* we can't yet support runtime modification of this
* parameter. we'll need a configuration rwlock to