From 7b99f2e4a8b7071930a5851c5f6c6ab6ddc0dd57 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 26 Jun 2014 15:47:46 -0700 Subject: [PATCH] afs: Create afs_SetDataVersion 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 Reviewed-by: Daria Phoebe Brashear Reviewed-by: Benjamin Kaduk Reviewed-by: Thomas Keiser Tested-by: BuildBot --- src/afs/VNOPS/afs_vnop_create.c | 2 +- src/afs/afs_disconnected.c | 4 +++- src/afs/afs_prototypes.h | 2 ++ src/afs/afs_vcache.c | 14 ++++++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index 2fb580c..30eaa7b 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -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 */ diff --git a/src/afs/afs_disconnected.c b/src/afs/afs_disconnected.c index 692dcbc..957bf93 100644 --- a/src/afs/afs_disconnected.c +++ b/src/afs/afs_disconnected.c @@ -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) { diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index d6b7cf6..01e3214 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -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); diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 18fb79a..36334c0 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -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); +} -- 1.9.4