Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8258a348
Commit
8258a348
authored
May 14, 2015
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InnoDB: check if scrubbing is enabled before scanning the tablespace
parent
a94cabd5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
88 additions
and
88 deletions
+88
-88
mysql-test/suite/encryption/r/innodb-encr-threads.result
mysql-test/suite/encryption/r/innodb-encr-threads.result
+1
-1
mysql-test/suite/encryption/t/innodb-encr-threads.test
mysql-test/suite/encryption/t/innodb-encr-threads.test
+1
-1
storage/innobase/fil/fil0crypt.cc
storage/innobase/fil/fil0crypt.cc
+43
-43
storage/xtradb/fil/fil0crypt.cc
storage/xtradb/fil/fil0crypt.cc
+43
-43
No files found.
mysql-test/suite/encryption/r/innodb-encr-threads.result
View file @
8258a348
...
...
@@ -2,6 +2,6 @@ create table t1 (i int) engine=innodb;
set global innodb_encryption_threads = 1;
set global innodb_encryption_rotate_key_age = 2;
insert t1 values (1);
drop table t1;
set global innodb_encryption_threads = 0;
set global innodb_encryption_rotate_key_age = 1;
drop table t1;
mysql-test/suite/encryption/t/innodb-encr-threads.test
View file @
8258a348
...
...
@@ -8,7 +8,7 @@ create table t1 (i int) engine=innodb;
set
global
innodb_encryption_threads
=
1
;
set
global
innodb_encryption_rotate_key_age
=
2
;
insert
t1
values
(
1
);
drop
table
t1
;
set
global
innodb_encryption_threads
=
0
;
set
global
innodb_encryption_rotate_key_age
=
1
;
drop
table
t1
;
storage/innobase/fil/fil0crypt.cc
View file @
8258a348
...
...
@@ -1143,16 +1143,51 @@ fil_crypt_start_encrypting_space(
return
pending_op
;
}
/** State of a rotation thread */
struct
rotate_thread_t
{
explicit
rotate_thread_t
(
uint
no
)
{
memset
(
this
,
0
,
sizeof
(
*
this
));
thread_no
=
no
;
first
=
true
;
estimated_max_iops
=
20
;
}
uint
thread_no
;
bool
first
;
/*!< is position before first space */
ulint
space
;
/*!< current space */
ulint
offset
;
/*!< current offset */
ulint
batch
;
/*!< #pages to rotate */
uint
min_key_version_found
;
/*!< min key version found but not rotated */
lsn_t
end_lsn
;
/*!< max lsn when rotating this space */
uint
estimated_max_iops
;
/*!< estimation of max iops */
uint
allocated_iops
;
/*!< allocated iops */
uint
cnt_waited
;
/*!< #times waited during this slot */
uint
sum_waited_us
;
/*!< wait time during this slot */
fil_crypt_stat_t
crypt_stat
;
// statistics
btr_scrub_t
scrub_data
;
/* thread local data used by btr_scrub-functions
* when iterating pages of tablespace */
/* check if this thread should shutdown */
bool
should_shutdown
()
const
{
return
!
(
srv_shutdown_state
==
SRV_SHUTDOWN_NONE
&&
thread_no
<
srv_n_fil_crypt_threads
);
}
};
/***********************************************************************
Check if space needs rotation given a key_state
@return true if space needs key rotation */
static
bool
fil_crypt_space_needs_rotation
(
uint
space
,
/*!< in: FIL space id
*/
rotate_thread_t
*
state
,
/*!< in: Key rotation state
*/
key_state_t
*
key_state
,
/*!< in: Key state */
bool
*
recheck
)
/*!< out: needs recheck ? */
{
ulint
space
=
state
->
space
;
if
(
fil_space_get_type
(
space
)
!=
FIL_TABLESPACE
)
{
return
false
;
}
...
...
@@ -1217,10 +1252,14 @@ fil_crypt_space_needs_rotation(
crypt_data
->
min_key_version
,
key_state
->
key_version
,
key_state
->
rotate_key_age
);
crypt_data
->
rotate_state
.
scrubbing
.
is_active
=
btr_scrub_start_space
(
space
,
&
state
->
scrub_data
);
time_t
diff
=
time
(
0
)
-
crypt_data
->
rotate_state
.
scrubbing
.
last_scrub_completed
;
bool
need_scrubbing
=
diff
>=
srv_background_scrub_data_interval
;
crypt_data
->
rotate_state
.
scrubbing
.
is_active
&&
diff
>=
srv_background_scrub_data_interval
;
if
(
need_key_rotation
==
false
&&
need_scrubbing
==
false
)
break
;
...
...
@@ -1239,40 +1278,6 @@ fil_crypt_space_needs_rotation(
return
false
;
}
/** State of a rotation thread */
struct
rotate_thread_t
{
explicit
rotate_thread_t
(
uint
no
)
{
memset
(
this
,
0
,
sizeof
(
*
this
));
thread_no
=
no
;
first
=
true
;
estimated_max_iops
=
20
;
}
uint
thread_no
;
bool
first
;
/*!< is position before first space */
ulint
space
;
/*!< current space */
ulint
offset
;
/*!< current offset */
ulint
batch
;
/*!< #pages to rotate */
uint
min_key_version_found
;
/*!< min key version found but not rotated */
lsn_t
end_lsn
;
/*!< max lsn when rotating this space */
uint
estimated_max_iops
;
/*!< estimation of max iops */
uint
allocated_iops
;
/*!< allocated iops */
uint
cnt_waited
;
/*!< #times waited during this slot */
uint
sum_waited_us
;
/*!< wait time during this slot */
fil_crypt_stat_t
crypt_stat
;
// statistics
btr_scrub_t
scrub_data
;
/* thread local data used by btr_scrub-functions
* when iterating pages of tablespace */
/* check if this thread should shutdown */
bool
should_shutdown
()
const
{
return
!
(
srv_shutdown_state
==
SRV_SHUTDOWN_NONE
&&
thread_no
<
srv_n_fil_crypt_threads
);
}
};
/***********************************************************************
Update global statistics with thread statistics */
static
void
...
...
@@ -1485,8 +1490,7 @@ fil_crypt_find_space_to_rotate(
while
(
!
state
->
should_shutdown
()
&&
state
->
space
!=
ULINT_UNDEFINED
)
{
ulint
space
=
state
->
space
;
if
(
fil_crypt_space_needs_rotation
(
space
,
key_state
,
recheck
))
{
if
(
fil_crypt_space_needs_rotation
(
state
,
key_state
,
recheck
))
{
ut_ad
(
key_state
->
key_id
);
/* init state->min_key_version_found before
* starting on a space */
...
...
@@ -1494,7 +1498,7 @@ fil_crypt_find_space_to_rotate(
return
true
;
}
state
->
space
=
fil_get_next_space
(
space
);
state
->
space
=
fil_get_next_space
(
s
tate
->
s
pace
);
}
/* if we didn't find any space return iops */
...
...
@@ -1541,10 +1545,6 @@ fil_crypt_start_rotate_space(
state
->
min_key_version_found
=
crypt_data
->
rotate_state
.
min_key_version_found
;
/* inform scrubbing */
crypt_data
->
rotate_state
.
scrubbing
.
is_active
=
btr_scrub_start_space
(
space
,
&
state
->
scrub_data
);
mutex_exit
(
&
crypt_data
->
mutex
);
}
...
...
storage/xtradb/fil/fil0crypt.cc
View file @
8258a348
...
...
@@ -1143,16 +1143,51 @@ fil_crypt_start_encrypting_space(
return
pending_op
;
}
/** State of a rotation thread */
struct
rotate_thread_t
{
explicit
rotate_thread_t
(
uint
no
)
{
memset
(
this
,
0
,
sizeof
(
*
this
));
thread_no
=
no
;
first
=
true
;
estimated_max_iops
=
20
;
}
uint
thread_no
;
bool
first
;
/*!< is position before first space */
ulint
space
;
/*!< current space */
ulint
offset
;
/*!< current offset */
ulint
batch
;
/*!< #pages to rotate */
uint
min_key_version_found
;
/*!< min key version found but not rotated */
lsn_t
end_lsn
;
/*!< max lsn when rotating this space */
uint
estimated_max_iops
;
/*!< estimation of max iops */
uint
allocated_iops
;
/*!< allocated iops */
uint
cnt_waited
;
/*!< #times waited during this slot */
uint
sum_waited_us
;
/*!< wait time during this slot */
fil_crypt_stat_t
crypt_stat
;
// statistics
btr_scrub_t
scrub_data
;
/* thread local data used by btr_scrub-functions
* when iterating pages of tablespace */
/* check if this thread should shutdown */
bool
should_shutdown
()
const
{
return
!
(
srv_shutdown_state
==
SRV_SHUTDOWN_NONE
&&
thread_no
<
srv_n_fil_crypt_threads
);
}
};
/***********************************************************************
Check if space needs rotation given a key_state
@return true if space needs key rotation */
static
bool
fil_crypt_space_needs_rotation
(
uint
space
,
/*!< in: FIL space id
*/
rotate_thread_t
*
state
,
/*!< in: Key rotation state
*/
key_state_t
*
key_state
,
/*!< in: Key state */
bool
*
recheck
)
/*!< out: needs recheck ? */
{
ulint
space
=
state
->
space
;
if
(
fil_space_get_type
(
space
)
!=
FIL_TABLESPACE
)
{
return
false
;
}
...
...
@@ -1217,10 +1252,14 @@ fil_crypt_space_needs_rotation(
crypt_data
->
min_key_version
,
key_state
->
key_version
,
key_state
->
rotate_key_age
);
crypt_data
->
rotate_state
.
scrubbing
.
is_active
=
btr_scrub_start_space
(
space
,
&
state
->
scrub_data
);
time_t
diff
=
time
(
0
)
-
crypt_data
->
rotate_state
.
scrubbing
.
last_scrub_completed
;
bool
need_scrubbing
=
diff
>=
srv_background_scrub_data_interval
;
crypt_data
->
rotate_state
.
scrubbing
.
is_active
&&
diff
>=
srv_background_scrub_data_interval
;
if
(
need_key_rotation
==
false
&&
need_scrubbing
==
false
)
break
;
...
...
@@ -1239,40 +1278,6 @@ fil_crypt_space_needs_rotation(
return
false
;
}
/** State of a rotation thread */
struct
rotate_thread_t
{
explicit
rotate_thread_t
(
uint
no
)
{
memset
(
this
,
0
,
sizeof
(
*
this
));
thread_no
=
no
;
first
=
true
;
estimated_max_iops
=
20
;
}
uint
thread_no
;
bool
first
;
/*!< is position before first space */
ulint
space
;
/*!< current space */
ulint
offset
;
/*!< current offset */
ulint
batch
;
/*!< #pages to rotate */
uint
min_key_version_found
;
/*!< min key version found but not rotated */
lsn_t
end_lsn
;
/*!< max lsn when rotating this space */
uint
estimated_max_iops
;
/*!< estimation of max iops */
uint
allocated_iops
;
/*!< allocated iops */
uint
cnt_waited
;
/*!< #times waited during this slot */
uint
sum_waited_us
;
/*!< wait time during this slot */
fil_crypt_stat_t
crypt_stat
;
// statistics
btr_scrub_t
scrub_data
;
/* thread local data used by btr_scrub-functions
* when iterating pages of tablespace */
/* check if this thread should shutdown */
bool
should_shutdown
()
const
{
return
!
(
srv_shutdown_state
==
SRV_SHUTDOWN_NONE
&&
thread_no
<
srv_n_fil_crypt_threads
);
}
};
/***********************************************************************
Update global statistics with thread statistics */
static
void
...
...
@@ -1485,8 +1490,7 @@ fil_crypt_find_space_to_rotate(
while
(
!
state
->
should_shutdown
()
&&
state
->
space
!=
ULINT_UNDEFINED
)
{
ulint
space
=
state
->
space
;
if
(
fil_crypt_space_needs_rotation
(
space
,
key_state
,
recheck
))
{
if
(
fil_crypt_space_needs_rotation
(
state
,
key_state
,
recheck
))
{
ut_ad
(
key_state
->
key_id
);
/* init state->min_key_version_found before
* starting on a space */
...
...
@@ -1494,7 +1498,7 @@ fil_crypt_find_space_to_rotate(
return
true
;
}
state
->
space
=
fil_get_next_space
(
space
);
state
->
space
=
fil_get_next_space
(
s
tate
->
s
pace
);
}
/* if we didn't find any space return iops */
...
...
@@ -1541,10 +1545,6 @@ fil_crypt_start_rotate_space(
state
->
min_key_version_found
=
crypt_data
->
rotate_state
.
min_key_version_found
;
/* inform scrubbing */
crypt_data
->
rotate_state
.
scrubbing
.
is_active
=
btr_scrub_start_space
(
space
,
&
state
->
scrub_data
);
mutex_exit
(
&
crypt_data
->
mutex
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment