]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
While doing a transaction comment, use fdatasync() instead of fsync() in
authordrh <drh@noemail.net>
Thu, 8 Sep 2005 12:38:41 +0000 (12:38 +0000)
committerdrh <drh@noemail.net>
Thu, 8 Sep 2005 12:38:41 +0000 (12:38 +0000)
cases there the file size is unchanged. (CVS 2673)

FossilOrigin-Name: 3c555a87493128620ac967faf7c63c2a58856e9e

manifest
manifest.uuid
src/os.h
src/os_test.c
src/os_unix.c
src/os_win.c
src/pager.c
src/vdbeaux.c

index 60a7e3cad43df765d3a2003836dcf20c2dafd6b8..99acbf2b494dcabe001e7fc76a595ce149d147a1 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sanother\stest\sto\saccount\sfor\sSUM()\sreturning\sinteger\srather\sthan\sfloat.\s(CVS\s2672)
-D 2005-09-08T12:37:29
+C While\sdoing\sa\stransaction\scomment,\suse\sfdatasync()\sinstead\sof\sfsync()\sin\ncases\sthere\sthe\sfile\ssize\sis\sunchanged.\s(CVS\s2673)
+D 2005-09-08T12:38:42
 F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -48,15 +48,15 @@ F src/insert.c 484c73bc1309f283a31baa0e114f3ee980536397
 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b
 F src/main.c bf88855445d365b497070d85e3faa0579a9edb91
 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
-F src/os.h c4b34bd4d6fea51a420f337468b907f4edecb161
+F src/os.h c9fd9f92f176a5ea22e0101fcc1e85d532844dd1
 F src/os_common.h 0e7f428ba0a6c40a61bc56c4e96f493231301b73
-F src/os_test.c 91e5f22dd89491e5e1554820e715805f43fa4ece
+F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c cbdac6b207295ebc528e00ca9f0d48084c8f8b8b
+F src/os_unix.c 4838fab463f7753cfa5f605091eb017eb3664600
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
-F src/os_win.c 4aad6cd49a2a546f945491a9e6a0b7d061cf47c5
+F src/os_win.c 6a80f6864cab2256a8e52b98f79d4e15a4b6004e
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c cd9896287a8fd33cc267bd0c2b69c421a4808169
+F src/pager.c bf7e0df511e4cd752f56a7fb24b23383f6e35782
 F src/pager.h 17b13225abd93c1e9f470060f40a21b9edb5a164
 F src/parse.y 4c0cf6b0646166b232693249b89e32a75c6f87d7
 F src/pragma.c 69413fbdc0c6aaa493a776ea52c1b3e6cf35dfb2
@@ -84,7 +84,7 @@ F src/vdbe.c 1caa73395943e20c61cde11deedf05cb37847f87
 F src/vdbe.h c8e105979fc7aaf5b8004e9621904e3bd096dfa2
 F src/vdbeInt.h 3dd2a29c7b0a55404c35f93caae81fb42f4cb70a
 F src/vdbeapi.c 6df708808458df837100521be72e728a581b5206
-F src/vdbeaux.c 11db0de973c850bb5d92c67af1c8f3c189f08741
+F src/vdbeaux.c a0aaf135c39825027366b5129f85191226d8b333
 F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
 F src/vdbemem.c e1da6b772e8a05e95ede8eb6f2f6d0ef4f2e1034
 F src/where.c 92ab208abe6bec15e81616b8c1a619be23ece506
@@ -306,7 +306,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 73fbb8d9689fecec18c36814e4358e691bcd647e
-R efbf84a8c26377be65ab30504e6faebd
+P bc723235e65eb4da7d2e4b18653f1173374cb407
+R 07bc4f21cf6f17d7905a2bca119ba6c3
 U drh
-Z 7134e07faaeb6a9d1ebc715293e50060
+Z 65f2e95a5335cb7bacc36cdf222b2679
index 3c7938504ea1503167aca1310065bc8bc0469a98..ec01b77db1b47db34a50ae525f1cc728908c058d 100644 (file)
@@ -1 +1 @@
-bc723235e65eb4da7d2e4b18653f1173374cb407
\ No newline at end of file
+3c555a87493128620ac967faf7c63c2a58856e9e
\ No newline at end of file
index 4854964fbef9819ff26689762eabb35276f4ae1c..c0d1efe5ce20e19eab885f3830ed0940c7d33013 100644 (file)
--- a/src/os.h
+++ b/src/os.h
@@ -181,7 +181,7 @@ int sqlite3OsClose(OsFile*);
 int sqlite3OsRead(OsFile*, void*, int amt);
 int sqlite3OsWrite(OsFile*, const void*, int amt);
 int sqlite3OsSeek(OsFile*, i64 offset);
-int sqlite3OsSync(OsFile*);
+int sqlite3OsSync(OsFile*, int);
 int sqlite3OsTruncate(OsFile*, i64 size);
 int sqlite3OsFileSize(OsFile*, i64 *pSize);
 char *sqlite3OsFullPathname(const char*);
index 8199f5b18327af8eeac7008d344dacaf275d711d..9b1c0e206f7bb56ebd9f0a73eefd157fa1875d9e 100644 (file)
@@ -391,12 +391,12 @@ int sqlite3OsWrite(OsFile *id, const void *pBuf, int amt){
 ** Sync the file. First flush the write-cache to disk, then call the
 ** real sync() function.
 */
-int sqlite3OsSync(OsFile *id){
+int sqlite3OsSync(OsFile *id, int dataOnly){
   int rc;
   /* printf("SYNC %s (%d blocks)\n", (*id)->zName, (*id)->nBlk); */
   rc = writeCache(*id);
   if( rc!=SQLITE_OK ) return rc;
-  rc = sqlite3RealSync(&(*id)->fd);
+  rc = sqlite3RealSync(&(*id)->fd, dataOnly);
   return rc;
 }
 
index edc22af00f1d2d04bf12628d83e7c9b905823eae..2f2303173c30cd58a8b924c6b73b8ed8f80029d4 100644 (file)
@@ -797,7 +797,7 @@ int sqlite3_fullsync_count = 0;
 ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash
 ** or power failure will likely corrupt the database file.
 */
-static int full_fsync(int fd, int fullSync){
+static int full_fsync(int fd, int fullSync, int dataOnly){
   int rc;
 
   /* Record the number of times that we do a normal fsync() and 
@@ -826,7 +826,11 @@ static int full_fsync(int fd, int fullSync){
   if( rc ) rc = fsync(fd);
 
 #else
-  rc = fsync(fd);
+  if( dataOnly ){
+    rc = fdatasync(fd);
+  }else{
+    rc = fsync(fd);
+  }
 #endif /* defined(F_FULLFSYNC) */
 #endif /* defined(SQLITE_NO_SYNC) */
 
@@ -836,6 +840,10 @@ static int full_fsync(int fd, int fullSync){
 /*
 ** Make sure all writes to a particular file are committed to disk.
 **
+** If dataOnly==0 then both the file itself and its metadata (file
+** size, access time, etc) are synced.  If dataOnly!=0 then only the
+** file data is synced.
+**
 ** Under Unix, also make sure that the directory entry for the file
 ** has been created by fsync-ing the directory that contains the file.
 ** If we do not do this and we encounter a power failure, the directory
@@ -844,16 +852,16 @@ static int full_fsync(int fd, int fullSync){
 ** the directory entry for the journal was never created) and the transaction
 ** will not roll back - possibly leading to database corruption.
 */
-int sqlite3OsSync(OsFile *id){
+int sqlite3OsSync(OsFile *id, int dataOnly){
   assert( id->isOpen );
   SimulateIOError(SQLITE_IOERR);
   TRACE2("SYNC    %-3d\n", id->h);
-  if( full_fsync(id->h, id->fullSync) ){
+  if( full_fsync(id->h, id->fullSync, dataOnly) ){
     return SQLITE_IOERR;
   }
   if( id->dirfd>=0 ){
     TRACE2("DIRSYNC %-3d\n", id->dirfd);
-    full_fsync(id->dirfd, id->fullSync);
+    full_fsync(id->dirfd, id->fullSync, 0);
     close(id->dirfd);  /* Only need to sync once, so close the directory */
     id->dirfd = -1;    /* when we are done. */
   }
index c5f6bd933fd4466c005640e27ad0ce0842e077df..8639ef2db077a86a4d3139d0ed4b254d63788dac 100644 (file)
@@ -482,7 +482,7 @@ int sqlite3OsSeek(OsFile *id, i64 offset){
 /*
 ** Make sure all writes to a particular file are committed to disk.
 */
-int sqlite3OsSync(OsFile *id){
+int sqlite3OsSync(OsFile *id, int dataOnly){
   assert( id->isOpen );
   TRACE3("SYNC %d lock=%d\n", id->h, id->locktype);
   if( FlushFileBuffers(id->h) ){
index 6cd35d43999e1cd9d2e231b423bd32bbd6967957..9b852385bd389f4ed04b9bcfd3d77a6cf13373bc 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.210 2005/08/27 16:36:49 drh Exp $
+** @(#) $Id: pager.c,v 1.211 2005/09/08 12:38:42 drh Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -2121,7 +2121,7 @@ static int syncJournal(Pager *pPager){
         */
         if( pPager->fullSync ){
           TRACE2("SYNC journal of %d\n", PAGERID(pPager));
-          rc = sqlite3OsSync(&pPager->jfd);
+          rc = sqlite3OsSync(&pPager->jfd, 0);
           if( rc!=0 ) return rc;
         }
         sqlite3OsSeek(&pPager->jfd, pPager->journalHdr + sizeof(aJournalMagic));
@@ -2131,7 +2131,7 @@ static int syncJournal(Pager *pPager){
         sqlite3OsSeek(&pPager->jfd, pPager->journalOff);
       }
       TRACE2("SYNC journal of %d\n", PAGERID(pPager));
-      rc = sqlite3OsSync(&pPager->jfd);
+      rc = sqlite3OsSync(&pPager->jfd, pPager->fullSync);
       if( rc!=0 ) return rc;
       pPager->journalStarted = 1;
     }
@@ -3472,7 +3472,7 @@ int sqlite3pager_sync(Pager *pPager, const char *zMaster, Pgno nTrunc){
 
     /* Sync the database file. */
     if( !pPager->noSync ){
-      rc = sqlite3OsSync(&pPager->fd);
+      rc = sqlite3OsSync(&pPager->fd, 0);
     }
 
     pPager->state = PAGER_SYNCED;
index a4d5b0524ffc4aa383b981f4fff24a1038047b1d..c1ccd835965c67915a300803d1b475936807e4b1 100644 (file)
@@ -985,7 +985,8 @@ static int vdbeCommit(sqlite3 *db){
     */
     zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
     rc = sqlite3OsOpenDirectory(zMainFile, &master);
-    if( rc!=SQLITE_OK || (needSync && (rc=sqlite3OsSync(&master))!=SQLITE_OK) ){
+    if( rc!=SQLITE_OK ||
+          (needSync && (rc=sqlite3OsSync(&master,0))!=SQLITE_OK) ){
       sqlite3OsClose(&master);
       sqlite3OsDelete(zMaster);
       sqliteFree(zMaster);