diff options
author | unknown <bell@desktop.sanja.is.com.ua> | 2007-11-05 15:07:50 +0200 |
---|---|---|
committer | unknown <bell@desktop.sanja.is.com.ua> | 2007-11-05 15:07:50 +0200 |
commit | f3e957b7c1ffa4958970bda9b0c5e2ecdc81d52a (patch) | |
tree | 448c2ade24e4b9ca1b5d654ba4d12e171ec3e507 | |
parent | 1cede43268dec2baa2d80cff591da517d6500f74 (diff) | |
download | mariadb-git-f3e957b7c1ffa4958970bda9b0c5e2ecdc81d52a.tar.gz |
Support of rec_lsn added to pagecache_write call.
storage/maria/ma_pagecache.c:
Support of rec_lsn added to pagecache_write call.
A function for setting rec_lsn made.
-rw-r--r-- | storage/maria/ma_bitmap.c | 3 | ||||
-rw-r--r-- | storage/maria/ma_blockrec.c | 23 | ||||
-rw-r--r-- | storage/maria/ma_loghandler.c | 1 | ||||
-rw-r--r-- | storage/maria/ma_page.c | 4 | ||||
-rwxr-xr-x | storage/maria/ma_pagecache.c | 83 | ||||
-rw-r--r-- | storage/maria/ma_pagecache.h | 9 | ||||
-rw-r--r-- | storage/maria/ma_preload.c | 5 | ||||
-rw-r--r-- | storage/maria/unittest/ma_pagecache_consist.c | 4 | ||||
-rw-r--r-- | storage/maria/unittest/ma_pagecache_single.c | 22 | ||||
-rw-r--r-- | storage/maria/unittest/ma_test_loghandler_pagecache-t.c | 2 |
10 files changed, 94 insertions, 62 deletions
diff --git a/storage/maria/ma_bitmap.c b/storage/maria/ma_bitmap.c index d7b073356b2..e0c1cbd73b0 100644 --- a/storage/maria/ma_bitmap.c +++ b/storage/maria/ma_bitmap.c @@ -149,7 +149,8 @@ static inline my_bool write_changed_bitmap(MARIA_SHARE *share, (uchar*) bitmap->map, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, - PAGECACHE_WRITE_DELAY, 0)); + PAGECACHE_WRITE_DELAY, 0, + LSN_IMPOSSIBLE)); } /* diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 7709de703c0..a159756f509 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -1451,7 +1451,8 @@ static my_bool write_tail(MARIA_HA *info, PAGECACHE_LOCK_READ, block_is_read ? PAGECACHE_PIN_LEFT_PINNED : PAGECACHE_PIN, - PAGECACHE_WRITE_DELAY, &page_link.link))) + PAGECACHE_WRITE_DELAY, &page_link.link, + LSN_IMPOSSIBLE))) { page_link.unlock= PAGECACHE_LOCK_READ_UNLOCK; if (block_is_read) @@ -1544,7 +1545,7 @@ static my_bool write_full_pages(MARIA_HA *info, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0)) + 0, LSN_IMPOSSIBLE)) DBUG_RETURN(1); page++; block->used= BLOCKUSED_USED; @@ -2262,7 +2263,8 @@ static my_bool write_block_record(MARIA_HA *info, PAGECACHE_LOCK_READ, head_block_is_read ? PAGECACHE_PIN_LEFT_PINNED : PAGECACHE_PIN, - PAGECACHE_WRITE_DELAY, &page_link.link)) + PAGECACHE_WRITE_DELAY, &page_link.link, + LSN_IMPOSSIBLE)) goto disk_err; page_link.unlock= PAGECACHE_LOCK_READ_UNLOCK; if (head_block_is_read) @@ -3041,7 +3043,8 @@ static my_bool delete_head_or_tail(MARIA_HA *info, buff, share->page_type, lock_at_write, PAGECACHE_PIN_LEFT_PINNED, - PAGECACHE_WRITE_DELAY, &page_link.link)) + PAGECACHE_WRITE_DELAY, &page_link.link, + LSN_IMPOSSIBLE)) DBUG_RETURN(1); } else /* page is now empty */ @@ -3069,7 +3072,8 @@ static my_bool delete_head_or_tail(MARIA_HA *info, buff, share->page_type, lock_at_write, PAGECACHE_PIN_LEFT_PINNED, - PAGECACHE_WRITE_DELAY, &page_link.link)) + PAGECACHE_WRITE_DELAY, &page_link.link, + LSN_IMPOSSIBLE)) DBUG_RETURN(1); DBUG_ASSERT(empty_space >= info->s->bitmap.sizes[0]); @@ -5037,7 +5041,8 @@ uint _ma_apply_redo_insert_row_head_or_tail(MARIA_HA *info, LSN lsn, &info->dfile, page, 0, buff, PAGECACHE_PLAIN_PAGE, unlock_method, unpin_method, - PAGECACHE_WRITE_DELAY, 0)) + PAGECACHE_WRITE_DELAY, 0, + LSN_IMPOSSIBLE)) DBUG_RETURN(my_errno); /* Fix bitmap */ @@ -5144,7 +5149,8 @@ uint _ma_apply_redo_purge_row_head_or_tail(MARIA_HA *info, LSN lsn, &info->dfile, page, 0, buff, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, - PAGECACHE_WRITE_DELAY, 0)) + PAGECACHE_WRITE_DELAY, 0, + LSN_IMPOSSIBLE)) result= my_errno; /* This will work even if the page was marked as UNALLOCATED_PAGE */ @@ -5224,7 +5230,8 @@ uint _ma_apply_redo_purge_blocks(MARIA_HA *info, &info->dfile, page+i, 0, buff, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, - PAGECACHE_WRITE_DELAY, 0)) + PAGECACHE_WRITE_DELAY, 0, + LSN_IMPOSSIBLE)) DBUG_RETURN(my_errno); } /** @todo leave bitmap lock to the bitmap code... */ diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 67830653824..f5bf7f58f9f 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -2059,6 +2059,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, 0, + LSN_IMPOSSIBLE, &translog_page_validator, (uchar*) &data)) { UNRECOVERABLE_ERROR(("Can't write page (%lu,0x%lx) to pagecache", diff --git a/storage/maria/ma_page.c b/storage/maria/ma_page.c index ac9e33f896a..15dc979cb4d 100644 --- a/storage/maria/ma_page.c +++ b/storage/maria/ma_page.c @@ -106,7 +106,7 @@ int _ma_write_keypage(register MARIA_HA *info, register MARIA_KEYDEF *keyinfo, level, buff, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, - PAGECACHE_WRITE_DELAY, 0)); + PAGECACHE_WRITE_DELAY, 0, LSN_IMPOSSIBLE)); } /* maria_write_keypage */ @@ -140,7 +140,7 @@ int _ma_dispose(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, my_off_t pos, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, - PAGECACHE_WRITE_DELAY, 0, + PAGECACHE_WRITE_DELAY, 0, LSN_IMPOSSIBLE, offset, sizeof(buff), 0, 0)); } /* _ma_dispose */ diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index ce4c915c4ee..20a73086091 100755 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -632,6 +632,24 @@ static uint pagecache_fwrite(PAGECACHE *pagecache, (pageno)<<(pagecache->shift), flags) +/** + @brief set rec_lsn of pagecache block (if it is needed) + + @param block block where to set rec_lsn + @param first_REDO_LSN_for_page the LSN to set +*/ + +static inline void pagecache_set_block_rec_lsn(PAGECACHE_BLOCK_LINK *block, + LSN first_REDO_LSN_for_page) +{ + if (block->rec_lsn == LSN_MAX) + block->rec_lsn= first_REDO_LSN_for_page; + else + DBUG_ASSERT(cmp_translog_addr(block->rec_lsn, + first_REDO_LSN_for_page) <= 0); +} + + /* next_power(value) is 2 at the power of (1+floor(log2(value))); e.g. next_power(2)=4, next_power(3)=4. @@ -2568,12 +2586,7 @@ void pagecache_unlock(PAGECACHE *pagecache, { DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK); DBUG_ASSERT(pin == PAGECACHE_UNPIN); - if (block->rec_lsn == LSN_MAX) - block->rec_lsn= first_REDO_LSN_for_page; - else - DBUG_ASSERT(cmp_translog_addr(block->rec_lsn, - first_REDO_LSN_for_page) <= 0); - + pagecache_set_block_rec_lsn(block, first_REDO_LSN_for_page); } if (lsn != LSN_IMPOSSIBLE) check_and_set_lsn(pagecache, lsn, block); @@ -2726,14 +2739,10 @@ void pagecache_unlock_by_link(PAGECACHE *pagecache, with WRITE lock that was temporarly converted to READ lock before it's unpinned */ - DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK || + DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK || lock == PAGECACHE_LOCK_READ_UNLOCK); DBUG_ASSERT(pin == PAGECACHE_UNPIN); - if (block->rec_lsn == LSN_MAX) - block->rec_lsn= first_REDO_LSN_for_page; - else - DBUG_ASSERT(cmp_translog_addr(block->rec_lsn, - first_REDO_LSN_for_page) <= 0); + pagecache_set_block_rec_lsn(block, first_REDO_LSN_for_page); } if (lsn != LSN_IMPOSSIBLE) check_and_set_lsn(pagecache, lsn, block); @@ -3153,25 +3162,27 @@ my_bool pagecache_delete_pages(PAGECACHE *pagecache, } -/* - Write a buffer into a cached file. - - SYNOPSIS - - pagecache_write_part() - pagecache pointer to a page cache data structure - file handler for the file to write data to - pageno number of the block of data in the file - level determines the weight of the data - buff buffer with the data - type type of the page - lock lock change - pin pin page - write_mode how to write page - link link to the page if we pin it - - RETURN VALUE - 0 if a success, 1 - otherwise. +/** + @brief Writes a buffer into a cached file. + + @param pagecache pointer to a page cache data structure + @param file handler for the file to write data to + @param pageno number of the block of data in the file + @param level determines the weight of the data + @param buff buffer with the data + @param type type of the page + @param lock lock change + @param pin pin page + @param write_mode how to write page + @param link link to the page if we pin it + @param first_REDO_LSN_for_page the lsn to set rec_lsn + @param offset offset in the page + @param size size of data + @param validator read page validator + @param validator_data the validator data + + @retval 0 if a success. + @retval 1 Error. */ /* description of how to change lock before and after write */ @@ -3235,6 +3246,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, enum pagecache_page_pin pin, enum pagecache_write_mode write_mode, PAGECACHE_BLOCK_LINK **link, + LSN first_REDO_LSN_for_page, uint offset, uint size, pagecache_disk_read_validator validator, uchar* validator_data) @@ -3364,6 +3376,15 @@ restart: block->status|= PCBLOCK_READ; } } + if (first_REDO_LSN_for_page) + { + /* single write action of the last write action */ + DBUG_ASSERT(lock == PAGECACHE_LOCK_WRITE_UNLOCK || + lock == PAGECACHE_LOCK_LEFT_UNLOCKED); + DBUG_ASSERT(pin == PAGECACHE_UNPIN || + pin == PAGECACHE_PIN_LEFT_UNPINNED); + pagecache_set_block_rec_lsn(block, first_REDO_LSN_for_page); + } if (need_lock_change) { diff --git a/storage/maria/ma_pagecache.h b/storage/maria/ma_pagecache.h index 64935a0fa36..6b5b9afbc19 100644 --- a/storage/maria/ma_pagecache.h +++ b/storage/maria/ma_pagecache.h @@ -201,12 +201,12 @@ extern uchar *pagecache_valid_read(PAGECACHE *pagecache, pagecache_disk_read_validator validator, uchar* validator_data); -#define pagecache_write(P,F,N,L,B,T,O,I,M,K) \ - pagecache_write_part(P,F,N,L,B,T,O,I,M,K,0,(P)->block_size,0,0) +#define pagecache_write(P,F,N,L,B,T,O,I,M,K,R) \ + pagecache_write_part(P,F,N,L,B,T,O,I,M,K,R,0,(P)->block_size,0,0) -#define pagecache_inject(P,F,N,L,B,T,O,I,K,V,D) \ +#define pagecache_inject(P,F,N,L,B,T,O,I,K,R,V,D) \ pagecache_write_part(P,F,N,L,B,T,O,I,PAGECACHE_WRITE_DONE, \ - K,0,(P)->block_size,V,D) + K,R,0,(P)->block_size,V,D) extern my_bool pagecache_write_part(PAGECACHE *pagecache, PAGECACHE_FILE *file, @@ -218,6 +218,7 @@ extern my_bool pagecache_write_part(PAGECACHE *pagecache, enum pagecache_page_pin pin, enum pagecache_write_mode write_mode, PAGECACHE_BLOCK_LINK **link, + LSN first_REDO_LSN_for_page, uint offset, uint size, pagecache_disk_read_validator validator, diff --git a/storage/maria/ma_preload.c b/storage/maria/ma_preload.c index 138bb94f7d0..182a7dbd5f5 100644 --- a/storage/maria/ma_preload.c +++ b/storage/maria/ma_preload.c @@ -100,7 +100,7 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves) PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, - PAGECACHE_WRITE_DONE, 0)) + PAGECACHE_WRITE_DONE, 0, LSN_IMPOSSIBLE)) goto err; } pos+= block_length; @@ -117,7 +117,8 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves) PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, - PAGECACHE_WRITE_DONE, 0)) + PAGECACHE_WRITE_DONE, 0, + LSN_IMPOSSIBLE)) goto err; pos+= length; } diff --git a/storage/maria/unittest/ma_pagecache_consist.c b/storage/maria/unittest/ma_pagecache_consist.c index 54491a09c3b..fb0c4fac541 100644 --- a/storage/maria/unittest/ma_pagecache_consist.c +++ b/storage/maria/unittest/ma_pagecache_consist.c @@ -237,7 +237,7 @@ void writer(int num) PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); if (i % flush_divider == 0) flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); @@ -380,7 +380,7 @@ int main(int argc __attribute__((unused)), PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); } flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); free(buffr); diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index 8add95e8a36..76209d37015 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -104,7 +104,7 @@ int simple_read_write_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); pagecache_read(&pagecache, &file1, 0, 3, (char*)buffr, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_LEFT_UNLOCKED, @@ -140,7 +140,7 @@ int simple_read_change_write_read_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); /* test */ pagecache_read(&pagecache, &file1, 0, 3, (char*)buffw, @@ -153,7 +153,7 @@ int simple_read_change_write_read_test() PAGECACHE_LOCK_WRITE_UNLOCK, PAGECACHE_UNPIN, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); pagecache_read(&pagecache, &file1, 0, 3, (char*)buffr, PAGECACHE_PLAIN_PAGE, @@ -194,7 +194,7 @@ int simple_pin_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); /* test */ if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE)) { @@ -210,14 +210,14 @@ int simple_pin_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); bfill(buffw + PAGE_SIZE/2, PAGE_SIZE/2, ((unsigned char) 129)); pagecache_write(&pagecache, &file1, 0, 3, (char*)buffw, PAGECACHE_PLAIN_PAGE, PAGECACHE_LOCK_WRITE_TO_READ, PAGECACHE_PIN_LEFT_PINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); /* We have to get error because one page of the file is pinned, other page should be flushed @@ -272,7 +272,7 @@ int simple_delete_forget_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); /* test */ bfill(buffw, PAGE_SIZE, '\2'); @@ -281,7 +281,7 @@ int simple_delete_forget_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); pagecache_delete(&pagecache, &file1, 0, PAGECACHE_LOCK_WRITE, 0); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); @@ -314,7 +314,7 @@ int simple_delete_flush_test() PAGECACHE_LOCK_WRITE, PAGECACHE_PIN, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); /* test */ bfill(buffw, PAGE_SIZE, '\2'); @@ -323,7 +323,7 @@ int simple_delete_flush_test() PAGECACHE_LOCK_LEFT_WRITELOCKED, PAGECACHE_PIN_LEFT_PINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); pagecache_delete(&pagecache, &file1, 0, PAGECACHE_LOCK_LEFT_WRITELOCKED, 1); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); @@ -362,7 +362,7 @@ int simple_big_test() PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); } desc[i].length= 0; desc[i].content= '\0'; diff --git a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c index fa6fcd544a3..c93f57fad01 100644 --- a/storage/maria/unittest/ma_test_loghandler_pagecache-t.c +++ b/storage/maria/unittest/ma_test_loghandler_pagecache-t.c @@ -129,7 +129,7 @@ int main(int argc __attribute__((unused)), char *argv[]) PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_PIN_LEFT_UNPINNED, PAGECACHE_WRITE_DELAY, - 0); + 0, LSN_IMPOSSIBLE); flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE); } if ((stat= my_stat(first_translog_file, &st, MYF(0))) == 0) |