Commit cf7b6e91 authored by marko's avatar marko

branches/zip: Move all fields that are not needed in compression or

decompression from page_zip_des_t to buf_page_t, because the fields
needed in compression are modified without holding the block mutex.
All writes to bit-fields sharing a machine word must be protected
by the same mutex or rw-lock.
parent 61a48f1e
...@@ -616,7 +616,7 @@ buf_block_init( ...@@ -616,7 +616,7 @@ buf_block_init(
block->n_pointers = 0; block->n_pointers = 0;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
page_zip_des_init(&block->page.zip); page_zip_des_init(&block->page.zip);
block->page.zip.state = BUF_BLOCK_NOT_USED; block->page.state = BUF_BLOCK_NOT_USED;
mutex_create(&block->mutex, SYNC_BUF_BLOCK); mutex_create(&block->mutex, SYNC_BUF_BLOCK);
......
...@@ -2663,8 +2663,7 @@ fil_create_new_single_table_tablespace( ...@@ -2663,8 +2663,7 @@ fil_create_new_single_table_tablespace(
page_zip_des_t page_zip; page_zip_des_t page_zip;
page_zip_set_size(&page_zip, zip_size); page_zip_set_size(&page_zip, zip_size);
page_zip.data = page + UNIV_PAGE_SIZE; page_zip.data = page + UNIV_PAGE_SIZE;
page_zip.state = page_zip.n_blobs page_zip.n_blobs = page_zip.m_start = page_zip.m_end = 0;
= page_zip.m_start = page_zip.m_end = 0;
buf_flush_init_for_writing(page, &page_zip, 0); buf_flush_init_for_writing(page, &page_zip, 0);
ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size); ret = os_file_write(path, file, page_zip.data, 0, 0, zip_size);
} }
......
...@@ -737,11 +737,22 @@ buf_get_free_list_len(void); ...@@ -737,11 +737,22 @@ buf_get_free_list_len(void);
for compressed and uncompressed frames */ for compressed and uncompressed frames */
struct buf_page_struct{ struct buf_page_struct{
/* None of the following bit-fields must be modified without
holding block->mutex, since they can be stored in the same
machine word. Some of them are additionally protected by
buf_pool->mutex. */
ulint space:32; /* tablespace id */ ulint space:32; /* tablespace id */
ulint offset:32; /* page number */ ulint offset:32; /* page number */
page_zip_des_t zip; /* compressed page; zip.state
and zip.flush_type are relevant ulint state:3; /* state of the control block
for all pages */ (@see enum buf_page_state); also
protected by buf_pool->mutex */
ulint flush_type:2; /* if this block is currently being
flushed to disk, this tells the
flush_type (@see enum buf_flush) */
page_zip_des_t zip; /* compressed page */
buf_page_t* hash; /* node used in chaining to the page buf_page_t* hash; /* node used in chaining to the page
hash table */ hash table */
......
...@@ -92,7 +92,7 @@ buf_page_get_state( ...@@ -92,7 +92,7 @@ buf_page_get_state(
/* out: state */ /* out: state */
const buf_page_t* bpage) /* in: pointer to the control block */ const buf_page_t* bpage) /* in: pointer to the control block */
{ {
enum buf_page_state state = bpage->zip.state; enum buf_page_state state = bpage->state;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
switch (state) { switch (state) {
...@@ -157,7 +157,7 @@ buf_block_set_state( ...@@ -157,7 +157,7 @@ buf_block_set_state(
break; break;
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
block->page.zip.state = state; block->page.state = state;
ut_ad(buf_block_get_state(block) == state); ut_ad(buf_block_get_state(block) == state);
} }
...@@ -193,7 +193,7 @@ buf_page_get_flush_type( ...@@ -193,7 +193,7 @@ buf_page_get_flush_type(
/* out: flush type */ /* out: flush type */
const buf_page_t* bpage) /* in: buffer page */ const buf_page_t* bpage) /* in: buffer page */
{ {
enum buf_flush flush_type = bpage->zip.flush_type; enum buf_flush flush_type = bpage->flush_type;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
switch (flush_type) { switch (flush_type) {
...@@ -217,7 +217,7 @@ buf_page_set_flush_type( ...@@ -217,7 +217,7 @@ buf_page_set_flush_type(
buf_page_t* bpage, /* in: buffer page */ buf_page_t* bpage, /* in: buffer page */
enum buf_flush flush_type) /* in: flush type */ enum buf_flush flush_type) /* in: flush type */
{ {
bpage->zip.flush_type = flush_type; bpage->flush_type = flush_type;
ut_ad(buf_page_get_flush_type(bpage) == flush_type); ut_ad(buf_page_get_flush_type(bpage) == flush_type);
} }
......
...@@ -31,13 +31,8 @@ page0*.h includes rem0rec.h and may include rem0rec.ic. */ ...@@ -31,13 +31,8 @@ page0*.h includes rem0rec.h and may include rem0rec.ic. */
struct page_zip_des_struct struct page_zip_des_struct
{ {
page_zip_t* data; /* compressed page data */ page_zip_t* data; /* compressed page data */
ulint state:3; /* state of the control block
(cf. enum buf_page_state) */ ulint :17; /* reserved */
ulint flush_type:2; /* if this block is currently being
flushed to disk, this tells the
flush_type (cf. enum buf_flush);
protected by block->mutex */
ulint :9; /* reserved */
ulint n_blobs:12; /* number of externally stored ulint n_blobs:12; /* number of externally stored
columns on the page; the maximum columns on the page; the maximum
is 744 on a 16 KiB page */ is 744 on a 16 KiB 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