KDFS-windows-lock-order-20080827

LICENSE MIT

do not hold cm_scacheLock while obtaining cm_scache_t->rw


(cherry picked from commit c50857b05e6636bef864c9418b21d1bf3c63494a)
This commit is contained in:
Jeffrey Altman 2008-08-27 13:22:10 +00:00
parent c340a15039
commit 731ca21201

View File

@ -742,14 +742,16 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
lock_ObtainWrite(&cm_scacheLock);
if (scp == NULL) {
scp = cm_GetNewSCache(); /* returns scp->rw held */
if (scp == NULL) {
osi_Log0(afsd_logp,"cm_GetSCache unable to obtain *new* scache entry");
lock_ReleaseWrite(&cm_scacheLock);
return CM_ERROR_WOULDBLOCK;
}
} else
lock_ObtainWrite(&scp->rw);
if (scp == NULL) {
osi_Log0(afsd_logp,"cm_GetSCache unable to obtain *new* scache entry");
lock_ReleaseWrite(&cm_scacheLock);
return CM_ERROR_WOULDBLOCK;
}
} else {
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainWrite(&scp->rw);
lock_ObtainWrite(&cm_scacheLock);
}
scp->fid = *fidp;
scp->dotdotFid.cell=AFS_FAKE_ROOT_CELL_ID;
scp->dotdotFid.volume=AFS_FAKE_ROOT_VOL_ID;
@ -778,12 +780,12 @@ long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
scp->bufDataVersionLow=cm_data.fakeDirVersion;
scp->lockDataVersion=-1; /* no lock yet */
lock_ReleaseWrite(&scp->rw);
lock_ReleaseWrite(&cm_scacheLock);
*outScpp = scp;
#ifdef DEBUG_REFCOUNT
afsi_log("%s:%d cm_GetSCache (2) scp 0x%p ref %d", file, line, scp, scp->refCount);
osi_Log1(afsd_logp,"cm_GetSCache (2) scp 0x%p", scp);
#endif
lock_ReleaseWrite(&cm_scacheLock);
return 0;
}
// end of yj code