Commit 0de4c556 authored by unknown's avatar unknown

Faster translog_filename_by_fileno

Fixed compiler warning
PAGECACHE_PAGE_LINK -> PAGECACHE_BLOCK_LINK*


storage/maria/ma_loghandler.h:
  PAGECACHE_PAGE_LINK -> PAGECACHE_BLOCK_LINK*
storage/maria/ma_pagecache.c:
  PAGECACHE_PAGE_LINK -> PAGECACHE_BLOCK_LINK*
storage/maria/ma_pagecache.h:
  PAGECACHE_PAGE_LINK -> PAGECACHE_BLOCK_LINK*
storage/maria/maria_def.h:
  PAGECACHE_PAGE_LINK -> PAGECACHE_BLOCK_LINK*
parent c9c58163
...@@ -640,22 +640,25 @@ static void translog_check_cursor(struct st_buffer_cursor *cursor) ...@@ -640,22 +640,25 @@ static void translog_check_cursor(struct st_buffer_cursor *cursor)
translog_filename_by_fileno() translog_filename_by_fileno()
file_no Number of the log we want to open file_no Number of the log we want to open
path Pointer to buffer where file name will be path Pointer to buffer where file name will be
stored (must be FN_REFLEN bytes at least stored (must be FN_REFLEN bytes at least)
RETURN RETURN
pointer to path pointer to path
*/ */
static char *translog_filename_by_fileno(uint32 file_no, char *path) static char *translog_filename_by_fileno(uint32 file_no, char *path)
{ {
char file_name[10 + 8 + 1]; /* See fallowing my_sprintf() call */ char buff[11], *end;
char *res; uint length;
DBUG_ENTER("translog_filename_by_fileno"); DBUG_ENTER("translog_filename_by_fileno");
DBUG_ASSERT(file_no <= 0xfffffff); DBUG_ASSERT(file_no <= 0xfffffff);
my_sprintf(file_name, (file_name, "maria_log.%08u", file_no));
res= fn_format(path, file_name, log_descriptor.directory, "", MYF(MY_WME)); /* log_descriptor.directory is already formated */
DBUG_PRINT("info", ("Path: '%s' path: 0x%lx res: 0x%lx", end= strxmov(path, log_descriptor.directory, "maria_log.0000000", NullS);
res, (ulong) path, (ulong) res)); length= (uint) (int10_to_str(file_no, buff, 10) - buff);
DBUG_RETURN(res); strmov(end-length+1, buff);
DBUG_PRINT("info", ("Path: '%s' path: 0x%lx", path, (ulong) res));
DBUG_RETURN(path);
} }
...@@ -986,10 +989,11 @@ static void translog_mark_file_finished(uint32 file) ...@@ -986,10 +989,11 @@ static void translog_mark_file_finished(uint32 file)
{ {
int i; int i;
struct st_file_counter *fc_ptr; struct st_file_counter *fc_ptr;
DBUG_ENTER("translog_mark_file_finished"); DBUG_ENTER("translog_mark_file_finished");
DBUG_PRINT("enter", ("file: %lu", (ulong) file)); DBUG_PRINT("enter", ("file: %lu", (ulong) file));
LINT_INIT(fc_ptr);
pthread_mutex_lock(&log_descriptor.unfinished_files_lock); pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0); DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0);
...@@ -2310,7 +2314,7 @@ my_bool translog_unlock() ...@@ -2310,7 +2314,7 @@ my_bool translog_unlock()
*/ */
static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer, static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer,
PAGECACHE_PAGE_LINK *direct_link) PAGECACHE_BLOCK_LINK **direct_link)
{ {
TRANSLOG_ADDRESS addr= *(data->addr), in_buffers; TRANSLOG_ADDRESS addr= *(data->addr), in_buffers;
uint cache_index; uint cache_index;
...@@ -2490,7 +2494,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer, ...@@ -2490,7 +2494,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer,
*/ */
static void translog_free_link(PAGECACHE_PAGE_LINK *direct_link) static void translog_free_link(PAGECACHE_BLOCK_LINK *direct_link)
{ {
DBUG_ENTER("translog_free_link"); DBUG_ENTER("translog_free_link");
DBUG_PRINT("info", ("Direct link: 0x%lx", DBUG_PRINT("info", ("Direct link: 0x%lx",
...@@ -5692,7 +5696,7 @@ int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff) ...@@ -5692,7 +5696,7 @@ int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff)
{ {
uchar buffer[TRANSLOG_PAGE_SIZE], *page; uchar buffer[TRANSLOG_PAGE_SIZE], *page;
translog_size_t res, page_offset= LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE; translog_size_t res, page_offset= LSN_OFFSET(lsn) % TRANSLOG_PAGE_SIZE;
PAGECACHE_PAGE_LINK direct_link; PAGECACHE_BLOCK_LINK *direct_link;
TRANSLOG_ADDRESS addr; TRANSLOG_ADDRESS addr;
TRANSLOG_VALIDATOR_DATA data; TRANSLOG_VALIDATOR_DATA data;
DBUG_ENTER("translog_read_record_header"); DBUG_ENTER("translog_read_record_header");
...@@ -5963,7 +5967,7 @@ static void translog_destroy_reader_data(struct st_translog_reader_data *data) ...@@ -5963,7 +5967,7 @@ static void translog_destroy_reader_data(struct st_translog_reader_data *data)
SYNOPSIS SYNOPSIS
translog_read_record_header() translog_read_record_header()
lsn log record serial number (address of the record) lsn log record serial number (address of the record)
offset From the beginning of the record beginning (read§ offset From the beginning of the record beginning (read
by translog_read_record_header). by translog_read_record_header).
length Length of record part which have to be read. length Length of record part which have to be read.
buffer Buffer where to read the record part (have to be at buffer Buffer where to read the record part (have to be at
......
...@@ -182,8 +182,8 @@ typedef struct st_translog_scanner_data ...@@ -182,8 +182,8 @@ typedef struct st_translog_scanner_data
TRANSLOG_ADDRESS horizon; TRANSLOG_ADDRESS horizon;
TRANSLOG_ADDRESS last_file_page; /* Last page on in this file */ TRANSLOG_ADDRESS last_file_page; /* Last page on in this file */
uchar *page; /* page content pointer */ uchar *page; /* page content pointer */
/* direct link on the current page or NULL if it is not supported/requested */ /* direct link on the current page or NULL if not supported/requested */
PAGECACHE_PAGE_LINK direct_link; PAGECACHE_BLOCK_LINK *direct_link;
/* offset of the chunk in the page */ /* offset of the chunk in the page */
translog_size_t page_offset; translog_size_t page_offset;
/* set horizon only once at init */ /* set horizon only once at init */
......
...@@ -2755,10 +2755,9 @@ void pagecache_unlock_by_link(PAGECACHE *pagecache, ...@@ -2755,10 +2755,9 @@ void pagecache_unlock_by_link(PAGECACHE *pagecache,
*/ */
void pagecache_unpin_by_link(PAGECACHE *pagecache, void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link, PAGECACHE_BLOCK_LINK *block,
LSN lsn) LSN lsn)
{ {
PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link;
DBUG_ENTER("pagecache_unpin_by_link"); DBUG_ENTER("pagecache_unpin_by_link");
DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu", DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu",
(ulong) block, (ulong) block,
...@@ -3212,13 +3211,13 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3212,13 +3211,13 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
enum pagecache_write_mode write_mode, enum pagecache_write_mode write_mode,
PAGECACHE_PAGE_LINK *link, PAGECACHE_BLOCK_LINK **link,
uint offset, uint size, uint offset, uint size,
pagecache_disk_read_validator validator, pagecache_disk_read_validator validator,
uchar* validator_data) uchar* validator_data)
{ {
PAGECACHE_BLOCK_LINK *block= NULL; PAGECACHE_BLOCK_LINK *block= NULL;
PAGECACHE_PAGE_LINK fake_link; PAGECACHE_BLOCK_LINK *fake_link;
int error= 0; int error= 0;
int need_lock_change= write_lock_change_table[lock].need_lock_change; int need_lock_change= write_lock_change_table[lock].need_lock_change;
DBUG_ENTER("pagecache_write_part"); DBUG_ENTER("pagecache_write_part");
...@@ -3234,10 +3233,10 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3234,10 +3233,10 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED); DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED);
DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK); DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK);
DBUG_ASSERT(offset + size <= pagecache->block_size); DBUG_ASSERT(offset + size <= pagecache->block_size);
if (!link) if (!link)
link= &fake_link; link= &fake_link;
else *link= 0;
*link= 0;
restart: restart:
...@@ -3362,7 +3361,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3362,7 +3361,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN) if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN)
unreg_request(pagecache, block, 1); unreg_request(pagecache, block, 1);
else else
*link= (PAGECACHE_PAGE_LINK)block; *link= block;
if (block->status & PCBLOCK_ERROR) if (block->status & PCBLOCK_ERROR)
error= 1; error= 1;
......
...@@ -91,8 +91,6 @@ typedef struct st_pagecache_page PAGECACHE_PAGE; ...@@ -91,8 +91,6 @@ typedef struct st_pagecache_page PAGECACHE_PAGE;
struct st_pagecache_hash_link; struct st_pagecache_hash_link;
typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
typedef PAGECACHE_BLOCK_LINK * PAGECACHE_PAGE_LINK; /* To be removed */
#include <wqueue.h> #include <wqueue.h>
typedef my_bool (*pagecache_disk_read_validator)(uchar *page, uchar *data); typedef my_bool (*pagecache_disk_read_validator)(uchar *page, uchar *data);
...@@ -205,7 +203,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -205,7 +203,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
enum pagecache_write_mode write_mode, enum pagecache_write_mode write_mode,
PAGECACHE_PAGE_LINK *link, PAGECACHE_BLOCK_LINK **link,
uint offset, uint offset,
uint size, uint size,
pagecache_disk_read_validator validator, pagecache_disk_read_validator validator,
...@@ -228,7 +226,7 @@ extern void pagecache_unpin(PAGECACHE *pagecache, ...@@ -228,7 +226,7 @@ extern void pagecache_unpin(PAGECACHE *pagecache,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
LSN lsn); LSN lsn);
extern void pagecache_unpin_by_link(PAGECACHE *pagecache, extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link, PAGECACHE_BLOCK_LINK *link,
LSN lsn); LSN lsn);
extern int flush_pagecache_blocks(PAGECACHE *keycache, extern int flush_pagecache_blocks(PAGECACHE *keycache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
......
...@@ -632,7 +632,7 @@ typedef struct st_maria_s_param ...@@ -632,7 +632,7 @@ typedef struct st_maria_s_param
/* Used to store reference to pinned page */ /* Used to store reference to pinned page */
typedef struct st_pinned_page typedef struct st_pinned_page
{ {
PAGECACHE_PAGE_LINK link; PAGECACHE_BLOCK_LINK *link;
enum pagecache_page_lock unlock; enum pagecache_page_lock unlock;
} MARIA_PINNED_PAGE; } MARIA_PINNED_PAGE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment