afs: Create afs_SetDataVersion 91/11791/6
authorAndrew Deason <adeason@sinenomine.net>
Thu, 26 Jun 2014 22:47:46 +0000 (15:47 -0700)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 15 Sep 2016 01:54:17 +0000 (21:54 -0400)
Several different places in the codebase change avc->f.m.DataVersion
for a particular vcache, when we've noticed that the DV for the vcache
has changed. Consolidate all of these occurrences into a single
afs_SetDataVersion function, to make it easier to change what happens
when we notice a change in DV number.

This should incur no behavior change; it is just simple code
reorganization.

Change-Id: I5dbf2678d3c4b5a2fbef6ef045a0b5bfa8a49242
Reviewed-on: https://gerrit.openafs.org/11791
Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com>
Reviewed-by: Daria Phoebe Brashear <shadow@your-file-system.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Thomas Keiser <tkeiser@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/VNOPS/afs_vnop_create.c
src/afs/afs_disconnected.c
src/afs/afs_prototypes.h
src/afs/afs_vcache.c

index 2fb580c..30eaa7b 100644 (file)
@@ -554,7 +554,7 @@ afs_LocalHero(struct vcache *avc, struct dcache *adc,
     /* The bulk status code used the length as a sequence number.  */
     /* Don't update the vcache entry unless the stats are current. */
     if (avc->f.states & CStatd) {
-       hset(avc->f.m.DataVersion, avers);
+       afs_SetDataVersion(avc, &avers);
 #ifdef AFS_64BIT_CLIENT
        FillInt64(avc->f.m.Length, astat->Length_hi, astat->Length);
 #else /* AFS_64BIT_CLIENT */
index 692dcbc..957bf93 100644 (file)
@@ -1507,6 +1507,7 @@ afs_GenDisconStatus(struct vcache *adp, struct vcache *avc,
                    struct VenusFid *afid, struct vattr *attrs,
                    struct vrequest *areq, int file_type)
 {
+    afs_hyper_t zero;
     memcpy(&avc->f.fid, afid, sizeof(struct VenusFid));
     avc->f.m.Mode = attrs->va_mode;
     /* Used to do this:
@@ -1517,7 +1518,8 @@ afs_GenDisconStatus(struct vcache *adp, struct vcache *avc,
      */
     avc->f.m.Group = adp->f.m.Group;
     avc->f.m.Owner = adp->f.m.Owner;
-    hset64(avc->f.m.DataVersion, 0, 0);
+    hzero(zero);
+    afs_SetDataVersion(avc, &zero);
     avc->f.m.Length = attrs->va_size;
     avc->f.m.Date = osi_Time();
     switch(file_type) {
index d6b7cf6..01e3214 100644 (file)
@@ -1141,6 +1141,8 @@ typedef unsigned int afs_stalevc_flags_t;
 extern void afs_StaleVCacheFlags(struct vcache *avc, afs_stalevc_flags_t flags,
                                 afs_uint32 cflags);
 
+extern void afs_SetDataVersion(struct vcache *avc, afs_hyper_t *avers);
+
 extern void afs_ProcessFS(struct vcache *avc,
                          struct AFSFetchStatus *astat,
                          struct vrequest *areq);
index 18fb79a..36334c0 100644 (file)
@@ -853,6 +853,7 @@ afs_PrePopulateVCache(struct vcache *avc, struct VenusFid *afid,
                      struct server *serverp) {
 
     afs_uint32 slot;
+    afs_hyper_t zero;
     slot = avc->diskSlot;
 
     osi_PrePopulateVCache(avc);
@@ -876,7 +877,8 @@ afs_PrePopulateVCache(struct vcache *avc, struct VenusFid *afid,
 
     hzero(avc->mapDV);
     avc->f.truncPos = AFS_NOTRUNC;   /* don't truncate until we need to */
-    hzero(avc->f.m.DataVersion);     /* in case we copy it into flushDV */
+    hzero(zero);
+    afs_SetDataVersion(avc, &zero);  /* in case we copy it into flushDV */
     avc->Access = NULL;
     avc->callback = serverp;         /* to minimize chance that clear
                                      * request is lost */
@@ -1495,6 +1497,7 @@ afs_ProcessFS(struct vcache *avc,
              struct AFSFetchStatus *astat, struct vrequest *areq)
 {
     afs_size_t length;
+    afs_hyper_t newDV;
     AFS_STATCNT(afs_ProcessFS);
 
 #ifdef AFS_64BIT_CLIENT
@@ -1523,7 +1526,8 @@ afs_ProcessFS(struct vcache *avc,
        avc->f.m.Length = length;
        avc->f.m.Date = astat->ClientModTime;
     }
-    hset64(avc->f.m.DataVersion, astat->dataVersionHigh, astat->DataVersion);
+    hset64(newDV, astat->dataVersionHigh, astat->DataVersion);
+    afs_SetDataVersion(avc, &newDV);
     avc->f.m.Owner = astat->Owner;
     avc->f.m.Mode = astat->UnixModeBits;
     avc->f.m.Group = astat->Group;
@@ -3258,3 +3262,9 @@ afs_StaleVCacheFlags(struct vcache *avc, afs_stalevc_flags_t flags,
        }
     }
 }
+
+void
+afs_SetDataVersion(struct vcache *avc, afs_hyper_t *avers)
+{
+    hset(avc->f.m.DataVersion, *avers);
+}