windows cm_BeginDirOp add flags (nobuildtree)

Add a flags argument to cm_BeginDirOp, and define a flag
CM_DIROP_FLAG_NOBUILDTREE which asserts that the operation
being synchronized does not require scp->dirPlus to be
constructed.

Change-Id: Ibc4345574da3c1e7717c83b64a83260f70a3b06c
Reviewed-on: http://gerrit.openafs.org/2053
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Asanka Herath <asanka@secure-endpoints.com>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Matt Benjamin 2010-05-27 19:14:20 -04:00 committed by Jeffrey Altman
parent 60e5d85fd0
commit 48d3fd9eed
5 changed files with 49 additions and 23 deletions

View File

@ -977,7 +977,7 @@ cm_DirFindItem(cm_dirOp_t * op,
*/
long
cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp,
afs_uint32 lockType, cm_dirOp_t * op)
afs_uint32 lockType, afs_uint32 flags, cm_dirOp_t * op)
{
long code;
int i, mxheld = 0, haveWrite = 0;
@ -1064,7 +1064,8 @@ cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp,
scp->dirDataVersion = CM_SCACHE_VERSION_BAD;
}
if (!scp->dirBplus) {
if ((!scp->dirBplus) &&
(!(flags & CM_DIROP_FLAG_NOBUILDTREE))) {
if (mxheld) {
lock_ReleaseWrite(&scp->rw);
mxheld = 0;
@ -1095,7 +1096,7 @@ cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp,
if (scp->dirBplus)
scp->dirDataVersion = scp->dataVersion;
}
}
} /* build btree */
}
if (code == 0) {

View File

@ -101,10 +101,15 @@ typedef struct cm_dirOpBuffer {
#define CM_DIROPBUFF_INUSE 0x1
/* lock types */
#define CM_DIRLOCK_NONE 0x0
#define CM_DIRLOCK_READ 0x1
#define CM_DIRLOCK_WRITE 0x2
/* flags for cm_dirOp operations */
#define CM_DIROP_FLAG_NONE 0x0000
#define CM_DIROP_FLAG_NOBUILDTREE 0x0001
/* Used for managing transactional directory operations. Each
instance should only be used by one thread. */
typedef struct cm_dirOp {
@ -130,7 +135,7 @@ typedef struct cm_dirOp {
extern long
cm_BeginDirOp(cm_scache_t * scp, cm_user_t * userp, cm_req_t * reqp,
afs_uint32 lockType, cm_dirOp_t * op);
afs_uint32 lockType, afs_uint32 flags, cm_dirOp_t * op);
extern int
cm_CheckDirOpForSingleChange(cm_dirOp_t * op);
@ -187,4 +192,5 @@ extern int
cm_MemDumpDirStats(FILE *outputFile, char *cookie, int lock);
extern afs_uint64 dir_enums;
#endif /* __CM_DIR_ENV__ */

View File

@ -1135,7 +1135,8 @@ cm_IoctlDeleteMountPoint(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scac
lock_ReleaseWrite(&scp->rw);
#ifdef USE_BPLUS
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
code = cm_BPlusDirLookupOriginalName(&dirop, cp, &originalName);
/* The cm_Dir* functions can't be used to lookup the
@ -2265,7 +2266,8 @@ cm_IoctlDeletelink(struct cm_ioctl *ioctlp, struct cm_user *userp, cm_scache_t *
lock_ReleaseWrite(&scp->rw);
#ifdef USE_BPLUS
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
code = cm_BPlusDirLookupOriginalName(&dirop, clientp, &originalName);
/* cm_Dir*() functions can't be used to lookup the original

View File

@ -499,7 +499,8 @@ long cm_ApplyDir(cm_scache_t *scp, cm_DirFuncp_t funcp, void *parmp,
code = ENOENT;
code = cm_BeginDirOp(scp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(scp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
#ifdef USE_BPLUS
@ -1092,7 +1093,8 @@ retry_lookup:
int usedBplus = 0;
#endif
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
#ifdef USE_BPLUS
code = cm_BPlusDirLookup(&dirop, nnamep, &rock.fid);
@ -1592,7 +1594,8 @@ long cm_Unlink(cm_scache_t *dscp, fschar_t *fnamep, clientchar_t * cnamep,
if (fnamep == NULL) {
code = -1;
#ifdef USE_BPLUS
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
code = cm_BPlusDirLookupOriginalName(&dirop, cnamep, &fnamep);
if (code == 0)
@ -1615,7 +1618,8 @@ long cm_Unlink(cm_scache_t *dscp, fschar_t *fnamep, clientchar_t * cnamep,
code = cm_Lookup(dscp, cnamep, CM_FLAG_NOMOUNTCHASE, userp, reqp, &scp);
/* make sure we don't screw up the dir status during the merge */
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &dirop);
lock_ObtainWrite(&dscp->rw);
sflags = CM_SCACHESYNC_STOREDATA;
@ -2802,7 +2806,8 @@ long cm_Create(cm_scache_t *dscp, clientchar_t *cnamep, long flags, cm_attr_t *a
* that someone who does a chmod will know to wait until our call
* completes.
*/
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, CM_DIROP_FLAG_NONE,
&dirop);
lock_ObtainWrite(&dscp->rw);
code = cm_SyncOp(dscp, NULL, userp, reqp, 0, CM_SCACHESYNC_STOREDATA);
lock_ReleaseWrite(&dscp->rw);
@ -2979,7 +2984,8 @@ long cm_MakeDir(cm_scache_t *dscp, clientchar_t *cnamep, long flags, cm_attr_t *
* data, so that someone who does a chmod on the dir will wait until
* our call completes.
*/
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, CM_DIROP_FLAG_NONE,
&dirop);
lock_ObtainWrite(&dscp->rw);
code = cm_SyncOp(dscp, NULL, userp, reqp, 0, CM_SCACHESYNC_STOREDATA);
lock_ReleaseWrite(&dscp->rw);
@ -3101,7 +3107,8 @@ long cm_Link(cm_scache_t *dscp, clientchar_t *cnamep, cm_scache_t *sscp, long fl
return CM_ERROR_CROSSDEVLINK;
}
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, CM_DIROP_FLAG_NONE,
&dirop);
lock_ObtainWrite(&dscp->rw);
code = cm_SyncOp(dscp, NULL, userp, reqp, 0, CM_SCACHESYNC_STOREDATA);
lock_ReleaseWrite(&dscp->rw);
@ -3199,7 +3206,8 @@ long cm_SymLink(cm_scache_t *dscp, clientchar_t *cnamep, fschar_t *contentsp, lo
* so that someone who does a chmod on the dir will wait until our
* call completes.
*/
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, CM_DIROP_FLAG_NONE,
&dirop);
lock_ObtainWrite(&dscp->rw);
code = cm_SyncOp(dscp, NULL, userp, reqp, 0, CM_SCACHESYNC_STOREDATA);
lock_ReleaseWrite(&dscp->rw);
@ -3324,7 +3332,8 @@ long cm_RemoveDir(cm_scache_t *dscp, fschar_t *fnamep, clientchar_t *cnamep, cm_
if (fnamep == NULL) {
code = -1;
#ifdef USE_BPLUS
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
code = cm_BPlusDirLookupOriginalName(&dirop, cnamep, &fnamep);
if (code == 0)
@ -3344,7 +3353,8 @@ long cm_RemoveDir(cm_scache_t *dscp, fschar_t *fnamep, clientchar_t *cnamep, cm_
* so that someone who does a chmod on the dir will wait until our
* call completes.
*/
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, &dirop);
cm_BeginDirOp(dscp, userp, reqp, CM_DIRLOCK_NONE, CM_DIROP_FLAG_NONE,
&dirop);
lock_ObtainWrite(&dscp->rw);
code = cm_SyncOp(dscp, NULL, userp, reqp, 0, CM_SCACHESYNC_STOREDATA);
lock_ReleaseWrite(&dscp->rw);
@ -3523,7 +3533,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
if (oldNamep == NULL) {
code = -1;
#ifdef USE_BPLUS
code = cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_READ, &oldDirOp);
code = cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &oldDirOp);
if (code == 0) {
code = cm_BPlusDirLookupOriginalName(&oldDirOp, cOldNamep, &oldNamep);
if (code == 0)
@ -3554,7 +3565,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
}
oneDir = 1;
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE, &oldDirOp);
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &oldDirOp);
lock_ObtainWrite(&oldDscp->rw);
cm_dnlcRemove(oldDscp, cOldNamep);
cm_dnlcRemove(oldDscp, cNewNamep);
@ -3588,7 +3600,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
}
if (oldDscp->fid.vnode < newDscp->fid.vnode) {
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE, &oldDirOp);
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &oldDirOp);
lock_ObtainWrite(&oldDscp->rw);
cm_dnlcRemove(oldDscp, cOldNamep);
code = cm_SyncOp(oldDscp, NULL, userp, reqp, 0,
@ -3597,7 +3610,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
if (code != 0)
cm_EndDirOp(&oldDirOp);
if (code == 0) {
cm_BeginDirOp(newDscp, userp, reqp, CM_DIRLOCK_NONE, &newDirOp);
cm_BeginDirOp(newDscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &newDirOp);
lock_ObtainWrite(&newDscp->rw);
cm_dnlcRemove(newDscp, cNewNamep);
code = cm_SyncOp(newDscp, NULL, userp, reqp, 0,
@ -3617,7 +3631,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
}
else {
/* lock the new vnode entry first */
cm_BeginDirOp(newDscp, userp, reqp, CM_DIRLOCK_NONE, &newDirOp);
cm_BeginDirOp(newDscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &newDirOp);
lock_ObtainWrite(&newDscp->rw);
cm_dnlcRemove(newDscp, cNewNamep);
code = cm_SyncOp(newDscp, NULL, userp, reqp, 0,
@ -3626,7 +3641,8 @@ long cm_Rename(cm_scache_t *oldDscp, fschar_t *oldNamep, clientchar_t *cOldNamep
if (code != 0)
cm_EndDirOp(&newDirOp);
if (code == 0) {
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE, &oldDirOp);
cm_BeginDirOp(oldDscp, userp, reqp, CM_DIRLOCK_NONE,
CM_DIROP_FLAG_NONE, &oldDirOp);
lock_ObtainWrite(&oldDscp->rw);
cm_dnlcRemove(oldDscp, cOldNamep);
code = cm_SyncOp(oldDscp, NULL, userp, reqp, 0,

View File

@ -518,7 +518,8 @@ NET_API_STATUS NetrShareEnum(
if (ResumeHandle == NULL || *ResumeHandle == 0) {
cm_dirOp_t dirop;
code = cm_BeginDirOp(dscp, userp, &req, CM_DIRLOCK_READ, &dirop);
code = cm_BeginDirOp(dscp, userp, &req, CM_DIRLOCK_READ,
CM_DIROP_FLAG_NONE, &dirop);
if (code == 0) {
code = cm_BPlusDirEnumerate(dscp, userp, &req, TRUE, NULL, TRUE, &enump);
if (code) {