#ifdef AFS_DEMAND_ATTACH_FS
pthread_mutex_t vol_salvsync_mutex;
+
+/*
+ * Set this to 1 to disallow SALVSYNC communication in all threads; used
+ * during shutdown, since the salvageserver may have gone away.
+ */
+static volatile sig_atomic_t vol_disallow_salvsync = 0;
#endif /* AFS_DEMAND_ATTACH_FS */
#ifdef AFS_OSF_ENV
/* online salvager */
static int VCheckSalvage(register Volume * vp);
static int VUpdateSalvagePriority_r(Volume * vp);
+#ifdef SALVSYNC_BUILD_CLIENT
static int VScheduleSalvage_r(Volume * vp);
+#endif
/* Volume hash table */
static void VReorderHash_r(VolumeHashChainHead * head, Volume * pp, Volume * vp);
/* VLRU */
static void VLRU_ComputeConstants(void);
static void VInitVLRU(void);
-static void VLRU_Init_Node_r(volatile Volume * vp);
-static void VLRU_Add_r(volatile Volume * vp);
-static void VLRU_Delete_r(volatile Volume * vp);
-static void VLRU_UpdateAccess_r(volatile Volume * vp);
+static void VLRU_Init_Node_r(Volume * vp);
+static void VLRU_Add_r(Volume * vp);
+static void VLRU_Delete_r(Volume * vp);
+static void VLRU_UpdateAccess_r(Volume * vp);
static void * VLRU_ScannerThread(void * args);
static void VLRU_Scan_r(int idx);
static void VLRU_Promote_r(int idx);
static void VLRU_Demote_r(int idx);
-static void VLRU_SwitchQueues(volatile Volume * vp, int new_idx, int append);
+static void VLRU_SwitchQueues(Volume * vp, int new_idx, int append);
/* soft detach */
-static int VCheckSoftDetach(volatile Volume * vp, afs_uint32 thresh);
-static int VCheckSoftDetachCandidate(volatile Volume * vp, afs_uint32 thresh);
-static int VSoftDetachVolume_r(volatile Volume * vp, afs_uint32 thresh);
+static int VCheckSoftDetach(Volume * vp, afs_uint32 thresh);
+static int VCheckSoftDetachCandidate(Volume * vp, afs_uint32 thresh);
+static int VSoftDetachVolume_r(Volume * vp, afs_uint32 thresh);
pthread_key_t VThread_key;
* shutdown all remaining volumes
*/
+#ifdef AFS_DEMAND_ATTACH_FS
+
void
VShutdown_r(void)
{
int i;
- register Volume *vp, *np;
- register afs_int32 code;
-#ifdef AFS_DEMAND_ATTACH_FS
struct DiskPartition64 * diskP;
struct diskpartition_queue_t * dpq;
vshutdown_thread_t params;
}
Log("VShutdown: complete.\n");
+}
+
#else /* AFS_DEMAND_ATTACH_FS */
+
+void
+VShutdown_r(void)
+{
+ int i;
+ register Volume *vp, *np;
+ register afs_int32 code;
Log("VShutdown: shutting down on-line volumes...\n");
for (i = 0; i < VolumeHashTable.Size; i++) {
/* try to hold first volume in the hash table */
}
}
Log("VShutdown: complete.\n");
-#endif /* AFS_DEMAND_ATTACH_FS */
}
+#endif /* AFS_DEMAND_ATTACH_FS */
+
void
VShutdown(void)
VOL_UNLOCK;
}
+/**
+ * stop new activity (e.g. SALVSYNC) from occurring
+ *
+ * Use this to make the volume package less busy; for example, during
+ * shutdown. This doesn't actually shutdown/detach anything in the
+ * volume package, but prevents certain processes from ocurring. For
+ * example, preventing new SALVSYNC communication in DAFS. In theory, we
+ * could also use this to prevent new volume attachment, or prevent
+ * other programs from checking out volumes, etc.
+ */
+void
+VSetTranquil(void)
+{
+#ifdef AFS_DEMAND_ATTACH_FS
+ /* make sure we don't try to contact the salvageserver, since it may
+ * not be around anymore */
+ vol_disallow_salvsync = 1;
+#endif
+}
+
#ifdef AFS_DEMAND_ATTACH_FS
/*
* demand attach fs
if (thr_left) {
/* try to assign any leftover threads to partitions that
* had volume lengths closer to needing thread_target+1 */
- int max_residue, max_id;
+ int max_residue, max_id = 0;
/* compute the residues */
for (diskP = DiskPartitionList; diskP; diskP = diskP->next) {
static void *
VShutdownThread(void * args)
{
- struct rx_queue *qp;
- Volume * vp;
vshutdown_thread_t * params;
- int part, code, found, pass, schedule_version_save, count;
+ int found, pass, schedule_version_save, count;
struct DiskPartition64 *diskP;
struct diskpartition_queue_t * dpq;
Device id;
int
VShutdownByPartition_r(struct DiskPartition64 * dp)
{
- int pass, retVal;
+ int pass;
int pass_stats[4];
int total;
Log("VShutdownByPartition: shut down %d volumes on %s (pass[0]=%d, pass[1]=%d, pass[2]=%d, pass[3]=%d)\n",
total, VPartitionPath(dp), pass_stats[0], pass_stats[1], pass_stats[2], pass_stats[3]);
- return retVal;
+ return 0;
}
/* internal shutdown functionality
VOffline_r(vp, "File server was shut down");
}
break;
+ default:
+ break;
}
VCancelReservation_r(vp);
VolumeHeaderToDisk(VolumeDiskHeader_t * dh, VolumeHeader_t * h)
{
- memset((char *)dh, 0, sizeof(VolumeDiskHeader_t));
+ memset(dh, 0, sizeof(VolumeDiskHeader_t));
dh->stamp = h->stamp;
dh->id = h->id;
dh->parent = h->parent;
void
DiskToVolumeHeader(VolumeHeader_t * h, VolumeDiskHeader_t * dh)
{
- memset((char *)h, 0, sizeof(VolumeHeader_t));
+ memset(h, 0, sizeof(VolumeHeader_t));
h->stamp = dh->stamp;
h->id = dh->id;
h->parent = dh->parent;
char path[64];
int isbusy = 0;
VolId volumeId;
- Volume * nvp;
+ Volume * nvp = NULL;
VolumeStats stats_save;
*ec = 0;
}
#ifdef AFS_DEMAND_ATTACH_FS
+# ifdef FSSYNC_BUILD_CLIENT
disk_header_loaded:
+#endif
if (!*ec) {
/* check for pending volume operations */
if (VVolOpSetVBusy_r(vp, vp->pending_vol_op)) {
vp->specialStatus = VBUSY;
}
+ default:
+ break;
}
}
* area and mark it as initialized.
*/
if (!(V_stat_initialized(vp))) {
- memset((char *)(V_stat_area(vp)), 0, VOL_STATS_BYTES);
+ memset((V_stat_area(vp)), 0, VOL_STATS_BYTES);
V_stat_initialized(vp) = 1;
}
#endif /* OPENAFS_VOL_STATS */
*/
/* only valid before/during demand attachment */
- assert(!vp->pending_vol_op || vp->pending_vol_op != FSSYNC_VolOpRunningUnknown);
+ assert(!vp->pending_vol_op || vp->pending_vol_op->vol_op_state != FSSYNC_VolOpRunningUnknown);
/* deny getvolume due to running mutually exclusive vol op */
if (vp->pending_vol_op && vp->pending_vol_op->vol_op_state==FSSYNC_VolOpRunningOffline) {
void
VOffline_r(Volume * vp, char *message)
{
+#ifndef AFS_DEMAND_ATTACH_FS
Error error;
VolumeId vid = V_id(vp);
+#endif
assert(programType != volumeUtility);
if (!V_inUse(vp)) {
static int
VUpdateSalvagePriority_r(Volume * vp)
{
- int code, ret=0;
- afs_uint32 now;
+ int ret=0;
#ifdef SALVSYNC_BUILD_CLIENT
+ afs_uint32 now;
+ int code;
+
vp->salvage.prio++;
now = FT_ApproxTime();
}
+#ifdef SALVSYNC_BUILD_CLIENT
/**
* schedule a salvage with the salvage server.
*
static int
VScheduleSalvage_r(Volume * vp)
{
- int code, ret=0;
-#ifdef SALVSYNC_BUILD_CLIENT
+ int ret=0;
+ int code;
VolState state_save;
VThreadOptions_t * thread_opts;
char partName[16];
if (thread_opts == NULL) {
thread_opts = &VThread_defaults;
}
- if (thread_opts->disallow_salvsync) {
+ if (thread_opts->disallow_salvsync || vol_disallow_salvsync) {
return 1;
}
}
}
}
-#endif /* SALVSYNC_BUILD_CLIENT */
return ret;
}
-#ifdef SALVSYNC_BUILD_CLIENT
/**
* connect to the salvageserver SYNC service.
*
int
VDisconnectSALV(void)
{
- int retVal;
VOL_LOCK;
VDisconnectSALV_r();
VOL_UNLOCK;
- return retVal;
+ return 0;
}
/**
* All we need to do is bzero the entire VOL_STATS_BYTES of
* the detailed volume statistics area.
*/
- memset((char *)(V_stat_area(vp)), 0, VOL_STATS_BYTES);
+ memset((V_stat_area(vp)), 0, VOL_STATS_BYTES);
#endif /* OPENAFS_VOL_STATS */
}
VBumpVolumeUsage_r(register Volume * vp)
{
unsigned int now = FT_ApproxTime();
+ V_accessDate(vp) = now;
if (now - V_dayUseDate(vp) > OneDay)
VAdjustVolumeStatistics_r(vp);
/*
* @internal volume package interal use only.
*/
static void
-VLRU_Init_Node_r(volatile Volume * vp)
+VLRU_Init_Node_r(Volume * vp)
{
if (!VLRU_enabled)
return;
* @internal volume package internal use only.
*/
static void
-VLRU_Add_r(volatile Volume * vp)
+VLRU_Add_r(Volume * vp)
{
int idx;
VolState state_save;
* @internal volume package internal use only.
*/
static void
-VLRU_Delete_r(volatile Volume * vp)
+VLRU_Delete_r(Volume * vp)
{
int idx;
* @internal volume package internal use only.
*/
static void
-VLRU_UpdateAccess_r(volatile Volume * vp)
+VLRU_UpdateAccess_r(Volume * vp)
{
- afs_uint32 live_interval;
Volume * rvp = NULL;
if (!VLRU_enabled)
* @internal volume package internal use only.
*/
static void
-VLRU_SwitchQueues(volatile Volume * vp, int new_idx, int append)
+VLRU_SwitchQueues(Volume * vp, int new_idx, int append)
{
if (queue_IsNotOnQueue(&vp->vlru))
return;
VLRU_ScannerThread(void * args)
{
afs_uint32 now, min_delay, delay;
- afs_uint32 next_scan[VLRU_GENERATIONS];
- afs_uint32 next_promotion[VLRU_GENERATIONS];
int i, min_idx, min_op, overdue, state;
/* set t=0 for promotion cycle to be
int len, chaining, promote;
afs_uint32 now, thresh;
struct rx_queue *qp, *nqp;
- Volume * vp, *start, *end;
+ Volume * vp, *start = NULL, *end = NULL;
/* get exclusive access to two chains, and drop the glock */
VLRU_Wait_r(&volume_LRU.q[idx]);
int len, chaining, demote;
afs_uint32 now, thresh;
struct rx_queue *qp, *nqp;
- Volume * vp, *start, *end;
+ Volume * vp, *start = NULL, *end = NULL;
Volume ** salv_flag_vec = NULL;
int salv_vec_offset = 0;
{
afs_uint32 now, thresh;
struct rx_queue *qp, *nqp;
- volatile Volume * vp;
+ Volume * vp;
int i, locked = 1;
assert(idx == VLRU_QUEUE_NEW || idx == VLRU_QUEUE_CANDIDATE);
/* check whether volume is safe to soft detach
* caller MUST NOT hold a ref count on vp */
static int
-VCheckSoftDetach(volatile Volume * vp, afs_uint32 thresh)
+VCheckSoftDetach(Volume * vp, afs_uint32 thresh)
{
int ret=0;
/* check whether volume should be made a
* soft detach candidate */
static int
-VCheckSoftDetachCandidate(volatile Volume * vp, afs_uint32 thresh)
+VCheckSoftDetachCandidate(Volume * vp, afs_uint32 thresh)
{
int idx, ret = 0;
if (vp->nUsers || vp->nWaiters)
*
* caller MUST NOT hold a ref count on vp */
static int
-VSoftDetachVolume_r(volatile Volume * vp, afs_uint32 thresh)
+VSoftDetachVolume_r(Volume * vp, afs_uint32 thresh)
{
afs_uint32 ts_save;
int ret = 0;
V_attachFlags(vp) &= ~(VOL_ON_VLRU);
VCancelReservation_r(vp);
return 0;
+ default:
+ break;
}
/* hold the volume and take it offline.
static int everLogged = 0;
#ifdef AFS_DEMAND_ATTACH_FS
- VolState vp_save, back_save;
+ VolState vp_save = 0, back_save = 0;
/* XXX debug 9/19/05 we've apparently got
* a ref counting bug somewhere that's
void
VPrintExtendedCacheStats_r(int flags)
{
- int i, j;
+ int i;
afs_uint32 vol_sum = 0;
struct stats {
double min;