Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a compressed database mode bug. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | prefix-mmap |
Files: | files | file ages | folders |
SHA1: |
84e9aca2455b73e4939a1e2fd43b5a25 |
User & Date: | dan 2013-03-07 19:54:38.118 |
Context
2013-03-07
| ||
20:12 | Fix some test cases to account for sqlite4 memory mapping the file. Leaf check-in: 5f9133f8a8 user: dan tags: prefix-mmap | |
19:54 | Fix a compressed database mode bug. check-in: 84e9aca245 user: dan tags: prefix-mmap | |
18:36 | When recycling an lsm cursor, reset the flags field. check-in: 4d830d87e4 user: dan tags: prefix-mmap | |
Changes
Changes to src/lsm_file.c.
︙ | ︙ | |||
241 242 243 244 245 246 247 | /* Page cache parameters for non-mmap() pages */ int nCacheMax; /* Configured cache size (in pages) */ int nCacheAlloc; /* Current cache size (in pages) */ Page *pLruFirst; /* Head of the LRU list */ Page *pLruLast; /* Tail of the LRU list */ int nHash; /* Number of hash slots in hash table */ Page **apHash; /* nHash Hash slots */ | < < | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | /* Page cache parameters for non-mmap() pages */ int nCacheMax; /* Configured cache size (in pages) */ int nCacheAlloc; /* Current cache size (in pages) */ Page *pLruFirst; /* Head of the LRU list */ Page *pLruLast; /* Tail of the LRU list */ int nHash; /* Number of hash slots in hash table */ Page **apHash; /* nHash Hash slots */ Page *pWaiting; /* b-tree pages waiting to be written */ /* Statistics */ int nOut; /* Number of outstanding pages */ int nWrite; /* Total number of pages written */ int nRead; /* Total number of pages read */ }; |
︙ | ︙ | |||
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 | iHash = fsHashKey(pFS->nHash, pPg->iPg); for(pp=&pFS->apHash[iHash]; *pp!=pPg; pp=&(*pp)->pHashNext); *pp = pPg->pHashNext; pPg->pHashNext = 0; } /* ** Purge the cache of all non-mmap pages with nRef==0. */ void lsmFsPurgeCache(FileSystem *pFS){ Page *pPg; pPg = pFS->pLruFirst; while( pPg ){ Page *pNext = pPg->pLruNext; assert( pPg->flags & PAGE_FREE ); fsPageRemoveFromHash(pFS, pPg); | > > > > > > < | < | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 | iHash = fsHashKey(pFS->nHash, pPg->iPg); for(pp=&pFS->apHash[iHash]; *pp!=pPg; pp=&(*pp)->pHashNext); *pp = pPg->pHashNext; pPg->pHashNext = 0; } static void fsPageBufferFree(Page *pPg){ pPg->pFS->nCacheAlloc--; lsmFree(pPg->pFS->pEnv, pPg->aData); lsmFree(pPg->pFS->pEnv, pPg); } /* ** Purge the cache of all non-mmap pages with nRef==0. */ void lsmFsPurgeCache(FileSystem *pFS){ Page *pPg; pPg = pFS->pLruFirst; while( pPg ){ Page *pNext = pPg->pLruNext; assert( pPg->flags & PAGE_FREE ); fsPageRemoveFromHash(pFS, pPg); fsPageBufferFree(pPg); pPg = pNext; } pFS->pLruFirst = 0; pFS->pLruLast = 0; assert( pFS->nCacheAlloc<=pFS->nOut && pFS->nCacheAlloc>=0 ); } |
︙ | ︙ | |||
1060 1061 1062 1063 1064 1065 1066 | if( pPage ){ pPage->flags = PAGE_FREE; } *ppOut = pPage; return rc; } | < < < < < < < < < < | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 | if( pPage ){ pPage->flags = PAGE_FREE; } *ppOut = pPage; return rc; } static void fsGrowMapping( FileSystem *pFS, i64 iSz, int *pRc ){ /* This function won't work with compressed databases yet. */ assert( pFS->pCompress==0 ); |
︙ | ︙ |
Changes to src/lsm_unix.c.
︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | lsm_i64 *pnOut ){ off_t iSz; int prc; PosixFile *p = (PosixFile *)pFile; struct stat buf; if( p->pMap ){ munmap(p->pMap, p->nMap); *ppOut = p->pMap = 0; *pnOut = p->nMap = 0; } if( iMin>=0 ){ memset(&buf, 0, sizeof(buf)); prc = fstat(p->fd, &buf); if( prc!=0 ) return LSM_IOERR_BKPT; iSz = buf.st_size; if( iSz<iMin ){ | > > > > > | | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | lsm_i64 *pnOut ){ off_t iSz; int prc; PosixFile *p = (PosixFile *)pFile; struct stat buf; /* If the file is between 0 and 2MB in size, extend it in chunks of 256K. ** Thereafter, in chunks of 1MB at a time. */ const int aIncrSz[] = {256*1024, 1024*1024}; int nIncrSz = aIncrSz[iMin>(2*1024*1024)]; if( p->pMap ){ munmap(p->pMap, p->nMap); *ppOut = p->pMap = 0; *pnOut = p->nMap = 0; } if( iMin>=0 ){ memset(&buf, 0, sizeof(buf)); prc = fstat(p->fd, &buf); if( prc!=0 ) return LSM_IOERR_BKPT; iSz = buf.st_size; if( iSz<iMin ){ iSz = ((iMin + nIncrSz-1) / nIncrSz) * nIncrSz; prc = ftruncate(p->fd, iSz); if( prc!=0 ) return LSM_IOERR_BKPT; } p->pMap = mmap(0, iSz, PROT_READ|PROT_WRITE, MAP_SHARED, p->fd, 0); p->nMap = iSz; } |
︙ | ︙ |