From d4e66ef219c88cdb17f2e860027cf6752ea21b17 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 22 Apr 2010 22:24:11 +0100 Subject: [PATCH] Unix: Modify disk cache versioning This change increments the disk cache version number, and adds a structure size record to the disk cache header. All old disk caches will be replaced when the client is started. With the various changes made to unify our file handles, and to support large file handles on Linux, the size of the 'fcache' structure was modified earlier in the 1.5 series. However, fcache is also the building block of the CacheItems file, so these changes inadvertently broke users upgrading from 1.4. In addition, as the disk cache inode is now a union of many different structures, the structure size is now potentially volatile across both kernel, and OpenAFS revisions. Up the version number so old disk caches are invalidated and won't crash users who are upgrading. Also take the opportunity to add an item to the header which stores the size of struct fcache used by the disk cache. If the size on disk doesn't match that expected by the kernel module, truncate the cache and start again. Change-Id: I2ee8863d0bfaaaba34272c9e139638e17669a53e Reviewed-on: http://gerrit.openafs.org/1811 Reviewed-by: Andrew Deason Reviewed-by: Marc Dionne Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/afs.h | 7 ++----- src/afs/afs_dcache.c | 1 + src/afs/afs_init.c | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/afs/afs.h b/src/afs/afs.h index 2a43b9e03..5ff445e09 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -1052,12 +1052,9 @@ struct afs_ioctl32 { struct afs_fheader { #define AFS_FHMAGIC 0x7635abaf /* uses version number */ afs_int32 magic; -#if defined(AFS_SUN57_64BIT_ENV) -#define AFS_CI_VERSION 3 -#else -#define AFS_CI_VERSION 2 -#endif +#define AFS_CI_VERSION 4 afs_int32 version; + afs_uint32 dataSize; afs_int32 firstCSize; afs_int32 otherCSize; }; diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 03c837517..9d2bf48d5 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -2551,6 +2551,7 @@ afs_WriteThroughDSlots(void) theader.firstCSize = AFS_FIRSTCSIZE; theader.otherCSize = AFS_OTHERCSIZE; theader.version = AFS_CI_VERSION; + theader.dataSize = sizeof(struct fcache); afs_osi_Write(afs_cacheInodep, 0, &theader, sizeof(theader)); } ReleaseWriteLock(&afs_xdcache); diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c index 70394333d..90f967a63 100644 --- a/src/afs/afs_init.c +++ b/src/afs/afs_init.c @@ -488,6 +488,7 @@ afs_InitCacheInfo(register char *afile) if (theader.magic == AFS_FHMAGIC && theader.firstCSize == AFS_FIRSTCSIZE && theader.otherCSize == AFS_OTHERCSIZE + && theader.dataSize == sizeof(struct fcache) && theader.version == AFS_CI_VERSION) goodFile = 1; } @@ -496,6 +497,7 @@ afs_InitCacheInfo(register char *afile) theader.magic = AFS_FHMAGIC; theader.firstCSize = AFS_FIRSTCSIZE; theader.otherCSize = AFS_OTHERCSIZE; + theader.dataSize = sizeof(struct fcache); theader.version = AFS_CI_VERSION; afs_osi_Write(tfile, 0, &theader, sizeof(theader)); /* -- 2.39.5