summaryrefslogtreecommitdiff
path: root/storage/xtradb/fil
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@skysql.com>2014-10-28 14:49:31 +0400
committerJan Lindström <jan.lindstrom@skysql.com>2014-10-29 11:07:11 +0200
commitb96697d286e477ae8df212bdf0350d3110168499 (patch)
tree076cf49e3caf69ce4afc7fc8eba21ba574a34e5a /storage/xtradb/fil
parente48fbd28d298417aae1eb06b3842586598e5dfce (diff)
downloadmariadb-git-b96697d286e477ae8df212bdf0350d3110168499.tar.gz
MDEV-6648: InnoDB: Add support for 4K sector size if supported
New generation hard drives, SSDs and NVM devices support 4K sector size. Supported sector size can be found using fstatvfs() or GetDiskFreeSpace() functions.
Diffstat (limited to 'storage/xtradb/fil')
-rw-r--r--storage/xtradb/fil/fil0fil.cc57
-rw-r--r--storage/xtradb/fil/fil0pagecompress.cc10
2 files changed, 45 insertions, 22 deletions
diff --git a/storage/xtradb/fil/fil0fil.cc b/storage/xtradb/fil/fil0fil.cc
index 31430368514..b5e1a63f62d 100644
--- a/storage/xtradb/fil/fil0fil.cc
+++ b/storage/xtradb/fil/fil0fil.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2014, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2013, 2014, SkySQL Ab. All Rights Reserved.
+Copyright (c) 2013, 2014, MariaDB Corporation. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -179,6 +179,7 @@ struct fil_node_t {
ib_int64_t flush_counter;/*!< up to what
modification_counter value we have
flushed the modifications to disk */
+ ulint file_block_size;/*!< file system block size */
UT_LIST_NODE_T(fil_node_t) chain;
/*!< link field for the file chain */
UT_LIST_NODE_T(fil_node_t) LRU;
@@ -779,6 +780,8 @@ fil_node_open_file(
size_bytes = os_file_get_size(node->handle);
ut_a(size_bytes != (os_offset_t) -1);
+
+ node->file_block_size = os_file_get_block_size(node->handle, node->name);
#ifdef UNIV_HOTBACKUP
if (space->id == 0) {
node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
@@ -927,6 +930,10 @@ add_size:
&ret, atomic_writes);
}
+ if (node->file_block_size == 0) {
+ node->file_block_size = os_file_get_block_size(node->handle, node->name);
+ }
+
ut_a(ret);
node->open = TRUE;
@@ -5221,6 +5228,11 @@ retry:
start_page_no = space->size;
file_start_page_no = space->size - node->size;
+ /* Determine correct file block size */
+ if (node->file_block_size == 0) {
+ node->file_block_size = os_file_get_block_size(node->handle, node->name);
+ }
+
#ifdef HAVE_POSIX_FALLOCATE
if (srv_use_posix_fallocate) {
os_offset_t start_offset = start_page_no * page_size;
@@ -6853,36 +6865,47 @@ fil_get_page_type_name(
{
switch(page_type) {
case FIL_PAGE_PAGE_COMPRESSED:
- return "PAGE_COMPRESSED";
+ return (const char*)"PAGE_COMPRESSED";
case FIL_PAGE_INDEX:
- return "INDEX";
+ return (const char*)"INDEX";
case FIL_PAGE_UNDO_LOG:
- return "UNDO LOG";
+ return (const char*)"UNDO LOG";
case FIL_PAGE_INODE:
- return "INODE";
+ return (const char*)"INODE";
case FIL_PAGE_IBUF_FREE_LIST:
- return "IBUF_FREE_LIST";
+ return (const char*)"IBUF_FREE_LIST";
case FIL_PAGE_TYPE_ALLOCATED:
- return "ALLOCATED";
+ return (const char*)"ALLOCATED";
case FIL_PAGE_IBUF_BITMAP:
- return "IBUF_BITMAP";
+ return (const char*)"IBUF_BITMAP";
case FIL_PAGE_TYPE_SYS:
- return "SYS";
+ return (const char*)"SYS";
case FIL_PAGE_TYPE_TRX_SYS:
- return "TRX_SYS";
+ return (const char*)"TRX_SYS";
case FIL_PAGE_TYPE_FSP_HDR:
- return "FSP_HDR";
+ return (const char*)"FSP_HDR";
case FIL_PAGE_TYPE_XDES:
- return "XDES";
+ return (const char*)"XDES";
case FIL_PAGE_TYPE_BLOB:
- return "BLOB";
+ return (const char*)"BLOB";
case FIL_PAGE_TYPE_ZBLOB:
- return "ZBLOB";
+ return (const char*)"ZBLOB";
case FIL_PAGE_TYPE_ZBLOB2:
- return "ZBLOB2";
+ return (const char*)"ZBLOB2";
case FIL_PAGE_TYPE_COMPRESSED:
- return "ORACLE PAGE COMPRESSED";
+ return (const char*)"ORACLE PAGE COMPRESSED";
default:
- return "PAGE TYPE CORRUPTED";
+ return (const char*)"PAGE TYPE CORRUPTED";
}
}
+/****************************************************************//**
+Get block size from fil node
+@return block size*/
+ulint
+fil_node_get_block_size(
+/*====================*/
+ fil_node_t* node) /*!< in: Node where to get block
+ size */
+{
+ return (node->file_block_size);
+}
diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc
index d7bc0ff62e7..a4b0e1b486b 100644
--- a/storage/xtradb/fil/fil0pagecompress.cc
+++ b/storage/xtradb/fil/fil0pagecompress.cc
@@ -260,6 +260,7 @@ fil_compress_page(
byte* out_buf, /*!< out: compressed buffer */
ulint len, /*!< in: length of input buffer.*/
ulint compression_level, /* in: compression level */
+ ulint block_size, /*!< in: block size */
ulint* out_len, /*!< out: actual length of compressed
page */
byte* lzo_mem) /*!< in: temporal memory used by LZO */
@@ -450,12 +451,11 @@ fil_compress_page(
write_size+=header_len;
-#define SECT_SIZE 512
-
/* Actual write needs to be alligned on block size */
- if (write_size % SECT_SIZE) {
- write_size = (write_size + SECT_SIZE-1) & ~(SECT_SIZE-1);
- ut_a((write_size % SECT_SIZE) == 0);
+ if (write_size % block_size) {
+ ut_a(block_size > 0);
+ write_size = (write_size + block_size-1) & ~(block_size-1);
+ ut_a((write_size % block_size) == 0);
}
#ifdef UNIV_PAGECOMPRESS_DEBUG