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)
translog_filename_by_fileno()
file_no Number of the log we want to open
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
pointer to path
*/
static char *translog_filename_by_fileno(uint32 file_no, char *path)
{
char file_name[10 + 8 + 1]; /* See fallowing my_sprintf() call */
char *res;
char buff[11], *end;
uint length;
DBUG_ENTER("translog_filename_by_fileno");
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));
DBUG_PRINT("info", ("Path: '%s' path: 0x%lx res: 0x%lx",
res, (ulong) path, (ulong) res));
DBUG_RETURN(res);
/* log_descriptor.directory is already formated */
end= strxmov(path, log_descriptor.directory, "maria_log.0000000", NullS);
length= (uint) (int10_to_str(file_no, buff, 10) - buff);
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)
{
int i;
struct st_file_counter *fc_ptr;
DBUG_ENTER("translog_mark_file_finished");
DBUG_PRINT("enter", ("file: %lu", (ulong) file));
LINT_INIT(fc_ptr);
pthread_mutex_lock(&log_descriptor.unfinished_files_lock);
DBUG_ASSERT(log_descriptor.unfinished_files.elements > 0);
......@@ -2310,7 +2314,7 @@ my_bool translog_unlock()
*/
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;
uint cache_index;
......@@ -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_PRINT("info", ("Direct link: 0x%lx",
......@@ -5692,7 +5696,7 @@ int translog_read_record_header(LSN lsn, TRANSLOG_HEADER_BUFFER *buff)
{
uchar buffer[TRANSLOG_PAGE_SIZE], *page;
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_VALIDATOR_DATA data;
DBUG_ENTER("translog_read_record_header");
......@@ -5963,7 +5967,7 @@ static void translog_destroy_reader_data(struct st_translog_reader_data *data)
SYNOPSIS
translog_read_record_header()
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).
length Length of record part which have to be read.
buffer Buffer where to read the record part (have to be at
......
......@@ -182,8 +182,8 @@ typedef struct st_translog_scanner_data
TRANSLOG_ADDRESS horizon;
TRANSLOG_ADDRESS last_file_page; /* Last page on in this file */
uchar *page; /* page content pointer */
/* direct link on the current page or NULL if it is not supported/requested */
PAGECACHE_PAGE_LINK direct_link;
/* direct link on the current page or NULL if not supported/requested */
PAGECACHE_BLOCK_LINK *direct_link;
/* offset of the chunk in the page */
translog_size_t page_offset;
/* set horizon only once at init */
......
......@@ -2755,10 +2755,9 @@ void pagecache_unlock_by_link(PAGECACHE *pagecache,
*/
void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link,
PAGECACHE_BLOCK_LINK *block,
LSN lsn)
{
PAGECACHE_BLOCK_LINK *block= (PAGECACHE_BLOCK_LINK *)link;
DBUG_ENTER("pagecache_unpin_by_link");
DBUG_PRINT("enter", ("block: 0x%lx fd: %u page: %lu",
(ulong) block,
......@@ -3212,13 +3211,13 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
enum pagecache_write_mode write_mode,
PAGECACHE_PAGE_LINK *link,
PAGECACHE_BLOCK_LINK **link,
uint offset, uint size,
pagecache_disk_read_validator validator,
uchar* validator_data)
{
PAGECACHE_BLOCK_LINK *block= NULL;
PAGECACHE_PAGE_LINK fake_link;
PAGECACHE_BLOCK_LINK *fake_link;
int error= 0;
int need_lock_change= write_lock_change_table[lock].need_lock_change;
DBUG_ENTER("pagecache_write_part");
......@@ -3234,9 +3233,9 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
DBUG_ASSERT(lock != PAGECACHE_LOCK_LEFT_READLOCKED);
DBUG_ASSERT(lock != PAGECACHE_LOCK_READ_UNLOCK);
DBUG_ASSERT(offset + size <= pagecache->block_size);
if (!link)
link= &fake_link;
else
*link= 0;
restart:
......@@ -3362,7 +3361,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
if (pin == PAGECACHE_PIN_LEFT_UNPINNED || pin == PAGECACHE_UNPIN)
unreg_request(pagecache, block, 1);
else
*link= (PAGECACHE_PAGE_LINK)block;
*link= block;
if (block->status & PCBLOCK_ERROR)
error= 1;
......
......@@ -91,8 +91,6 @@ typedef struct st_pagecache_page PAGECACHE_PAGE;
struct st_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>
typedef my_bool (*pagecache_disk_read_validator)(uchar *page, uchar *data);
......@@ -205,7 +203,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
enum pagecache_write_mode write_mode,
PAGECACHE_PAGE_LINK *link,
PAGECACHE_BLOCK_LINK **link,
uint offset,
uint size,
pagecache_disk_read_validator validator,
......@@ -228,7 +226,7 @@ extern void pagecache_unpin(PAGECACHE *pagecache,
pgcache_page_no_t pageno,
LSN lsn);
extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link,
PAGECACHE_BLOCK_LINK *link,
LSN lsn);
extern int flush_pagecache_blocks(PAGECACHE *keycache,
PAGECACHE_FILE *file,
......
......@@ -632,7 +632,7 @@ typedef struct st_maria_s_param
/* Used to store reference to pinned page */
typedef struct st_pinned_page
{
PAGECACHE_PAGE_LINK link;
PAGECACHE_BLOCK_LINK *link;
enum pagecache_page_lock unlock;
} 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