vol: remove OPENAFS_VOL_STATS
[openafs.git] / src / vol / volume.h
index 20694c5..f9b6473 100644 (file)
@@ -101,8 +101,6 @@ extern pthread_t vol_glock_holder;
 #define VTRANS_LOCK MUTEX_ENTER(&vol_trans_mutex)
 #define VTRANS_UNLOCK MUTEX_EXIT(&vol_trans_mutex)
 #else /* AFS_PTHREAD_ENV */
-#define VOL_CV_WAIT(cv)
-#define VOL_CV_TIMEDWAIT(cv, ts, to)
 #define VOL_LOCK
 #define VOL_UNLOCK
 #define VSALVSYNC_LOCK
@@ -273,6 +271,9 @@ typedef struct VolumePackageOptions {
                                    *   during shutdown, we will still only wait
                                    *   for this amount of time in total, not e.g.
                                    *   for each going-offline volume encountered. */
+    afs_int32 usage_threshold;    /*< number of accesses before writing volume header */
+    afs_int32 usage_rate_limit;   /*< minimum number of seconds before writing volume
+                                   *  header, after usage_threshold is exceeded */
 } VolumePackageOptions;
 
 /* Magic numbers and version stamps for each type of file */
@@ -292,12 +293,7 @@ typedef struct VolumePackageOptions {
 #define ACLVERSION             1
 #define LINKTABLEVERSION       1
 
-/*
- * Define whether we are keeping detailed statistics on volume dealings.
- */
-#define OPENAFS_VOL_STATS      1
 
-#if OPENAFS_VOL_STATS
 /*
  * Define various indices and counts used in keeping volume-level statistics.
  */
@@ -326,7 +322,6 @@ typedef struct VolumePackageOptions {
 #define VOL_STATS_TIME_IDX_3   3       /*1 hr to 24 hrs */
 #define VOL_STATS_TIME_IDX_4   4       /*1 day to 7 days */
 #define VOL_STATS_TIME_IDX_5   5       /*Greater than 1 week */
-#endif /* OPENAFS_VOL_STATS */
 
 /* Volume header.  This is the contents of the named file representing
  * the volume.  Read-only by the file server!
@@ -464,17 +459,12 @@ typedef struct VolumeDiskData {
      * set when the copy is created */
     Date copyDate;
 
-#if OPENAFS_VOL_STATS
     bit32 stat_initialized;    /*Are the stat fields below set up? */
     bit32 reserved4[7];
-#else
-    bit32 reserved4[8];
-#endif                         /* OPENAFS_VOL_STATS */
 
     /* messages */
 #define VMSGSIZE 128
     char offlineMessage[VMSGSIZE];     /* Why the volume is offline */
-#if OPENAFS_VOL_STATS
 #define VOL_STATS_BYTES 128
     /*
      * Keep per-volume aggregate statistics on type and distance of access,
@@ -486,9 +476,6 @@ typedef struct VolumeDiskData {
     bit32 stat_fileDiffAuthor[VOL_STATS_NUM_TIME_FIELDS];
     bit32 stat_dirSameAuthor[VOL_STATS_NUM_TIME_FIELDS];
     bit32 stat_dirDiffAuthor[VOL_STATS_NUM_TIME_FIELDS];
-#else
-    char motd[VMSGSIZE];       /* Volume "message of the day" */
-#endif                         /* OPENAFS_VOL_STATS */
 
 } VolumeDiskData;
 
@@ -719,6 +706,8 @@ typedef struct Volume {
     VolumeVLRUState vlru;         /* state specific to the VLRU */
     FSSYNC_VolOp_info * pending_vol_op;  /* fssync command info for any pending vol ops */
 #endif /* AFS_DEMAND_ATTACH_FS */
+    int usage_bumps_outstanding; /**< to rate limit the usage update i/o by accesses */
+    int usage_bumps_next_write;  /**< to rate limit the usage update i/o by time */
 } Volume;
 
 struct volHeader {
@@ -779,7 +768,6 @@ struct volHeader {
 #define V_offlineMessage(vp)   ((vp)->header->diskstuff.offlineMessage)
 #define V_disk(vp)             ((vp)->header->diskstuff)
 #define V_motd(vp)             ((vp)->header->diskstuff.motd)
-#if OPENAFS_VOL_STATS
 #define V_stat_initialized(vp) ((vp)->header->diskstuff.stat_initialized)
 #define V_stat_area(vp)                (((vp)->header->diskstuff.stat_reads))
 #define V_stat_reads(vp, idx)  (((vp)->header->diskstuff.stat_reads)[idx])
@@ -788,7 +776,6 @@ struct volHeader {
 #define V_stat_fileDiffAuthor(vp, idx) (((vp)->header->diskstuff.stat_fileDiffAuthor)[idx])
 #define V_stat_dirSameAuthor(vp, idx)  (((vp)->header->diskstuff.stat_dirSameAuthor)[idx])
 #define V_stat_dirDiffAuthor(vp, idx)  (((vp)->header->diskstuff.stat_dirDiffAuthor)[idx])
-#endif /* OPENAFS_VOL_STATS */
 #define V_volUpCounter(vp)             ((vp)->header->diskstuff.volUpdateCounter)
 
 /* File offset computations.  The offset values in the volume header are
@@ -901,13 +888,15 @@ extern int VDeregisterVolOp_r(Volume * vp);
 extern void VCancelReservation_r(Volume * vp);
 extern int VChildProcReconnectFS_r(void);
 extern void VOfflineForVolOp_r(Error *ec, Volume *vp, char *message);
+#endif /* AFS_DEMAND_ATTACH_FS */
 
+#if defined(AFS_DEMAND_ATTACH_FS) || defined(AFS_DEMAND_ATTACH_UTIL)
 struct VDiskLock;
 extern void VDiskLockInit(struct VDiskLock *dl, struct VLockFile *lf,
                           afs_uint32 offset);
 extern int VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock);
 extern void VReleaseDiskLock(struct VDiskLock *dl, int locktype);
-#endif /* AFS_DEMAND_ATTACH_FS */
+#endif /* AFS_DEMAND_ATTACH_FS || AFS_DEMAND_ATTACH_UTIL */
 extern int VVolOpLeaveOnline_r(Volume * vp, FSSYNC_VolOp_info * vopinfo);
 extern int VVolOpLeaveOnlineNoHeader_r(Volume * vp, FSSYNC_VolOp_info * vopinfo);
 extern int VVolOpSetVBusy_r(Volume * vp, FSSYNC_VolOp_info * vopinfo);
@@ -1029,8 +1018,7 @@ extern int VWalkVolumeHeaders(struct DiskPartition64 *dp, const char *partpath,
 #define VOL_FREE_BITMAP_WAIT     0x1  /* for demand attach, wait for other exclusive ops to end */
 
 /* VRequestSalvage_r flags */
-#define VOL_SALVAGE_INVALIDATE_HEADER 0x1 /* for demand attach fs, invalidate volume header cache */
-#define VOL_SALVAGE_NO_OFFLINE        0x2 /* we do not need to wait to offline the volume; it has
+#define VOL_SALVAGE_NO_OFFLINE        0x1 /* we do not need to wait to offline the volume; it has
                                            * not been fully attached */