Windows: add buf_InvalidateBuffers
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 3 Feb 2012 16:35:33 +0000 (11:35 -0500)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 3 Feb 2012 21:37:03 +0000 (13:37 -0800)
Add a utility function that invalidates all buffers for a
cm_scache_t object.

Change-Id: Ib10139fb2aefa03d597d5afd494652fade40432e
Reviewed-on: http://gerrit.openafs.org/6651
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/WINNT/afsd/cm_buf.c
src/WINNT/afsd/cm_buf.h

index 4d8833e..e64b1f4 100644 (file)
@@ -2131,6 +2131,33 @@ long buf_FlushCleanPages(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
 }
 
 /* Must be called with scp->rw held */
+long buf_InvalidateBuffers(cm_scache_t * scp)
+{
+    cm_buf_t * bp;
+    afs_uint32 i;
+    int found = 0;
+
+    lock_AssertAny(&scp->rw);
+
+    i = BUF_FILEHASH(&scp->fid);
+
+    lock_ObtainRead(&buf_globalLock);
+
+    for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp = bp->fileHashp) {
+        if (cm_FidCmp(&bp->fid, &scp->fid) == 0) {
+            bp->dataVersion = CM_BUF_VERSION_BAD;
+            found = 1;
+        }
+    }
+    lock_ReleaseRead(&buf_globalLock);
+
+    if (found)
+        return 0;
+    else
+        return ENOENT;
+}
+
+/* Must be called with scp->rw held */
 long buf_ForceDataVersion(cm_scache_t * scp, afs_uint64 fromVersion, afs_uint64 toVersion)
 {
     cm_buf_t * bp;
index eaedf12..0184d6e 100644 (file)
@@ -218,6 +218,8 @@ extern long buf_DirtyBuffersExist(cm_fid_t * fidp);
 
 extern long buf_CleanDirtyBuffers(cm_scache_t *scp);
 
+extern long buf_InvalidateBuffers(cm_scache_t * scp);
+
 extern long buf_RDRBuffersExist(cm_fid_t *fidp);
 
 extern long buf_ClearRDRFlag(cm_scache_t *scp, char * reason);