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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
0064316f
Commit
0064316f
authored
Dec 03, 2021
by
Eugene Kosov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: reduce code bloat
parent
fa132551
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
61 deletions
+60
-61
storage/innobase/include/log0log.h
storage/innobase/include/log0log.h
+0
-20
storage/innobase/log/log0log.cc
storage/innobase/log/log0log.cc
+60
-41
No files found.
storage/innobase/include/log0log.h
View file @
0064316f
...
...
@@ -346,26 +346,6 @@ or the MySQL version that created the redo log file. */
header */
#define LOG_FILE_HDR_SIZE (4 * OS_FILE_LOG_BLOCK_SIZE)
/** Memory mapped file */
class
mapped_file_t
{
public:
mapped_file_t
()
=
default
;
mapped_file_t
(
const
mapped_file_t
&
)
=
delete
;
mapped_file_t
&
operator
=
(
const
mapped_file_t
&
)
=
delete
;
mapped_file_t
(
mapped_file_t
&&
)
=
delete
;
mapped_file_t
&
operator
=
(
mapped_file_t
&&
)
=
delete
;
~
mapped_file_t
()
noexcept
;
dberr_t
map
(
const
char
*
path
,
bool
read_only
=
false
,
bool
nvme
=
false
)
noexcept
;
dberr_t
unmap
()
noexcept
;
byte
*
data
()
noexcept
{
return
m_area
.
data
();
}
private:
span
<
byte
>
m_area
;
};
/** Abstraction for reading, writing and flushing file cache to disk */
class
file_io
{
...
...
storage/innobase/log/log0log.cc
View file @
0064316f
...
...
@@ -221,47 +221,6 @@ void log_t::create()
(
aligned_malloc
(
OS_FILE_LOG_BLOCK_SIZE
,
OS_FILE_LOG_BLOCK_SIZE
));
}
mapped_file_t
::~
mapped_file_t
()
noexcept
{
if
(
!
m_area
.
empty
())
unmap
();
}
dberr_t
mapped_file_t
::
map
(
const
char
*
path
,
bool
read_only
,
bool
nvme
)
noexcept
{
auto
fd
=
mysql_file_open
(
innodb_log_file_key
,
path
,
read_only
?
O_RDONLY
:
O_RDWR
,
MYF
(
MY_WME
));
if
(
fd
==
-
1
)
return
DB_ERROR
;
const
auto
file_size
=
os_file_get_size
(
path
).
m_total_size
;
const
int
nvme_flag
=
nvme
?
MAP_SYNC
:
0
;
void
*
ptr
=
my_mmap
(
0
,
static_cast
<
size_t
>
(
file_size
),
read_only
?
PROT_READ
:
PROT_READ
|
PROT_WRITE
,
MAP_SHARED_VALIDATE
|
nvme_flag
,
fd
,
0
);
mysql_file_close
(
fd
,
MYF
(
MY_WME
));
if
(
ptr
==
MAP_FAILED
)
return
DB_ERROR
;
m_area
=
{
static_cast
<
byte
*>
(
ptr
),
static_cast
<
span
<
byte
>::
size_type
>
(
file_size
)};
return
DB_SUCCESS
;
}
dberr_t
mapped_file_t
::
unmap
()
noexcept
{
ut_ad
(
!
m_area
.
empty
());
if
(
my_munmap
(
m_area
.
data
(),
m_area
.
size
()))
return
DB_ERROR
;
m_area
=
{};
return
DB_SUCCESS
;
}
file_os_io
::
file_os_io
(
file_os_io
&&
rhs
)
:
m_fd
(
rhs
.
m_fd
)
{
rhs
.
m_fd
=
OS_FILE_CLOSED
;
...
...
@@ -331,6 +290,66 @@ dberr_t file_os_io::flush() noexcept
#include <libpmem.h>
/** Memory mapped file */
class
mapped_file_t
{
public:
mapped_file_t
()
=
default
;
mapped_file_t
(
const
mapped_file_t
&
)
=
delete
;
mapped_file_t
&
operator
=
(
const
mapped_file_t
&
)
=
delete
;
mapped_file_t
(
mapped_file_t
&&
)
=
delete
;
mapped_file_t
&
operator
=
(
mapped_file_t
&&
)
=
delete
;
~
mapped_file_t
()
noexcept
;
dberr_t
map
(
const
char
*
path
,
bool
read_only
=
false
,
bool
nvme
=
false
)
noexcept
;
dberr_t
unmap
()
noexcept
;
byte
*
data
()
noexcept
{
return
m_area
.
data
();
}
private:
span
<
byte
>
m_area
;
};
mapped_file_t
::~
mapped_file_t
()
noexcept
{
if
(
!
m_area
.
empty
())
unmap
();
}
dberr_t
mapped_file_t
::
map
(
const
char
*
path
,
bool
read_only
,
bool
nvme
)
noexcept
{
auto
fd
=
mysql_file_open
(
innodb_log_file_key
,
path
,
read_only
?
O_RDONLY
:
O_RDWR
,
MYF
(
MY_WME
));
if
(
fd
==
-
1
)
return
DB_ERROR
;
const
auto
file_size
=
size_t
{
os_file_get_size
(
path
).
m_total_size
};
const
int
nvme_flag
=
nvme
?
MAP_SYNC
:
0
;
void
*
ptr
=
my_mmap
(
0
,
file_size
,
read_only
?
PROT_READ
:
PROT_READ
|
PROT_WRITE
,
MAP_SHARED_VALIDATE
|
nvme_flag
,
fd
,
0
);
mysql_file_close
(
fd
,
MYF
(
MY_WME
));
if
(
ptr
==
MAP_FAILED
)
return
DB_ERROR
;
m_area
=
{
static_cast
<
byte
*>
(
ptr
),
file_size
};
return
DB_SUCCESS
;
}
dberr_t
mapped_file_t
::
unmap
()
noexcept
{
ut_ad
(
!
m_area
.
empty
());
if
(
my_munmap
(
m_area
.
data
(),
m_area
.
size
()))
return
DB_ERROR
;
m_area
=
{};
return
DB_SUCCESS
;
}
static
bool
is_pmem
(
const
char
*
path
)
noexcept
{
mapped_file_t
mf
;
...
...
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