diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-04-21 11:28:18 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-04-21 18:12:10 +0300 |
commit | 0871a00a62efe63d23e3dde5a0bcd667583ee717 (patch) | |
tree | 9c86a3c76db65e74c9e3717ef6b30f179ff18170 /storage/innobase/fil/fil0pagecompress.cc | |
parent | b66e15ecbcc08b30abd2f709fde6a93e1827967e (diff) | |
download | mariadb-git-0871a00a62efe63d23e3dde5a0bcd667583ee717.tar.gz |
MDEV-12545 Reduce the amount of fil_space_t lookups
buf_flush_write_block_low(): Acquire the tablespace reference once,
and pass it to lower-level functions. This is only a start; further
calls may be removed.
fil_decompress_page(): Remove unsafe use of fil_space_get_by_id().
Diffstat (limited to 'storage/innobase/fil/fil0pagecompress.cc')
-rw-r--r-- | storage/innobase/fil/fil0pagecompress.cc | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index dad74ce34f2..0f47ea1d21e 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -85,8 +85,7 @@ UNIV_INTERN byte* fil_compress_page( /*==============*/ - ulint space_id, /*!< in: tablespace id of the - table. */ + fil_space_t* space, /*!< in,out: tablespace (NULL during IMPORT) */ byte* buf, /*!< in: buffer from which to write; in aio this must be appropriately aligned */ byte* out_buf, /*!< out: compressed buffer */ @@ -104,9 +103,12 @@ fil_compress_page( ulint write_size=0; /* Cache to avoid change during function execution */ ulint comp_method = innodb_compression_algorithm; - ulint orig_page_type; bool allocated=false; + /* page_compression does not apply to tables or tablespaces + that use ROW_FORMAT=COMPRESSED */ + ut_ad(!space || !page_size_t(space->flags).is_compressed()); + if (encrypted) { header_len += FIL_PAGE_COMPRESSION_METHOD_SIZE; } @@ -127,19 +129,13 @@ fil_compress_page( ut_ad(len); ut_ad(out_len); - /* read original page type */ - orig_page_type = mach_read_from_2(buf + FIL_PAGE_TYPE); - - fil_system_enter(); - fil_space_t* space = fil_space_get_by_id(space_id); - fil_system_exit(); - /* Let's not compress file space header or extent descriptor */ - if (orig_page_type == 0 || - orig_page_type == FIL_PAGE_TYPE_FSP_HDR || - orig_page_type == FIL_PAGE_TYPE_XDES || - orig_page_type == FIL_PAGE_PAGE_COMPRESSED) { + switch (fil_page_get_type(buf)) { + case 0: + case FIL_PAGE_TYPE_FSP_HDR: + case FIL_PAGE_TYPE_XDES: + case FIL_PAGE_PAGE_COMPRESSED: *out_len = len; goto err_exit; @@ -151,12 +147,9 @@ fil_compress_page( comp_level = page_zip_level; } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Preparing for compress for space " ULINTPF - " name %s len " ULINTPF ".", - space_id, fil_space_name(space), len); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_LOG("compress", "Preparing for space " + << (space ? space->id : 0) << " '" + << (space ? space->name : "(import)") << "' len " << len); write_size = UNIV_PAGE_SIZE - header_len; @@ -306,13 +299,12 @@ fil_compress_page( comp_page = static_cast<byte *>(ut_malloc_nokey(UNIV_PAGE_SIZE)); uncomp_page = static_cast<byte *>(ut_malloc_nokey(UNIV_PAGE_SIZE)); memcpy(comp_page, out_buf, UNIV_PAGE_SIZE); - bool tsfound; - const page_size_t page_size = fil_space_get_page_size(space_id, &tsfound); fil_decompress_page(uncomp_page, comp_page, ulong(len), NULL); - if (buf_page_is_corrupted(false, uncomp_page, page_size, space)) { - buf_page_print(uncomp_page, page_size, 0); + if (buf_page_is_corrupted(false, uncomp_page, univ_page_size, + space)) { + buf_page_print(uncomp_page, univ_page_size, 0); } ut_free(comp_page); @@ -341,12 +333,10 @@ fil_compress_page( #endif } -#ifdef UNIV_PAGECOMPRESS_DEBUG - ib_logf(IB_LOG_LEVEL_INFO, - "Compression succeeded for space " ULINTPF - " name %s len " ULINTPF " out_len " ULINTPF ".", - space_id, fil_space_name(space), len, write_size); -#endif /* UNIV_PAGECOMPRESS_DEBUG */ + DBUG_LOG("compress", "Succeeded for space " + << (space ? space->id : 0) << " '" + << (space ? space->name : "(import)") + << "' len " << len << " out_len " << write_size); srv_stats.page_compression_saved.add((len - write_size)); srv_stats.pages_page_compressed.inc(); @@ -372,11 +362,11 @@ err_exit: /* If error we leave the actual page as it was */ #ifndef UNIV_PAGECOMPRESS_DEBUG - if (space && space->printed_compression_failure == false) { + if (!space->printed_compression_failure) { #endif ib::warn() << "Compression failed for space: " - << space_id << " name: " - << fil_space_name(space) << " len: " + << space->id << " name: " + << space->name << " len: " << len << " err: " << err << " write_size: " << write_size << " compression method: " @@ -643,21 +633,16 @@ err_exit: /* Note that as we have found the page is corrupted, so all this could be incorrect. */ ulint space_id = mach_read_from_4(buf+FIL_PAGE_SPACE_ID); - fil_system_enter(); - fil_space_t* space = fil_space_get_by_id(space_id); - fil_system_exit(); - - bool tsfound; - const page_size_t page_size = fil_space_get_page_size(space_id, &tsfound); + const FilSpace space(space_id, true); ib::error() << "Corruption: Page is marked as compressed" << " space: " << space_id << " name: " - << (space ? fil_space_name(space) : "NULL") + << (space() ? space()->name : "NULL") << " but uncompress failed with error: " << err << " size: " << actual_size << " len: " << len << " compression method: " << fil_get_compression_alg_name(compression_alg) << "."; - buf_page_print(buf, page_size, 0); + buf_page_print(buf, univ_page_size, 0); } |