From 48d3fd9eedc122dec2c7b76f97078c56a77af89b Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Thu, 27 May 2010 19:14:20 -0400 Subject: [PATCH] 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 Reviewed-by: Asanka Herath Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_dir.c | 7 +++--- src/WINNT/afsd/cm_dir.h | 8 +++++- src/WINNT/afsd/cm_ioctl.c | 6 +++-- src/WINNT/afsd/cm_vnodeops.c | 48 ++++++++++++++++++++++++------------ src/WINNT/afsd/rpc_srvsvc.c | 3 ++- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/src/WINNT/afsd/cm_dir.c b/src/WINNT/afsd/cm_dir.c index c80f8f0803..f8d545f12d 100644 --- a/src/WINNT/afsd/cm_dir.c +++ b/src/WINNT/afsd/cm_dir.c @@ -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) { diff --git a/src/WINNT/afsd/cm_dir.h b/src/WINNT/afsd/cm_dir.h index cc1b998246..53814eb455 100644 --- a/src/WINNT/afsd/cm_dir.h +++ b/src/WINNT/afsd/cm_dir.h @@ -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__ */ diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c index d321ea3dff..9451a8f216 100644 --- a/src/WINNT/afsd/cm_ioctl.c +++ b/src/WINNT/afsd/cm_ioctl.c @@ -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 diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 19964e3a69..bc2628df23 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -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, diff --git a/src/WINNT/afsd/rpc_srvsvc.c b/src/WINNT/afsd/rpc_srvsvc.c index 0e3d0e40dc..c7af0695bc 100644 --- a/src/WINNT/afsd/rpc_srvsvc.c +++ b/src/WINNT/afsd/rpc_srvsvc.c @@ -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) {