]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
volser: preserve stats over reclones and restores
authorMichael Meffie <mmeffie@sinenomine.net>
Thu, 23 Feb 2012 17:34:44 +0000 (12:34 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Thu, 12 Sep 2013 18:22:50 +0000 (11:22 -0700)
Optionally, preserve the volume usage statistics instead of clearing
them during reclone and restore operations.

Reviewed-on: http://gerrit.openafs.org/3312
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit dfceff1d3a66e76246537738720f411330808d64)

Change-Id: I2e47c7ddac74f75b6f650327028644e178cfc574
Reviewed-on: http://gerrit.openafs.org/9477
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
doc/man-pages/pod8/fragments/volserver-options.pod
doc/man-pages/pod8/fragments/volserver-synopsis.pod
src/vol/vol_prototypes.h
src/vol/vutil.c
src/volser/dumpstuff.c
src/volser/volmain.c
src/volser/volprocs.c

index a2b98e25bec914d4e838b858853ff243e28fd275..1ad49a069ca52f3cf7f25e55027128be0207b9c2 100644 (file)
@@ -74,6 +74,12 @@ user.admin PTS entry. Sites whose Kerberos realms don't have these collisions
 between principal names may disable this check by starting the server
 with this option.
 
+=item B<-preserve-vol-stats>
+
+Preserve volume access statistics over volume restore and reclone operations.
+By default, volume access statistics are reset during volume restore and reclone
+operations.
+
 =item B<-sync> <I<sync behavior>>
 
 This is the same as the B<-sync> option in L<fileserver(8)>. See
index d5fca73534b9463c21c396012d977e40183e36d4..0340a50bcd0edc3548fbee1b7348a101826e1af6 100644 (file)
@@ -5,5 +5,5 @@ B<volserver>
     S<<< [B<-d> <I<debug level>>] >>>
     [B<-nojumbo>] [B<-jumbo>] 
     [B<-enable_peer_stats>] [B<-enable_process_stats>] 
-    [B<-allow-dotted-principals>] [B<-help>]
+    [B<-allow-dotted-principals>] [B<-preserve-vol-stats>] [B<-help>]
     [B<-sync> <I<sync behavior>>]
index 4d7a709591414431e0484ac594bb7fab41cab5c3..eec1ccf26c9ccc268c037e68c252b29c5a9f44f8 100644 (file)
@@ -22,6 +22,8 @@ extern void AssignVolumeName(VolumeDiskData * vol, char *name, char *ext);
 extern void AssignVolumeName_r(VolumeDiskData * vol, char *name, char *ext);
 extern void ClearVolumeStats(VolumeDiskData * vol);
 extern void ClearVolumeStats_r(VolumeDiskData * vol);
+extern void CopyVolumeStats(VolumeDiskData * from, VolumeDiskData * to);
+extern void CopyVolumeStats_r(VolumeDiskData * from, VolumeDiskData * to);
 extern afs_int32 CopyVolumeHeader(VolumeDiskData *, VolumeDiskData *);
 
 #endif
index 8e2a7002adaa8b2435ad6dcdd1accc2aa0e8e32d..991005bae06225c9e065c58578028099584ff204 100644 (file)
@@ -408,6 +408,34 @@ ClearVolumeStats_r(VolumeDiskData * vol)
     vol->dayUseDate = 0;
 }
 
+void
+CopyVolumeStats_r(VolumeDiskData * from, VolumeDiskData * to)
+{
+    memcpy(to->weekUse, from->weekUse, sizeof(to->weekUse));
+    to->dayUse = from->dayUse;
+    to->dayUseDate = from->dayUseDate;
+    if (from->stat_initialized) {
+       memcpy(to->stat_reads, from->stat_reads, sizeof(to->stat_reads));
+       memcpy(to->stat_writes, from->stat_writes, sizeof(to->stat_writes));
+       memcpy(to->stat_fileSameAuthor, from->stat_fileSameAuthor,
+              sizeof(to->stat_fileSameAuthor));
+       memcpy(to->stat_fileDiffAuthor, from->stat_fileDiffAuthor,
+              sizeof(to->stat_fileDiffAuthor));
+       memcpy(to->stat_dirSameAuthor, from->stat_dirSameAuthor,
+              sizeof(to->stat_dirSameAuthor));
+       memcpy(to->stat_dirDiffAuthor, from->stat_dirDiffAuthor,
+              sizeof(to->stat_dirDiffAuthor));
+    }
+}
+
+void
+CopyVolumeStats(VolumeDiskData * from, VolumeDiskData * to)
+{
+    VOL_LOCK;
+    CopyVolumeStats_r(from, to);
+    VOL_UNLOCK;
+}
+
 /**
  * read an existing volume disk header.
  *
index 138949c8c1d664bee539791e4c1dbe9cc117eceb..f525e63ce6b1a3479de6a4d20844f2c7f525b72f 100644 (file)
@@ -61,6 +61,7 @@
 /*@printflike@*/ extern void Log(const char *format, ...);
 
 extern int DoLogging;
+extern int DoPreserveVolumeStats;
 
 
 /* Forward Declarations */
@@ -1216,11 +1217,16 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
     afs_foff_t *b1 = NULL, *b2 = NULL;
     int s1 = 0, s2 = 0, delo = 0, tdelo;
     int tag;
+    VolumeDiskData saved_header;
 
     iod_Init(iodp, call);
 
     vp = avp;
 
+    if (DoPreserveVolumeStats) {
+       CopyVolumeStats(&V_disk(vp), &saved_header);
+    }
+
     if (!ReadDumpHeader(iodp, &header)) {
        Log("1 Volser: RestoreVolume: Error reading header file for dump; aborted\n");
        return VOLSERREAD_DUMPERROR;
@@ -1289,7 +1295,11 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
     }
 
   clean:
-    ClearVolumeStats(&vol);
+    if (DoPreserveVolumeStats) {
+       CopyVolumeStats(&saved_header, &vol);
+    } else {
+       ClearVolumeStats(&vol);
+    }
     if (V_needsSalvaged(vp)) {
        /* needsSalvaged may have been set while we tried to write volume data.
         * prevent it from getting overwritten. */
index ea0af1bd5496caa6e298fce06d2407fdc08434c0..2230666c12c460a92378731b211975347e0c85ea 100644 (file)
@@ -87,6 +87,7 @@ int udpBufSize = 0;           /* UDP buffer size for receive */
 
 int rxBind = 0;
 int rxkadDisableDotCheck = 0;
+int DoPreserveVolumeStats = 0;
 
 #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
 afs_uint32 SHostAddrs[ADDRSPERSITE];
@@ -374,6 +375,8 @@ main(int argc, char **argv)
            rx_enablePeerRPCStats();
        } else if (strcmp(argv[code], "-enable_process_stats") == 0) {
            rx_enableProcessRPCStats();
+       } else if (strcmp(argv[code], "-preserve-vol-stats") == 0) {
+           DoPreserveVolumeStats = 1;
        } else if (strcmp(argv[code], "-sync") == 0) {
            if ((code + 1) >= argc) {
                printf("You have to specify -sync <sync_behavior>\n");
index 61564587c210c77d14b2d0279190f85f4abf79ee..87e383e4555b83963517ee84725c538a0a3412fb 100644 (file)
@@ -71,6 +71,7 @@
 
 extern int DoLogging;
 extern struct afsconf_dir *tdir;
+extern int DoPreserveVolumeStats;
 
 extern void LogError(afs_int32 errcode);
 
@@ -907,6 +908,7 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
     afs_int32 newType;
     struct volser_trans *tt, *ttc;
     char caller[MAXKTCNAMELEN];
+    VolumeDiskData saved_header;
 
     /*not a super user */
     if (!afsconf_SuperUser(tdir, acid, caller))
@@ -963,6 +965,10 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
        goto fail;
     }
 
+    if (DoPreserveVolumeStats) {
+       CopyVolumeStats(&V_disk(clonevp), &saved_header);
+    }
+
     error = 0;
     Log("1 Volser: Clone: Recloning volume %u to volume %u\n", tt->volid,
        cloneId);
@@ -989,7 +995,11 @@ VolReClone(struct rx_call *acid, afs_int32 atrans, afs_int32 cloneId)
      * for ROs. But do not update copyDate; let it stay so we can identify
      * when the clone was first created. */
     V_creationDate(clonevp) = time(0);
-    ClearVolumeStats(&V_disk(clonevp));
+    if (DoPreserveVolumeStats) {
+       CopyVolumeStats(&saved_header, &V_disk(clonevp));
+    } else {
+       ClearVolumeStats(&V_disk(clonevp));
+    }
     V_destroyMe(clonevp) = 0;
     V_inService(clonevp) = 0;
     if (newType == backupVolume) {