Windows: Freelance vnode,unique pairs

The redirector maintains file object state after the afs
service has shutdown in case it is restarted.  It is critical that
Freelance FIDs not be reused.  Add cm_data.fakeDirVersion into
the mix when generating unique values.

Change-Id: I1cf480d3e0ec6e0b7eadf731a1ef867079c2dc44
Reviewed-on: http://gerrit.openafs.org/5357
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2011-09-03 22:35:43 -04:00 committed by Jeffrey Altman
parent 796684c024
commit 37d72aa156
2 changed files with 21 additions and 10 deletions

View File

@ -231,6 +231,9 @@ void cm_InitFakeRootDir() {
int sizeOfCurEntry;
int dirSize;
/* Increment the fake Uniquifier */
cm_data.fakeUnique++;
/* Reserve 2 directory chunks for "." and ".." */
curChunk += 2;
@ -267,7 +270,7 @@ void cm_InitFakeRootDir() {
fakeEntry.flag = 1;
fakeEntry.length = 0;
fakeEntry.next = 0;
fakeEntry.fid.unique = htonl(1);
fakeEntry.fid.unique = htonl(1 + cm_data.fakeUnique);
// the first page is special, it uses fakeDirHeader instead of fakePageHeader
// we fill up the page with dirEntries that belong there and we make changes
@ -310,7 +313,7 @@ void cm_InitFakeRootDir() {
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
/* enforce the rule that only directories have odd vnode values */
fakeEntry.fid.vnode = htonl((curDirEntry + 1) * 2);
fakeEntry.fid.unique = htonl(curDirEntry + 1);
fakeEntry.fid.unique = htonl(curDirEntry + 1 + cm_data.fakeUnique);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
@ -354,7 +357,7 @@ void cm_InitFakeRootDir() {
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
/* enforce the rule that only directories have odd vnode values */
fakeEntry.fid.vnode = htonl((curDirEntry + 1) * 2);
fakeEntry.fid.unique = htonl(curDirEntry + 1);
fakeEntry.fid.unique = htonl(curDirEntry + 1 + cm_data.fakeUnique);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
@ -504,6 +507,11 @@ int cm_reInitLocalMountPoints() {
static int
cm_enforceTrailingDot(char * line, size_t cchLine, DWORD *pdwSize)
{
if (*pdwSize < 4) {
afsi_log("invalid string");
return 0;
}
/* trailing white space first. */
if (line[(*pdwSize)-1] == '\0') {
while (isspace(line[(*pdwSize)-2])) {
@ -1516,8 +1524,9 @@ cm_FreelanceFetchMountPointString(cm_scache_t *scp)
if (!scp->mountPointStringp[0] &&
scp->fid.cell == AFS_FAKE_ROOT_CELL_ID &&
scp->fid.volume == AFS_FAKE_ROOT_VOL_ID &&
scp->fid.unique <= cm_noLocalMountPoints) {
strncpy(scp->mountPointStringp, cm_localMountPoints[scp->fid.unique-1].mountPointStringp, MOUNTPOINTLEN);
(afs_int32)(scp->fid.unique - cm_data.fakeUnique) - 1 >= 0 &&
scp->fid.unique - cm_data.fakeUnique <= cm_noLocalMountPoints) {
strncpy(scp->mountPointStringp, cm_localMountPoints[scp->fid.unique-cm_data.fakeUnique-1].mountPointStringp, MOUNTPOINTLEN);
scp->mountPointStringp[MOUNTPOINTLEN-1] = 0; /* null terminate */
}
lock_ReleaseMutex(&cm_Freelance_Lock);
@ -1531,12 +1540,13 @@ cm_FreelanceFetchFileType(cm_scache_t *scp)
lock_ObtainMutex(&cm_Freelance_Lock);
if (scp->fid.cell == AFS_FAKE_ROOT_CELL_ID &&
scp->fid.volume == AFS_FAKE_ROOT_VOL_ID &&
scp->fid.unique <= cm_noLocalMountPoints)
(afs_int32)(scp->fid.unique - cm_data.fakeUnique) - 1 >= 0 &&
scp->fid.unique - cm_data.fakeUnique <= cm_noLocalMountPoints)
{
scp->fileType = cm_localMountPoints[scp->fid.unique-1].fileType;
scp->fileType = cm_localMountPoints[scp->fid.unique-cm_data.fakeUnique-1].fileType;
if ( scp->fileType == CM_SCACHETYPE_SYMLINK &&
!strnicmp(cm_localMountPoints[scp->fid.unique-1].mountPointStringp, "msdfs:", strlen("msdfs:")) )
if (scp->fileType == CM_SCACHETYPE_SYMLINK &&
!strnicmp(cm_localMountPoints[scp->fid.unique-cm_data.fakeUnique-1].mountPointStringp, "msdfs:", strlen("msdfs:")) )
{
scp->fileType = CM_SCACHETYPE_DFSLINK;
}

View File

@ -10,7 +10,7 @@
#ifndef CM_MEMMAP_H
#define CM_MEMMAP_H 1
#define CM_CONFIG_DATA_VERSION 15
#define CM_CONFIG_DATA_VERSION 16
#define CM_CONFIG_DATA_MAGIC ('A' | 'F'<<8 | 'S'<<16 | CM_CONFIG_DATA_VERSION<<24)
typedef struct cm_config_data {
@ -49,6 +49,7 @@ typedef struct cm_config_data {
cm_scache_t * rootSCachep;
cm_scache_t fakeSCache;
afs_uint64 fakeDirVersion;
afs_uint32 fakeUnique;
cm_aclent_t * aclLRUp;
cm_aclent_t * aclLRUEndp;