ObtainWriteLock(&afs_xdcache, 758);
for (index = afs_dvhashTbl[i]; index != NULLIDX;) {
if (afs_indexUnique[index] == afid->Fid.Unique) {
- tdc = afs_GetDSlot(index);
- ReleaseReadLock(&tdc->tlock);
- if (!FidCmp(&tdc->f.fid, afid)) {
- break; /* leaving refCount high for caller */
- }
- afs_PutDCache(tdc);
+ tdc = afs_GetValidDSlot(index);
+ if (!tdc) {
+ index = NULLIDX;
+ break;
+ }
+ ReleaseReadLock(&tdc->tlock);
+ if (!FidCmp(&tdc->f.fid, afid)) {
+ break; /* leaving refCount high for caller */
+ }
+ afs_PutDCache(tdc);
}
index = afs_dvnextTbl[index];
}
parent_vc = afs_FindVCache(&parent_fid, 0, 1);
ReleaseSharedLock(&afs_xvcache);
if (!parent_vc) {
- return ENOENT;
+ return ENETDOWN;
}
shadow_fid.Cell = parent_vc->f.fid.Cell;
code = ENOENT;
} else {
/* printf("Directory dcache not found!\n"); */
- code = ENOENT;
+ code = ENETDOWN;
}
return code;
if (afs_GetParentDirFid(avc, afid)) {
/* printf("afs_GetParentVCache: Couldn't find parent dir's FID.\n"); */
- return ENOENT;
+ return ENETDOWN;
}
code = afs_GetVnodeName(avc, afid, aname, deleted);
ReleaseSharedLock(&afs_xvcache);
if (!*adp) {
/* printf("afs_GetParentVCache: Couldn't find parent dir's vcache\n"); */
- code = ENOENT;
+ code = ENETDOWN;
goto end;
}
/* Get parent dir's FID.*/
if (afs_GetParentDirFid(avc, &new_pdir_fid)) {
/* printf("afs_ProcessOpRename: Couldn't find new parent dir FID.\n"); */
- code = ENOENT;
+ code = ENETDOWN;
goto done;
}
}
tname = afs_osi_Alloc(AFSNAMEMAX);
if (!tname)
return ENOMEM;
+ memset(&InStatus, 0, sizeof(InStatus));
code = afs_GetParentVCache(avc, 0, &pdir_fid, tname, &tdp);
if (code)
tdc = afs_GetDCache(avc, 0, areq, &offset, &tlen, 0);
if (!tdc) {
- code = ENOENT;
+ code = ENETDOWN;
goto end;
}
ttargetName = afs_osi_Alloc(tlen);
if (!ttargetName) {
afs_PutDCache(tdc);
- return ENOMEM;
+ code = ENOMEM;
+ goto end;
}
ObtainReadLock(&tdc->lock);
tfile = afs_CFileOpen(&tdc->f.inode);
+ if (!tfile) {
+ ReleaseReadLock(&tdc->lock);
+ afs_PutDCache(tdc);
+ code = EIO;
+ goto end;
+ }
code = afs_CFileRead(tfile, 0, ttargetName, tlen);
ttargetName[tlen-1] = '\0';
afs_CFileClose(tfile);
ObtainWriteLock(&afs_xdcache, 743);
for (index = afs_dvhashTbl[hash]; index != NULLIDX; index = hash) {
hash = afs_dvnextTbl[index];
- tdc = afs_GetDSlot(index);
+ tdc = afs_GetValidDSlot(index);
+ if (!tdc) {
+ ReleaseWriteLock(&afs_xdcache);
+ code = EIO;
+ goto end;
+ }
ReleaseReadLock(&tdc->tlock);
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
memcpy(&tdc->f.fid, &newFid, sizeof(struct VenusFid));
} /* if fid match */
} /* if uniquifier match */
- if (tdc)
- afs_PutDCache(tdc);
+ afs_PutDCache(tdc);
} /* for all dcaches in this hash bucket */
ReleaseWriteLock(&afs_xdcache);
tvc->f.ddirty_flags &= ~VDisconCreate;
tvc->f.ddirty_flags |= VDisconCreated;
}
-#if 0
- /* Get server write lock. */
- do {
- tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn);
- if (tc) {
- XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK);
- RX_AFS_GUNLOCK();
- code = RXAFS_SetLock(rxconn,
- (struct AFSFid *)&tvc->f.fid.Fid,
- LockWrite,
- &tsync);
- RX_AFS_GLOCK();
- XSTATS_END_TIME;
- } else
- code = -1;
-
- } while (afs_Analyze(tc,
- rxconn,
- code,
- &tvc->f.fid,
- areq,
- AFS_STATS_FS_RPCIDX_SETLOCK,
- SHARED_LOCK,
- NULL));
-
- if (code)
- goto next_file;
-#endif
if (tvc->f.ddirty_flags & VDisconRename) {
/* If we're renaming the file, do so now */
code = afs_ProcessOpRename(tvc, areq);
} else if (afs_ConflictPolicy == SERVER_WINS) {
/* DV mismatch, apply collision resolution policy. */
/* Discard this files chunks and remove from current dir. */
- afs_ResetVCache(tvc, acred);
+ afs_ResetVCache(tvc, acred, 0);
tvc->f.truncPos = AFS_NOTRUNC;
} else {
/* printf("afs_ResyncDisconFiles: no resolution policy selected.\n"); */
} /* if DV match or client wins policy */
unlock_srv_file:
- /* Release server write lock. */
-#if 0
- do {
- tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn);
- if (tc) {
- XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK);
- RX_AFS_GUNLOCK();
- ucode = RXAFS_ReleaseLock(rxconn,
- (struct AFSFid *) &tvc->f.fid.Fid,
- &tsync);
- RX_AFS_GLOCK();
- XSTATS_END_TIME;
- } else
- ucode = -1;
- } while (afs_Analyze(tc,
- rxconn,
- ucode,
- &tvc->f.fid,
- areq,
- AFS_STATS_FS_RPCIDX_RELEASELOCK,
- SHARED_LOCK,
- NULL));
-#endif
+ /* If we ever lock files while replaying changes, we should unlock the
+ * file here. */
+
next_file:
ObtainWriteLock(&afs_disconDirtyLock, 710);
if (code == 0) {
ObtainWriteLock(&tvc->lock, 706);
if (squash)
- afs_ResetVCache(tvc, acred);
+ afs_ResetVCache(tvc, acred, 0);
afs_DeleteShadowDir(tvc);
ReleaseWriteLock(&afs_disconDirtyLock);
ObtainWriteLock(&tvc->lock, 718);
- afs_ResetVCache(tvc, acred);
+ afs_ResetVCache(tvc, acred, 0);
tvc->f.truncPos = AFS_NOTRUNC;
ReleaseWriteLock(&tvc->lock);
ObtainWriteLock(&afs_disconDirtyLock, 719);
struct VenusFid *afid, struct vattr *attrs,
struct vrequest *areq, int file_type)
{
+ afs_hyper_t zero;
memcpy(&avc->f.fid, afid, sizeof(struct VenusFid));
avc->f.m.Mode = attrs->va_mode;
/* Used to do this:
*/
avc->f.m.Group = adp->f.m.Group;
avc->f.m.Owner = adp->f.m.Owner;
- hset64(avc->f.m.DataVersion, 0, 0);
+ hzero(zero);
+ afs_SetDataVersion(avc, &zero);
avc->f.m.Length = attrs->va_size;
avc->f.m.Date = osi_Time();
switch(file_type) {
vSetType(avc, VLNK);
avc->f.m.Mode |= S_IFLNK;
if ((avc->f.m.Mode & 0111) == 0)
- avc->mvstat = 1;
+ avc->mvstat = AFS_MVSTAT_MTPT;
avc->f.parent.vnode = adp->f.fid.Fid.Vnode;
avc->f.parent.unique = adp->f.fid.Fid.Unique;
break;