libafs: avoid resetting the dynroot volume every 10 minutes 95/11895/5
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 5 Jun 2015 14:09:54 +0000 (10:09 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 6 Jul 2016 01:39:13 +0000 (21:39 -0400)
The dynroot volumes are synthetic, so do not need to be reset every time
the background daemon checks the volumes.

The results of osi_Time() is a signed 32-bit integer, and the volume
expireTime is an signed 32-bit integer, so use signed 32-bit integers
for the expiry check.

Change-Id: Ib92157686c1d8b84a63d409cb148155705953b6d
Reviewed-on: https://gerrit.openafs.org/11895
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/afs_dynroot.c
src/afs/afs_prototypes.h
src/afs/afs_volume.c

index 144a2d4..83dc1aa 100644 (file)
@@ -107,6 +107,17 @@ afs_dynrootCellInit(void)
     return 0;
 }
 
+/*!
+ * Returns non-zero if the volume is the dynroot volume.
+ */
+int
+afs_IsDynrootVolume(struct volume *v)
+{
+    return (afs_dynrootEnable
+           && v->cell == afs_dynrootCell
+           && v->volume == AFS_DYNROOT_VOLUME);
+}
+
 /*
  * Returns non-zero iff fid corresponds to the top of the dynroot volume.
  */
index 440567a..945954e 100644 (file)
@@ -294,6 +294,7 @@ extern void afs_PopulateDCache(struct vcache *avc, afs_size_t apos,
 /* afs_dynroot.c */
 extern afs_rwlock_t afs_dynrootDirLock;
 extern afs_rwlock_t afs_dynSymlinkLock;
+extern int afs_IsDynrootVolume(struct volume *v);
 extern int afs_IsDynrootFid(struct VenusFid *fid);
 extern int afs_IsDynrootMountFid(struct VenusFid *fid);
 extern int afs_IsDynrootAnyFid(struct VenusFid *fid);
index 2fd8a9e..3aa64b8 100644 (file)
@@ -409,6 +409,24 @@ afs_ResetVolumes(struct server *srvp, struct volume *tv)
     }
 }
 
+/*!
+ * Returns non-zero if the volume information is expired.
+ *
+ * Dynroot volumes are not setup from vldb queries, so never expire.
+ * Read-only volume expiry is tied to the volume callback.
+ *
+ * \param tv volume to check
+ * \param now current time
+ *
+ * \return non-zero if the volume should be reset
+ */
+static int
+IsExpired(struct volume *tv, afs_int32 now)
+{
+    return (tv->expireTime < (now + 10)) && (tv->states & VRO)
+           && !afs_IsDynrootVolume(tv);
+}
+
 /**
  *   Reset volume name to volume id mapping cache.
  * @param flags
@@ -418,7 +436,7 @@ afs_CheckVolumeNames(int flags)
 {
     afs_int32 i, j;
     struct volume *tv;
-    unsigned int now;
+    afs_int32 now;
     struct vcache *tvc;
     afs_int32 *volumeID, *cellID, vsize, nvols;
 #ifdef AFS_DARWIN80_ENV
@@ -447,8 +465,7 @@ afs_CheckVolumeNames(int flags)
     for (i = 0; i < NVOLS; i++) {
        for (tv = afs_volumes[i]; tv; tv = tv->next) {
            if (flags & AFS_VOLCHECK_EXPIRED) {
-               if (((tv->expireTime < (now + 10)) && (tv->states & VRO))
-                   || (flags & AFS_VOLCHECK_FORCE)) {
+               if (IsExpired(tv, now) || (flags & AFS_VOLCHECK_FORCE)) {
                    afs_ResetVolumeInfo(tv);    /* also resets status */
                    if (volumeID) {
                        volumeID[nvols] = tv->volume;