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.
(cherry picked from commit
c10b26ca355e47bfb486de971ac275fb281461ca)
*
* 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");
}
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.
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);
/* 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;
/* 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;