summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
Diffstat (limited to 'mysys')
-rw-r--r--mysys/lf_alloc-pin.c2
-rw-r--r--mysys/lf_hash.c4
-rw-r--r--mysys/my_sync.c18
3 files changed, 20 insertions, 4 deletions
diff --git a/mysys/lf_alloc-pin.c b/mysys/lf_alloc-pin.c
index d23ef129aa2..6ab6ba3aae0 100644
--- a/mysys/lf_alloc-pin.c
+++ b/mysys/lf_alloc-pin.c
@@ -271,7 +271,7 @@ static int ptr_cmp(void **a, void **b)
void _lf_pinbox_free(LF_PINS *pins, void *addr)
{
add_to_purgatory(pins, addr);
- if (pins->purgatory_count % LF_PURGATORY_SIZE)
+ if (pins->purgatory_count % LF_PURGATORY_SIZE == 0)
_lf_pinbox_real_free(pins);
}
diff --git a/mysys/lf_hash.c b/mysys/lf_hash.c
index 83cfe1a1639..38b212c65f0 100644
--- a/mysys/lf_hash.c
+++ b/mysys/lf_hash.c
@@ -268,8 +268,10 @@ static LF_SLIST *lsearch(LF_SLIST * volatile *head, CHARSET_INFO *cs,
int res= lfind(head, cs, hashnr, key, keylen, &cursor, pins);
if (res)
_lf_pin(pins, 2, cursor.curr);
- _lf_unpin(pins, 0);
+ else
+ _lf_unpin(pins, 2);
_lf_unpin(pins, 1);
+ _lf_unpin(pins, 0);
return res ? cursor.curr : 0;
}
diff --git a/mysys/my_sync.c b/mysys/my_sync.c
index 3853d30632e..88bcb685271 100644
--- a/mysys/my_sync.c
+++ b/mysys/my_sync.c
@@ -49,6 +49,13 @@ void thr_set_sync_wait_callback(void (*before_wait)(void),
(which is correct behaviour, if we know that the other thread synced the
file before closing)
+ MY_SYNC_FILESIZE is useful when syncing a file after it has been extended.
+ On Linux, fdatasync() on ext3/ext4 file systems does not properly flush
+ to disk the inode data required to preserve the added data across a crash
+ (this looks to be a bug). But when a file is extended, inode data will most
+ likely need flushing in any case, so passing MY_SYNC_FILESIZE as flags
+ is not likely to be any slower, and will be crash safe on Linux ext3/ext4.
+
RETURN
0 ok
-1 error
@@ -84,8 +91,12 @@ int my_sync(File fd, myf my_flags)
DBUG_PRINT("info",("fcntl(F_FULLFSYNC) failed, falling back"));
#endif
#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
- res= fdatasync(fd);
-#elif defined(HAVE_FSYNC)
+ if (!(my_flags & MY_SYNC_FILESIZE))
+ res= fdatasync(fd);
+ else
+ {
+#endif
+#if defined(HAVE_FSYNC)
res= fsync(fd);
if (res == -1 && errno == ENOLCK)
res= 0; /* Result Bug in Old FreeBSD */
@@ -95,6 +106,9 @@ int my_sync(File fd, myf my_flags)
#error Cannot find a way to sync a file, durability in danger
res= 0; /* No sync (strange OS) */
#endif
+#if defined(HAVE_FDATASYNC) && HAVE_DECL_FDATASYNC
+ }
+#endif
} while (res == -1 && errno == EINTR);
if (res)