diff options
author | unknown <guilhem@gbichot3.local> | 2006-11-27 22:01:29 +0100 |
---|---|---|
committer | unknown <guilhem@gbichot3.local> | 2006-11-27 22:01:29 +0100 |
commit | de6f550ec7015fccd044a54c7628cdf8cdc2ed8c (patch) | |
tree | 106184cb5d00019bbc3e544912757a1db64b6de8 /mysys/my_sync.c | |
parent | adfba203ffd1bd89d74a63ff09de9b9a40fb64d7 (diff) | |
download | mariadb-git-de6f550ec7015fccd044a54c7628cdf8cdc2ed8c.tar.gz |
WL#3072 Maria Recovery. Making DDLs durable in Maria:
Sync table files after CREATE (of non-temp table), DROP, RENAME,
TRUNCATE, sync directories and symlinks (for the 3 first commands).
Comments for future log records.
In ma_rename(), if rename of index works and then rename of data fails,
try to undo the rename of the index to leave a consistent state.
mysys/my_symlink.c:
sync directory after creation of a symbolic link in it, if asked
mysys/my_sync.c:
comment. Fix for when the file's name has no directory in it.
storage/maria/ma_create.c:
sync files and links and dirs when creating a non-temporary table.
Optimizations of the above to reduce syncs in the common cases:
* if index file and data file have the exact same paths (regular
and link), sync the directories (of regular and link) only once
after creating the last file (the data file).
* don't sync the data file if we didn't write to it (always true
in our builds).
storage/maria/ma_delete_all.c:
sync files after truncating a table
storage/maria/ma_delete_table.c:
sync files and symbolic links and dirs after dropping a table
storage/maria/ma_extra.c:
a function which wraps the sync of the index file and the sync of the
data file.
storage/maria/ma_locking.c:
using a wrapper function
storage/maria/ma_rename.c:
sync files and symbolic links and dirs after renaming a table.
If rename of index works and then rename of data fails, try to undo
the rename of the index to leave a consistent state. That is just a
try, it may fail...
storage/maria/ma_test3.c:
warning to not pay attention to this test.
storage/maria/maria_def.h:
declaration for the function added to ma_extra.c
Diffstat (limited to 'mysys/my_sync.c')
-rw-r--r-- | mysys/my_sync.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mysys/my_sync.c b/mysys/my_sync.c index ada2ea84414..26bee5a293f 100644 --- a/mysys/my_sync.c +++ b/mysys/my_sync.c @@ -52,7 +52,7 @@ int my_sync(File fd, myf my_flags) #if defined(F_FULLFSYNC) /* In Mac OS X >= 10.3 this call is safer than fsync() (it forces the - disk's cache). + disk's cache and guarantees ordered writes). */ if (!(res= fcntl(fd, F_FULLFSYNC, 0))) break; /* ok */ @@ -89,6 +89,7 @@ int my_sync(File fd, myf my_flags) } /* my_sync */ +static const char cur_dir_name[]= {FN_CURLIB, 0}; /* Force directory information to disk. @@ -107,11 +108,14 @@ int my_sync_dir(const char *dir_name, myf my_flags) DBUG_PRINT("my",("Dir: '%s' my_flags: %d", dir_name, my_flags)); File dir_fd; int res= 0; + const char *correct_dir_name; + /* Sometimes the path does not contain an explicit directory */ + correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name; /* Syncing a dir may give EINVAL on tmpfs on Linux, which is ok. EIO on the other hand is very important. Hence MY_IGNORE_BADFD. */ - if ((dir_fd= my_open(dir_name, O_RDONLY, MYF(my_flags))) >= 0) + if ((dir_fd= my_open(correct_dir_name, O_RDONLY, MYF(my_flags))) >= 0) { if (my_sync(dir_fd, MYF(my_flags | MY_IGNORE_BADFD))) res= 2; |