From dd809b087f91fd906ba701da8487254eb16a8db0 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 17 Jul 2004 21:44:57 +0000 Subject: [PATCH] Use the F_FULLFSYNC fctrl if it is available. Record the name of files that are opened in the OsFile structure. (CVS 1799) FossilOrigin-Name: 1d30d0dd46c2bd12ce3f7dc06492f3e27ab6bcee --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 21 +++++++++++++++++++-- src/os_unix.h | 1 + 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 457d091739..7f6c58bc25 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\stests\sfor\ssqlite3_changes\safter\sa\sDELETE.\s(CVS\s1798) -D 2004-07-15T20:08:39 +C Use\sthe\sF_FULLFSYNC\sfctrl\sif\sit\sis\savailable.\s\sRecord\sthe\sname\sof\sfiles\nthat\sare\sopened\sin\sthe\sOsFile\sstructure.\s(CVS\s1799) +D 2004-07-17T21:44:57 F Makefile.in 77d1219b6563476711a7a962e865979a6f314eb0 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -46,8 +46,8 @@ F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4 F src/os_test.c 6bf10100de2ca199a91fe7ac6474561c8a7166ae F src/os_test.h 6a26a4978492e4bbdbf385554958418ff02db162 -F src/os_unix.c 7df6ae05faa5b84164193d3694cb71b66661bbf3 -F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a +F src/os_unix.c 7dca8d07ac1d6e2b589eda6d536a4d143160a0f3 +F src/os_unix.h c3ee271744327d156a9e016dff965adebadffdfb F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008 F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 F src/pager.c 5f8cdc92ee9efb5a7849dc8b561b53122b700c78 @@ -233,7 +233,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P c44943e6fe0c88830102253591a501dc7d724d2f -R 6372bb8eea811521fd1d8c72d50b1f51 +P c01f13267f592dc2678e78ea45dadddcdc154f82 +R a9f4dab888d922312d00d87de0e5cb2e U drh -Z 3cb2ad30190c7832bdc46e58738a9e26 +Z d985f788c605dfd4069fa22794ea5ba6 diff --git a/manifest.uuid b/manifest.uuid index e27a6f831c..d60bbb8ed2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c01f13267f592dc2678e78ea45dadddcdc154f82 \ No newline at end of file +1d30d0dd46c2bd12ce3f7dc06492f3e27ab6bcee \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index d6dede920c..7bd9ded3fb 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -654,6 +654,22 @@ int sqlite3OsSeek(OsFile *id, off_t offset){ return SQLITE_OK; } +/* +** The fsync() system call does not work as advertised on many +** unix systems. The following procedure is an attempt to make +** it work better. +*/ +static int full_fsync(int fd){ + int rc; +#ifdef F_FULLFSYNC + rc = fcntl(fd, F_FULLFSYNC, 0); + if( rc ) rc = fsync(fd); +#else + rc = fsync(fd); +#endif + return rc; +} + /* ** Make sure all writes to a particular file are committed to disk. ** @@ -669,12 +685,12 @@ int sqlite3OsSync(OsFile *id){ assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE2("SYNC %-3d\n", id->h); - if( fsync(id->h) ){ + if( full_fsync(id->h) ){ return SQLITE_IOERR; } if( id->dirfd>=0 ){ TRACE2("DIRSYNC %-3d\n", id->dirfd); - fsync(id->dirfd); + full_fsync(id->dirfd); close(id->dirfd); /* Only need to sync once, so close the directory */ id->dirfd = -1; /* when we are done. */ } @@ -1057,6 +1073,7 @@ int sqlite3OsUnlock(OsFile *id, int locktype){ */ int sqlite3OsClose(OsFile *id){ if( !id->isOpen ) return SQLITE_OK; + id->zFilename = 0; sqlite3OsUnlock(id, NO_LOCK); if( id->dirfd>=0 ) close(id->dirfd); id->dirfd = -1; diff --git a/src/os_unix.h b/src/os_unix.h index ae16a9ac64..9e11e4c929 100644 --- a/src/os_unix.h +++ b/src/os_unix.h @@ -65,6 +65,7 @@ struct OsFile { struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ + const char *zFilename; /* Name passed to open() */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ int dirfd; /* File descriptor for the directory */ -- 2.47.3