]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Back out the unix VFS changes that seeks to avoid fstat() calls after an
authordrh <drh@noemail.net>
Mon, 16 Jun 2014 16:41:52 +0000 (16:41 +0000)
committerdrh <drh@noemail.net>
Mon, 16 Jun 2014 16:41:52 +0000 (16:41 +0000)
unlink().  That change did not clear the problem on FuseFS.

FossilOrigin-Name: 0617e20a33e08754aea14e60db44e557c13978e3

manifest
manifest.uuid
src/os_unix.c

index bad340afd29790c89772246f13eaff7ed7f9e957..303bdc8a7741b2084e360678d5ec373bfa57afb4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\s".eqp"\sdot-command\sto\sthe\s".help"\soutput\sin\sthe\scommand-line\sshell.\nThis\swas\saccidently\somitted\swhen\sthe\s".eqp"\scommand\swas\soriginally\simplemented\nfor\sSQLite\s3.8.4\s(check-in\s[e6ecf7337658624]).
-D 2014-06-16T15:01:37.512
+C Back\sout\sthe\sunix\sVFS\schanges\sthat\sseeks\sto\savoid\sfstat()\scalls\safter\san\nunlink().\s\sThat\schange\sdid\snot\sclear\sthe\sproblem\son\sFuseFS.
+D 2014-06-16T16:41:52.046
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in ed5e4aae4799f724699d5509fac2977786414dbb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -207,7 +207,7 @@ F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace
 F src/os.h 60d419395e32a8029fa380a80a3da2e9030f635e
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_setup.h c9d4553b5aaa6f73391448b265b89bed0b890faa
-F src/os_unix.c 89be80af5141624fe432f51bfebdc826ec4d0d4f
+F src/os_unix.c ae4b5240af4619d711301d7992396e182585269f
 F src/os_win.c 8dbf6c11780fe2eb96c1f289e664d0c7b2911d37
 F src/os_win.h 057344a6720b4c8405d9bd98f58cb37a6ee46c25
 F src/pager.c f6bb1fa6cdf2062f2d8aec3e64db302bca519ab8
@@ -1177,7 +1177,8 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P baf95a190907d05a847ae8b6a3dd60625c2a078a
-R 77392df379cf094587c415a5e52c867e
+P b0b4c776c321ca4a792ef67efbc62351eeac247d
+Q -10707d35786403ea5392d980f593bfecdae063dd
+R e96aeed73bec47c3b8abfdb2818e21e8
 U drh
-Z c37a319047179d2f3f16508cbd16fb41
+Z a60331639ee1b0609616a92f467c0973
index 31c88868b8204d6e3ffa08688e81657e12bf7ede..c80c92195132159609355bb5b73e91b86fb62333 100644 (file)
@@ -1 +1 @@
-b0b4c776c321ca4a792ef67efbc62351eeac247d
\ No newline at end of file
+0617e20a33e08754aea14e60db44e557c13978e3
\ No newline at end of file
index 72d04e670dee8bf5214ee892376dfd2801f272ef..fc320a4926f26c8565c51e4acd5c8b4d7239cb74 100644 (file)
@@ -191,7 +191,6 @@ struct unixFile {
   UnixUnusedFd *pUnused;              /* Pre-allocated UnixUnusedFd */
   const char *zPath;                  /* Name of the file */
   unixShm *pShm;                      /* Shared memory segment information */
-  sqlite3_int64 szFile;               /* File size for UNIXFILE_DELETE files */
   int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
 #if SQLITE_MAX_MMAP_SIZE>0
   int nFetchOut;                      /* Number of outstanding xFetch refs */
@@ -1322,11 +1321,9 @@ static int fileHasMoved(unixFile *pFile){
 static void verifyDbFile(unixFile *pFile){
   struct stat buf;
   int rc;
-  if( pFile->ctrlFlags & (UNIXFILE_WARNED|UNIXFILE_DELETE) ){
-    /* UNIXFILE_WARNED means that one or more of the following warnings have
-    ** already been issued.  Do not* repeat them so as not to clutter the error
-    ** log.  Do not investigate unlinked files since fstat() does not always
-    ** work following an unlink(). */
+  if( pFile->ctrlFlags & UNIXFILE_WARNED ){
+    /* One or more of the following warnings have already been issued.  Do not
+    ** repeat them so as not to clutter the error log */
     return;
   }
   rc = osFstat(pFile->h, &buf);
@@ -1335,7 +1332,7 @@ static void verifyDbFile(unixFile *pFile){
     pFile->ctrlFlags |= UNIXFILE_WARNED;
     return;
   }
-  if( buf.st_nlink==0 ){
+  if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
     sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
     pFile->ctrlFlags |= UNIXFILE_WARNED;
     return;
@@ -3284,10 +3281,6 @@ static int unixWrite(
   assert( id );
   assert( amt>0 );
 
-  /* Update the internally tracked file size.  The internal file size is only
-  ** accurate for unlinked files */
-  if( offset+amt>pFile->szFile ) pFile->szFile = offset+amt;
-
   /* If this is a database file (not a journal, master-journal or temp
   ** file), the bytes in the locking range should never be read or written. */
 #if 0
@@ -3628,7 +3621,6 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
     }
 #endif
 
-    pFile->szFile = nByte;
     return SQLITE_OK;
   }
 }
@@ -3638,27 +3630,12 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
 */
 static int unixFileSize(sqlite3_file *id, i64 *pSize){
   int rc;
-  unixFile *pFile = (unixFile*)id;
   struct stat buf;
-  assert( pFile );
-
-  /* For files that have been unlinked, simply return the szFile which we keep
-  ** track of internally.  There is no need to fstat() as SQLite has exclusive
-  ** access to the file and no other process can modify the file and thus change
-  ** the file size without our knowing it.  We do this because fstat() will
-  ** fail on unlinked files on some (broken) unix filesystems.
-  */
-  if( pFile->ctrlFlags & UNIXFILE_DELETE ){
-    *pSize = pFile->szFile;
-    /* The following assert() confirms that the internal filesize is correct */
-    assert( osFstat(pFile->h, &buf)!=0 || buf.st_size==pFile->szFile );
-    return SQLITE_OK;
-  }
-
-  rc = osFstat(pFile->h, &buf);
+  assert( id );
+  rc = osFstat(((unixFile*)id)->h, &buf);
   SimulateIOError( rc=1 );
   if( rc!=0 ){
-    pFile->lastErrno = errno;
+    ((unixFile*)id)->lastErrno = errno;
     return SQLITE_IOERR_FSTAT;
   }
   *pSize = buf.st_size;
@@ -3694,7 +3671,6 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
     i64 nSize;                    /* Required file size */
     struct stat buf;              /* Used to hold return values of fstat() */
    
-    if( pFile->ctrlFlags & UNIXFILE_DELETE ) return SQLITE_OK;
     if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
 
     nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -4243,7 +4219,6 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
   if( p==0 ) return SQLITE_NOMEM;
   memset(p, 0, sizeof(*p));
   assert( pDbFd->pShm==0 );
-  assert( (pDbFd->ctrlFlags & UNIXFILE_DELETE)==0 );
 
   /* Check to see if a unixShmNode object already exists. Reuse an existing
   ** one if present. Create a new one if necessary.
@@ -4790,7 +4765,6 @@ static void unixRemapfile(
   }
   pFd->pMapRegion = (void *)pNew;
   pFd->mmapSize = pFd->mmapSizeActual = nNew;
-  if( nNew>pFd->szFile ) pFd->szFile = nNew;
 }
 
 /*
@@ -4817,10 +4791,12 @@ static int unixMapfile(unixFile *pFd, i64 nByte){
   if( pFd->nFetchOut>0 ) return SQLITE_OK;
 
   if( nMap<0 ){
-    rc = unixFileSize((sqlite3_file*)pFd, &nMap);
+    struct stat statbuf;          /* Low-level file information */
+    rc = osFstat(pFd->h, &statbuf);
     if( rc!=SQLITE_OK ){
       return SQLITE_IOERR_FSTAT;
     }
+    nMap = statbuf.st_size;
   }
   if( nMap>pFd->mmapSizeMax ){
     nMap = pFd->mmapSizeMax;
@@ -5794,7 +5770,6 @@ static int unixOpen(
   }
 
   if( isDelete ){
-    assert( p->szFile==0 );
 #if OS_VXWORKS
     zPath = zName;
 #else