diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-05-04 15:23:26 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-05-04 15:23:26 +0200 |
commit | 87e3e67f434628768b5125fbab7e8862fa60da1a (patch) | |
tree | df19b8bcac9988d83270ed1da05f765bfc4e8624 /storage/innobase/fil/fil0fil.cc | |
parent | 80da57cc4f0c717ee3e01ac5abccc859b88a2fbf (diff) | |
parent | cee9ab9d85a8d75290b0d60bc7af26c8cf179a1d (diff) | |
download | mariadb-git-87e3e67f434628768b5125fbab7e8862fa60da1a.tar.gz |
Merge branch '10.0' into 10.1
Diffstat (limited to 'storage/innobase/fil/fil0fil.cc')
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 22abf592adc..bf7a53778f4 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1995, 2015, Oracle and/or its affiliates. +Copyright (c) 1995, 2016, Oracle and/or its affiliates. Copyright (c) 2013, 2016, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under @@ -3186,8 +3186,6 @@ fil_create_link_file( const char* tablename, /*!< in: tablename */ const char* filepath) /*!< in: pathname of tablespace */ { - os_file_t file; - ibool success; dberr_t err = DB_SUCCESS; char* link_filepath; char* prev_filepath = fil_read_link_file(tablename); @@ -3205,16 +3203,25 @@ fil_create_link_file( } link_filepath = fil_make_isl_name(tablename); - /* Note that OS_FILE_READ_WRITE_CACHED used here to avoid - unnecessary errors on O_DIRECT, link files are not really - a data files. */ - file = os_file_create_simple_no_error_handling( - innodb_file_data_key, link_filepath, - OS_FILE_CREATE, OS_FILE_READ_WRITE_CACHED, &success, 0); - if (!success) { - /* The following call will print an error message */ - ulint error = os_file_get_last_error(true); + /** Check if the file already exists. */ + FILE* file = NULL; + ibool exists; + os_file_type_t ftype; + + bool success = os_file_status(link_filepath, &exists, &ftype); + + ulint error = 0; + if (success && !exists) { + file = fopen(link_filepath, "w"); + if (file == NULL) { + /* This call will print its own error message */ + error = os_file_get_last_error(true); + } + } else { + error = OS_FILE_ALREADY_EXISTS; + } + if (error != 0) { ut_print_timestamp(stderr); fputs(" InnoDB: Cannot create file ", stderr); @@ -3239,13 +3246,17 @@ fil_create_link_file( return(err); } - if (!os_file_write(link_filepath, file, filepath, 0, - strlen(filepath))) { + ulint rbytes = fwrite(filepath, 1, strlen(filepath), file); + if (rbytes != strlen(filepath)) { + os_file_get_last_error(true); + ib_logf(IB_LOG_LEVEL_ERROR, + "cannot write link file " + "%s",filepath); err = DB_ERROR; } /* Close the file, we only need it at startup */ - os_file_close(file); + fclose(file); mem_free(link_filepath); @@ -5262,12 +5273,15 @@ retry: os_offset_t offset = ((os_offset_t) (start_page_no - file_start_page_no)) * page_size; + + const char* name = node->name == NULL ? space->name : node->name; + #ifdef UNIV_HOTBACKUP - success = os_file_write(node->name, node->handle, buf, + success = os_file_write(name, node->handle, buf, offset, page_size * n_pages); #else success = os_aio(OS_FILE_WRITE, 0, OS_AIO_SYNC, - node->name, node->handle, buf, + name, node->handle, buf, offset, page_size * n_pages, page_size, node, NULL, 0); #endif /* UNIV_HOTBACKUP */ @@ -5904,30 +5918,22 @@ fil_io( ut_a(byte_offset % OS_FILE_LOG_BLOCK_SIZE == 0); ut_a((len % OS_FILE_LOG_BLOCK_SIZE) == 0); + const char* name = node->name == NULL ? space->name : node->name; + #ifdef UNIV_HOTBACKUP /* In mysqlbackup do normal i/o, not aio */ if (type == OS_FILE_READ) { ret = os_file_read(node->handle, buf, offset, len); } else { ut_ad(!srv_read_only_mode); - ret = os_file_write(node->name, node->handle, buf, + ret = os_file_write(name, node->handle, buf, offset, len); } #else /* Queue the aio request */ - ret = os_aio( - type, - is_log, - mode | wake_later, - node->name, - node->handle, - buf, - offset, - len, - zip_size ? zip_size : UNIV_PAGE_SIZE, - node, - message, - write_size); + ret = os_aio(type, is_log, mode | wake_later, name, node->handle, buf, + offset, len, zip_size ? zip_size : UNIV_PAGE_SIZE, node, + message, write_size); #endif /* UNIV_HOTBACKUP */ |