Commit graph

591 commits

Author SHA1 Message Date
marko
020b6035be branches/zip: buf_page_init_for_read(): Increment the buf_fix_count
during the buf_zip_decompress() call.  Otherwise, the block may end
up being freed by another thread.  This bug was caught by the
page_zip_validate() check in buf_LRU_block_remove_hashed_page().
2007-01-10 12:50:10 +00:00
marko
1f7bc8e232 branches/zip: Remove a race condition.
buf_page_init_for_read(): Protect the buf_zip_decompress() call with
an X-lock on the block.

page_zip_validate(): Move the page_is_comp() assertion after the
page header comparison.
2007-01-10 10:08:34 +00:00
marko
b25ed2dac6 branches/zip: buf_buddy_free(): Add debug code for detecting live
objects in the free area.
2007-01-09 16:11:11 +00:00
marko
a0c093d93d branches/zip: buf_LRU_invalidate_tablespace(): After freeing a
compressed-only page, restart the scan of the LRU list, because
prev_bpage may have been relocated.

buf_LRU_block_remove_hashed_page(): Note that other compressed pages
or compressed-only blocks may be relocated when freeing a compressed
page or a compressed-only block descriptor.
2007-01-09 15:52:08 +00:00
marko
4c529eb09f branches/zip: Replace an ut_a() with ut_d(). This mistake was made in r1188. 2007-01-09 12:56:12 +00:00
marko
69afb619cc branches/zip: buf_LRU_free_block(): Correct the logic for releasing
dirty uncompressed blocks.  Move the page_zip_validate() call to
a more appropriate place, buf_LRU_block_remove_hashed_page().

buf_LRU_block_remove_hashed_page(): Allow bpage->oldest_modification != 0
for uncompressed pages if there is a compressed page that will be preserved.
Release the mutexes before calling buf_print() and buf_LRU_print().

page_zip_validate(): Remove the assertion containing the
buf_frame_get_page_zip() call.  We might already be holding buf_pool->mutex.
2007-01-09 12:47:15 +00:00
marko
f54da50c1e branches/zip: buf_buddy_alloc_clean(): Restart the scan after a
successful buf_LRU_free_block().

buf_LRU_free_block(): Note that buf_pool->mutex may be temporarily released.
2007-01-09 12:39:50 +00:00
marko
d3917bb5c3 branches/zip: buf_page_t: Introduce the field in_flush_list #ifdef UNIV_DEBUG.
buf_flush_batch(): Remove the local variable "found".
2007-01-09 12:35:42 +00:00
marko
5a094438a5 branches/zip: Maintain a valid checksum for compressed-only pages kept in
the buffer pool.

buf_LRU_free_block(): When preserving the compressed page, compute the
checksum.  Also assert page_zip_validate().

buf_zip_decompress(): Add parameter "check" for enabling checksum tests.
Before decompressing a compressed-only page from the buffer pool, verify
the compressed page checksum.
2007-01-08 17:08:57 +00:00
marko
186549b911 branches/zip: buf_LRU_free_block(): Check if the block has been reloaded
to the buffer pool while we were not holding buf_pool->mutex.  If it was,
do not attempt to preserve the compressed page.
2007-01-08 14:58:20 +00:00
marko
9d9714b8f3 branches/zip: page_zip_fields_decode(): Do not dereference a null pointer. 2007-01-08 12:32:31 +00:00
marko
e5c3aa1224 branches/zip: Make zlib use InnoDB memory heaps.
page_zip_malloc(): Replace ut_malloc(...) with mem_heap_alloc(opaque, ...).

page_zip_free(): Dummy function (cannot deallocate from InnoDB memory
heaps, and zlib seems to defer deallocation to the very end anyway).

page_zip_compress(): Create a big enough heap for the needs of zlib.
Replace deflateInit() with deflateInit2().

page_zip_decompress(): Create a big enough heap for the needs of zlib.
Replace inflateInit() with inflateInit2().
2007-01-05 21:15:05 +00:00
marko
0583d98529 branches/zip: buf_get_latched_pages_number(): Count compressed-only blocks too. 2007-01-05 21:00:07 +00:00
marko
e81c916b27 branches/zip: mem_heap_create_block(), mem_heap_create_func():
Remove the unused parameter init_block.

mem_heap_fast_create(): Remove.

struct mem_block_info_struct: Remove the field init_block.
2007-01-05 20:59:40 +00:00
marko
27ded6f71e branches/zip: Support compressed-only pages in buf_page_create().
buf_page_get_gen(): Note that buf_read_page() may uncompress
a compressed-only page.

buf_page_create(): Test buf_page_in_file() instead of BUF_BLOCK_FILE_PAGE.
2007-01-05 14:03:44 +00:00
marko
13d6355676 branches/zip: buf_validate(): Validate also the compressed-only blocks. 2007-01-05 12:13:28 +00:00
marko
51d0b62947 branches/zip: buf_page_peek(): Return TRUE also if the page exists in the
buffer pool in compressed form only.

buf_page_peek_block(): Remove.

mutex_enter_fast_func: Remove.
2007-01-05 11:19:56 +00:00
marko
e2db2a873f branches/zip: buf_pool_page_hash_rebuild(): Rebuild also buf_pool->zip_hash
and add compressed-only pages to buf_pool->page_hash.

BUF_POOL_ZIP_FOLD(), BUF_POOL_ZIP_FOLD_PTR(), BUF_POOL_ZIP_FOLD_BPAGE():
Macros for computing buf_pool->zip_hash fold values.  Make use of these
in buf0buddy.c.

buf0buddy.c: Replace some ptr == ut_align_down(ptr, ...) in assertions with
!ut_align_offset(ptr, ...).
2007-01-05 10:49:56 +00:00
marko
91c87cd343 branches/zip: Allow dirty blocks to be relocated. Allow a transition
to BUF_BLOCK_ZIP_DIRTY (discarding the uncompressed page corresponding
to a modified compressed page that has not been flushed to disk).

buf_page_can_relocate(): New function, modelled after
buf_flush_ready_for_replace().

buf_LRU_free_block(): Allow the transition to BUF_BLOCK_ZIP_DIRTY.

buf_flush_insert_into_flush_list(): Make the prototype public.

buf_buddy_relocate(): Remove an unnecessary switch statement.
Use buf_page_can_relocate() instead of buf_flush_ready_for_replace().

buf_page_peek(): Made UNIV_INLINE.

Document UNIV_ZIP_DEBUG.
2007-01-04 21:40:10 +00:00
marko
ede8e7bcd0 branches/zip: Fix two bugs in the relocation of block descriptors.
Improve diagnostics.

buf_buddy_relocate(): Do not assume all small blocks to contain only one
buf_page_t object.  Require an exact size match, as in the case of
compressed pages.

buf_relocate(): Relocate buf_pool->LRU_old if needed.
Validate the LRU list in debug builds.

buf_LRU_block_remove_hashed_page(): Do not overwrite FIL_PAGE_OFFSET
or FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID.  The memory will be invalidated
in debug builds of buf_buddy_free().

buf0buddy.c: Add assertions for not holding buf_pool->zip_mutex.
The calling thread should not be holding any block->mutex, but it might
be too time-consuming to assert against that, even #ifdef UNIV_SYNC_DEBUG.
2007-01-04 15:45:42 +00:00
marko
324df09d57 buf_flush_validate_low(): Minor cleanup. 2007-01-03 15:55:36 +00:00
marko
bb9217faa6 branches/zip: Before calling buf_buddy_alloc() or buf_buddy_free(),
release any block mutexes but hold the buf_pool->mutex.
2007-01-03 15:54:05 +00:00
marko
f890ec156c branches/zip: Use the buddy allocator for managing compressed pages.
There is something wrong with the management of compressed-only blocks
(BUF_BLOCK_ZIP_PAGE).  To disable the creation of such blocks, set zip=TRUE
in buf_LRU_block_remove_hashed_page().

buf_LRU_block_remove_hashed_page(): Release buf_pool->zip_mutex when
freeing a compressed-only page and its control block, with buf_buddy_free().
Adapt callers.

buf_LRU_block_free_hashed_page(): Change the parameter type from buf_page_t*
to buf_block_t*.

buf_LRU_free_block(): Move below the definition of buf_LRU_add_block_low().
Allocate block descriptor for compressed-only blocks.

buf_LRU_block_free_non_file_page(): Replace ut_free() with buf_buddy_free().

buf_zip_decompress(): New function, split from buf_page_io_complete().

buf_page_init_for_read(): Do not allocate the compressed page until it is
really needed, to avoid the overhead of the buddy allocator.  Decompress
compressed-only blocks that are needed again.

buf_page_create(): Do not allocate the compressed page until it is
really needed, to avoid the overhead of the buddy allocator.

buf_validate(): Replace some equality tests on the lengths of the LRU
list and the flush lists with greater-or-equal tests, since the counted
numbers do not include control blocks for compressed-only pages.
2007-01-03 13:10:46 +00:00
marko
0b89bb7905 branches/zip: Add __attribute__((const)) or __attribute__((pure))
to all fold functions.
2007-01-03 12:34:54 +00:00
marko
81334fe6de branches/zip: trx_prepare_off_kernel(): Eliminate the local variable
must_flush_log, and remove warning about lsn being possibly uninitialized.
2007-01-03 12:34:04 +00:00
marko
1b8f466cea branches/zip: buf_page_get_gen(): When checking a guessed block,
also check buf_page_in_file().  This error was introduced in r1082.
2007-01-02 21:25:40 +00:00
marko
7fbc4f2bc0 branches/zip: Merge revisions 1009:1165 from trunk. 2007-01-02 14:36:59 +00:00
marko
75e35eb7c0 branches/zip: Minor cleanup.
buf_buddy_get(): New function in buf0buddy.c, to replace the macro
in buf0buddy.h.

buf_buddy_get_offset(): Remove.

buf_buddy_get_slot(): Remove the prototype from buf0buddy.h.  This function
is for internal use in buf0buddy.ic.
2006-12-29 09:13:57 +00:00
marko
c087a5d559 branches/zip: Minor cleanup.
buf_page_get_gen(): Cache the result of fil_space_get_zip_size().

trx_commit_off_kernel(): Eliminate the flag must_flush_log.  Initialize lsn = 0
to signify must_flush_log == FALSE.

log_flush_margin(): Eliminate the flag do_flush.  Initialize lsn = 0
to signify do_flush == FALSE.
2006-12-29 09:07:01 +00:00
marko
631da97d5f branches/zip: Fix two bugs in the buddy allocator.
buf_buddy_block_free(): Remove the block from buf_pool->zip_hash.

buf_buddy_alloc_clean(): Test for buf_page_in_file() before
invoking buf_LRU_free_block().  The LRU list also contains "half-freed"
blocks (state == BUF_BLOCK_REMOVE_HASH).
2006-12-21 14:59:41 +00:00
marko
9244a3a503 branches/zip: Allow the buddy allocator to work for 16-kilobyte pages,
twice the maximum block size of the buddy system.

buf_page_t: Note that state may change from BUF_BLOCK_READY_FOR_USE
to BUF_BLOCK_MEMORY without buf_page_get_mutex() protection
[only buf_pool->mutex].

buf_buddy_get_slot(): Extend the output to BUF_BUDDY_SIZES.

buf_buddy_alloc(), buf_buddy_free(): Allow sizes up to UNIV_PAGE_SIZE.

buf_buddy_alloc_low(), buf_buddy_free_low(), buf_buddy_alloc_clean():
Allow i==BUF_BUDDY_SIZES.
2006-12-20 15:56:58 +00:00
marko
77417e46f1 branches/zip: buf_page_get_gen(): Restore the "break" statement to a
"for (;;)" loop that was accidentally removed in r1090.
2006-12-20 14:07:08 +00:00
marko
cf96318a9a branches/zip: buf_buddy_free_low(): When trying to relocate to a block on
the free list, remove the free block from the free list, so that the list
item pointers will not be overwritten.
2006-12-20 13:29:02 +00:00
marko
fe1e339fa0 branches/zip: Fix bugs in the buddy allocator and add assertions.
buf_buddy_free(), buf_buddy_free_low(): Document that the data must
not be pointed to by the buffer pool.  Add ut_ad(!buf_pool_contains_zip())
assertions to catch pointers to freed blocks.

Validate the zip_free[] lists #ifdef UNIV_DEBUG.

buf_buddy_relocate(): Ensure that the size of the compressed page
matches.  The buddy block can be split, and the control block can be
pointing to a smaller compressed page than the one whose relocation
is being attempted.
2006-12-20 11:38:19 +00:00
marko
3b2806f48f branches/zip: Add the debug function buf_pool_contains_zip() #ifdef UNIV_DEBUG. 2006-12-19 22:12:44 +00:00
marko
483cf9bee9 branches/zip: Correct some bugs in the buddy allocator and add debug code.
buf_buddy_alloc_zip() [UNIV_DEBUG]: Byte-fill the allocated blocks with ~i.

buf_buddy_block_free() [UNIV_DEBUG]: Clear the frame before releasing it
to the buffer pool.

buf_buddy_alloc_from() [UNIV_DEBUG]: Byte-fill the free blocks with j.

buf_buddy_relocate(): Allow the buf_page_hash_get() lookup to fail,
and note the reason.

buf_buddy_free_low(): Correctly compute the address of the combined free block.

buf_page_struct: Clarify the mutex protection rules.  Note that
the pointer zip.data is also protected by buf_pool->mutex.
2006-12-19 12:38:18 +00:00
marko
0a70979184 branches/zip: buf_buddy_free_low(): Examine the state bits inside the
block before traversing the free list.
2006-12-18 12:55:04 +00:00
marko
2eb7e547c3 branches/zip: buf_buddy_free_low(): Use a byte pointer in arithmetics.
buf_buddy_get(): Document that "page" should be a pointer to char or byte.
2006-12-18 12:39:39 +00:00
marko
e5e1a17414 branches/zip: Fix some bugs in the buddy allocator.
buf_buddy_alloc_zip(): Calculate the address with char* aritmetics.

buf_buddy_alloc_clean(): Acquire a mutex on the block before
calling buf_LRU_free_block().

buf_buddy_relocate(): Remove the bogus assertion about src and dst
being buddies of each other.  Use mach_read_from_4() instead of
page_get_space_id() and page_get_page_no() to avoid page alignment
assertions.

buf_buddy_free_low(): Replace bogus assertions.
2006-12-18 11:23:58 +00:00
marko
492cd8ce19 branches/zip: Minor improvements.
buf_LRU_block_remove_hashed_page(): Return the new state of the block.

Only call buf_LRU_block_free_hashed_page()
if buf_LRU_block_remove_hashed_page() did not return BUF_BLOCK_ZIP_FREE,
that is, the control block was not freed.

buf_LRU_insert_zip_clean(): New function, for inserting a compressed-only
block into buf_pool->zip_clean in the LRU order.

buf_LRU_block_remove_hashed_page(), buf_LRU_free_block():
Add the flag "zip" for controlling if the compressed page of an uncompressed
page should be removed.  For now, assume zip==TRUE.

buf_LRU_get_free_block(): Replace the test for UT_LIST_GET_LEN(buf_pool->free)
with a test for the return value of buf_LRU_get_free_only().  Do not
free zip.data, as it must already have been freed.

buf_flush_insert_into_flush_list(), buf_flush_insert_sorted_into_flush_list():
Remove compressed-only blocks from the buf_pool->zip_clean list.

buf_flush_remove(): Restore compressed-only blocks to
the buf_pool->zip_clean list.

buf_page_init_for_read(): Uncompress compressed-only blocks when possible.
Currently, there cannot be any compressed-only blocks in the buffer pool;
they would be inserted by buf_LRU_free_block(bpage, zip=FALSE).
2006-12-15 15:05:18 +00:00
marko
0fb620f58d branches/zip: Minor improvements.
buf_flush_remove(): New function, for removing a block from the flush list.
Sliced from buf_flush_write_complete().

buf_page_set_state(): Allow transitions between BUF_BLOCK_ZIP_PAGE
and BUF_BLOCK_ZIP_DIRTY.
2006-12-15 14:47:04 +00:00
marko
797822636d branches/zip: Refactor some code for relocating buffer control blocks.
buf_relocate(): New function, split from buf_buddy_relocate().
2006-12-14 15:15:51 +00:00
marko
cb530ba3e7 branches/zip: Make use of the previously unused state BUF_BLOCK_MEMORY.
buf_LRU_get_free_block(): Document that the block is in the state
BUF_BLOCK_READY_FOR_USE.

buf_block_alloc(): Change the state of the block to BUF_BLOCK_MEMORY
and document it.

Replace those invocations of buf_block_alloc() with
buf_LRU_get_free_block() where the allocated block is used for buffer
pool input and output.  However, temporary copies of B-tree pages
during reorganization are not used for file I/O, and such blocks are
still allocated with buf_block_alloc().
2006-12-13 14:58:54 +00:00
marko
310b625ef5 branches/zip: Make the buddy allocator reclaim blocks from the end of
the LRU list regardless of their size.

buf_buddy_alloc_clean_zip(): Rename to buf_buddy_alloc_clean(),
now that also uncompressed blocks can be reclaimed.
Use buf_buddy_alloc_zip() instead of reusing the freed block
directly, since buf_buddy_free() may combine blocks.
2006-12-12 16:28:22 +00:00
marko
5688c68737 branches/zip: Correct the names of two function parameters in buf0flu.ic. 2006-12-12 12:21:11 +00:00
marko
ff5f343b2d branches/zip: Minor improvements to the buddy allocator.
buf_buddy_alloc(), buf_buddy_alloc_low(): Add parameter "lru" for
enabling allocation from the list of least-recently-used blocks.

buf_buddy_alloc_low(): Release buf_pool->mutex while calling
buf_LRU_get_free_block().
2006-12-12 12:14:58 +00:00
marko
91aae17842 branches/zip: Make the code compile with all debugging enabled
buf_buddy_relocate(): Replace ut_align_down() with ut_align_offset()
in assertions.

buf0buddy.h: Include buf0buf.h and sync0sync.h.
2006-12-11 15:48:37 +00:00
marko
f9a10f4cef branches/zip: Implement the whole allocation algorithm of compressed pages.
buf_LRU_free_block(): Free compressed-only pages and their
descriptors with buf_buddy_free().

buf_LRU_get_free_only(): New function for returning a block from
buf_pool->free if one is available.  Split from buf_LRU_get_free_block().

buf_buddy_alloc_zip(): Rename from buf_buddy_alloc_low() and make static.
Remove parameter "split".  Always try to split.

buf_buddy_free_block(): Rename to buf_buddy_block_free().

buf_buddy_block_register(): New function for registering buf_block_t
objects reserved by the allocator.

buf_buddy_alloc_from(): New function for allocating an object from a
bigger object, and putting the unused parts on the free list.

buf_buddy_alloc_clean_zip(): New function for allocating memory by
replacing an unmodified compressed page.

buf_buddy_alloc_low(): New function for allocating memory, either from
the free lists of compressed pages, from the global free list, or from
unmodified pages in the buffer pool.
2006-12-11 14:27:43 +00:00
marko
9bf07dae11 branches/zip: buf_buddy_relocate(): Split some lines differently on
popular demand.
2006-12-11 09:59:06 +00:00
marko
d387f148b4 branches/zip: Add buf_pool->zip_hash for keeping track on pages allocated
to the buddy system for allocating compressed pages and their descriptors.

buf_buddy_free_block(): New function: Deallocate the buffer frame.

buf_buddy_free(), buf_buddy_free_low(): Return void instead of a pointer
to a freed buffer frame.
2006-12-11 09:54:13 +00:00