summaryrefslogtreecommitdiff
path: root/storage/myisam
diff options
context:
space:
mode:
authorNarayanan V <v.narayanan@sun.com>2009-04-09 13:48:23 +0530
committerNarayanan V <v.narayanan@sun.com>2009-04-09 13:48:23 +0530
commit53f8922307dd8504dbe14ee1ca3106cb51b5c151 (patch)
tree00988a6e771a7d0c6ab578e5c6abc1aeb3e747bc /storage/myisam
parentb1b8ab51599bed05430dc4a210f1b5a9bd066e08 (diff)
downloadmariadb-git-53f8922307dd8504dbe14ee1ca3106cb51b5c151.tar.gz
Bug#38848 myisam_use_mmap causes widespread myisam corruption on windows
Currently the memory map is being created with a size that is greater than the size of the underlying datafile. This can cause varying behaviour, e.g. In windows the size of the datafile is increased, while on linux it remains the same. This fix removes the increment margin to the size that is used while creating the memory map. storage/myisam/mi_dynrec.c: remove MEMMAP_EXTRA_MARGIN that is used as the increment margin to the underlying datafile size while creating the mmap. storage/myisam/mi_packrec.c: The size of the underlying datafile is increased by MEMMAP_EXTRA_MARGIN when using a packed record format. Hence in this case the size of the memory map should be incremented by the same factor.
Diffstat (limited to 'storage/myisam')
-rw-r--r--storage/myisam/mi_dynrec.c6
-rw-r--r--storage/myisam/mi_packrec.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c
index 3433c26f98b..d1cbd6955dd 100644
--- a/storage/myisam/mi_dynrec.c
+++ b/storage/myisam/mi_dynrec.c
@@ -66,7 +66,7 @@ static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos,
my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
{
DBUG_ENTER("mi_dynmap_file");
- if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
+ if (size > (my_off_t) (~((size_t) 0)))
{
DBUG_PRINT("warning", ("File is too large for mmap"));
DBUG_RETURN(1);
@@ -80,7 +80,7 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size)
upon a write if no physical memory is available.
*/
info->s->file_map= (uchar*)
- my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
+ my_mmap(0, (size_t) size,
info->s->mode==O_RDONLY ? PROT_READ :
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE,
@@ -113,7 +113,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size)
if (info->s->file_map)
{
VOID(my_munmap((char*) info->s->file_map,
- (size_t) info->s->mmaped_length + MEMMAP_EXTRA_MARGIN));
+ (size_t) info->s->mmaped_length));
mi_dynmap_file(info, size);
}
}
diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c
index be9ce9a0c24..d9abcbce050 100644
--- a/storage/myisam/mi_packrec.c
+++ b/storage/myisam/mi_packrec.c
@@ -1502,7 +1502,9 @@ my_bool _mi_memmap_file(MI_INFO *info)
DBUG_PRINT("warning",("File isn't extended for memmap"));
DBUG_RETURN(0);
}
- if (mi_dynmap_file(info, share->state.state.data_file_length))
+ if (mi_dynmap_file(info,
+ share->state.state.data_file_length +
+ MEMMAP_EXTRA_MARGIN))
DBUG_RETURN(0);
}
info->opt_flag|= MEMMAP_USED;