]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
windows-buf-setdirty-20080724
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 24 Jul 2008 20:32:58 +0000 (20:32 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 24 Jul 2008 20:32:58 +0000 (20:32 +0000)
LICENSE MIT

Everytime the CM_BUF_DIRTY flag is set on a cm_buf_t, the userp field
on the cm_buf_t must also be set.  Add a cm_user_t parameter to buf_SetDirty()
so that each function that calls it doesn't have to manually set the
last write user.  This improves code readability and the abstraction layering.

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

index 62b8078ac515ab286559a804fd9cff14a6772689..e5a8a3c439d1afd0f8dbe22ec1f29aa263e28b87 100644 (file)
@@ -1240,7 +1240,7 @@ void buf_CleanWait(cm_scache_t * scp, cm_buf_t *bp, afs_uint32 locked)
  *
  * The buffer must be locked before calling this routine.
  */
-void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length)
+void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length, cm_user_t *userp)
 {
     osi_assertx(bp->magic == CM_BUF_MAGIC, "invalid cm_buf_t magic");
     osi_assertx(bp->refCount > 0, "cm_buf_t refcount 0");
@@ -1299,6 +1299,14 @@ void buf_SetDirty(cm_buf_t *bp, afs_uint32 offset, afs_uint32 length)
         }
         lock_ReleaseWrite(&buf_globalLock);
     }
+
+    /* and record the last writer */
+    if (bp->userp != userp) {
+        cm_HoldUser(userp);
+        if (bp->userp) 
+            cm_ReleaseUser(bp->userp);
+        bp->userp = userp;
+    }
 }
 
 /* clean all buffers, reset log pointers and invalidate all buffers.
index 09d49ed3e8d644a4c37f5303c6c34baff4f87b17..bb028b67c708e4e08af1290bcf277a0b2ffa6814 100644 (file)
@@ -166,7 +166,7 @@ extern long buf_CleanAsync(cm_buf_t *, cm_req_t *);
 
 extern void buf_CleanWait(cm_scache_t *, cm_buf_t *, afs_uint32 locked);
 
-extern void buf_SetDirty(cm_buf_t *, afs_uint32 offset, afs_uint32 length);
+extern void buf_SetDirty(cm_buf_t *, afs_uint32 offset, afs_uint32 length, cm_user_t *);
 
 extern long buf_CleanAndReset(void);
 
index 849a7af90cde77643a9e0eb3ec569de4754589d4..228f3cf5a072ccb42ff123f37fae4e94c1043d45 100644 (file)
@@ -322,15 +322,7 @@ long WriteData(cm_scache_t *scp, osi_hyper_t offset, long count, char *op,
 
         /* now copy the data */
        memcpy(bufferp->datap + bufIndex, op, nbytes);
-        buf_SetDirty(bufferp, bufIndex, nbytes);
-
-        /* and record the last writer */
-        if (bufferp->userp != userp) {
-            cm_HoldUser(userp);
-            if (bufferp->userp) 
-                cm_ReleaseUser(bufferp->userp);
-            bufferp->userp = userp;
-        }
+        buf_SetDirty(bufferp, bufIndex, nbytes, userp);
 
         /* adjust counters, pointers, etc. */
         op += nbytes;
index 6005d9f37f8e96aaa3c295363b082f4161bbe2dd..521606b3050283872045c2ecfb00891748fcc3aa 100644 (file)
@@ -6787,15 +6787,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, afs_uint32 count, char
 
         /* now copy the data */
        memcpy(bufferp->datap + bufIndex, op, nbytes);
-        buf_SetDirty(bufferp, bufIndex, nbytes);
-
-        /* and record the last writer */
-        if (bufferp->userp != userp) {
-            cm_HoldUser(userp);
-            if (bufferp->userp) 
-                cm_ReleaseUser(bufferp->userp);
-            bufferp->userp = userp;
-        }
+        buf_SetDirty(bufferp, bufIndex, nbytes, userp);
 
         /* adjust counters, pointers, etc. */
         op += nbytes;