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
80c444ec
Commit
80c444ec
authored
Jun 16, 2014
by
John Esmet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FT-274 Use ybt functions for descriptor memory management, which is
safer and more readable.
parent
d42d5fc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
56 deletions
+22
-56
ft/ft-serialize.cc
ft/ft-serialize.cc
+8
-18
ft/ft.cc
ft/ft.cc
+7
-21
src/ydb_db.cc
src/ydb_db.cc
+7
-17
No files found.
ft/ft-serialize.cc
View file @
80c444ec
...
...
@@ -153,15 +153,7 @@ deserialize_descriptor_from_rbuf(struct rbuf *rb, DESCRIPTOR desc, int layout_ve
uint32_t
size
;
bytevec
data
;
rbuf_bytes
(
rb
,
&
data
,
&
size
);
bytevec
data_copy
=
data
;
if
(
size
>
0
)
{
data_copy
=
toku_memdup
(
data
,
size
);
//Cannot keep the reference from rbuf. Must copy.
lazy_assert
(
data_copy
);
}
else
{
lazy_assert
(
size
==
0
);
data_copy
=
NULL
;
}
toku_fill_dbt
(
&
desc
->
dbt
,
data_copy
,
size
);
toku_memdup_dbt
(
&
desc
->
dbt
,
data
,
size
);
}
static
int
...
...
@@ -194,12 +186,10 @@ deserialize_descriptor_from(int fd, BLOCK_TABLE bt, DESCRIPTOR desc, int layout_
goto
exit
;
}
}
{
struct
rbuf
rb
=
{.
buf
=
dbuf
,
.
size
=
(
unsigned
int
)
size
,
.
ndone
=
0
};
//Not temporary; must have a toku_memdup'd copy.
deserialize_descriptor_from_rbuf
(
&
rb
,
desc
,
layout_version
);
}
lazy_assert
(
deserialize_descriptor_size
(
desc
,
layout_version
)
+
4
==
size
);
struct
rbuf
rb
=
{
.
buf
=
dbuf
,
.
size
=
(
unsigned
int
)
size
,
.
ndone
=
0
};
deserialize_descriptor_from_rbuf
(
&
rb
,
desc
,
layout_version
);
lazy_assert
(
deserialize_descriptor_size
(
desc
,
layout_version
)
+
4
==
size
);
toku_free
(
dbuf
);
}
}
...
...
@@ -436,10 +426,10 @@ int deserialize_ft_versioned(int fd, struct rbuf *rb, FT *ftp, uint32_t version)
if
(
r
!=
0
)
{
goto
exit
;
}
// initialize for svn #4541
// TODO: use real dbt function
ft
->
cmp_descriptor
.
dbt
.
size
=
ft
->
descriptor
.
dbt
.
size
;
ft
->
cmp_descriptor
.
dbt
.
data
=
toku_xmemdup
(
ft
->
descriptor
.
dbt
.
data
,
ft
->
descriptor
.
dbt
.
size
);
toku_clone_dbt
(
&
ft
->
cmp_descriptor
.
dbt
,
ft
->
descriptor
.
dbt
);
// Version 13 descriptors had an extra 4 bytes that we don't read
// anymore. Since the header is going to think it's the current
// version if it gets written out, we need to write the descriptor in
...
...
ft/ft.cc
View file @
80c444ec
...
...
@@ -120,10 +120,8 @@ ft_destroy(FT ft) {
assert
(
ft
->
h
->
type
==
FT_CURRENT
);
toku_blocktable_destroy
(
&
ft
->
blocktable
);
ft
->
cmp
.
destroy
();
// TODO: use real dbt function
if
(
ft
->
descriptor
.
dbt
.
data
)
toku_free
(
ft
->
descriptor
.
dbt
.
data
);
// TODO: use real dbt function
if
(
ft
->
cmp_descriptor
.
dbt
.
data
)
toku_free
(
ft
->
cmp_descriptor
.
dbt
.
data
);
toku_destroy_dbt
(
&
ft
->
descriptor
.
dbt
);
toku_destroy_dbt
(
&
ft
->
cmp_descriptor
.
dbt
);
toku_ft_destroy_reflock
(
ft
);
toku_free
(
ft
->
h
);
}
...
...
@@ -913,26 +911,14 @@ toku_ft_update_descriptor_with_fd(FT ft, DESCRIPTOR desc, int fd) {
toku_serialize_descriptor_contents_to_fd
(
fd
,
desc
,
offset
);
// cleanup the old descriptor and set the in-memory descriptor to the new one
// TODO: use real dbt function
if
(
ft
->
descriptor
.
dbt
.
data
)
{
toku_free
(
ft
->
descriptor
.
dbt
.
data
);
}
// TODO: use real dbt function
ft
->
descriptor
.
dbt
.
size
=
desc
->
dbt
.
size
;
ft
->
descriptor
.
dbt
.
data
=
toku_memdup
(
desc
->
dbt
.
data
,
desc
->
dbt
.
size
);
toku_destroy_dbt
(
&
ft
->
descriptor
.
dbt
);
toku_clone_dbt
(
&
ft
->
descriptor
.
dbt
,
desc
->
dbt
);
}
void
toku_ft_update_cmp_descriptor
(
FT
ft
)
{
// TODO: use real dbt function
if
(
ft
->
cmp_descriptor
.
dbt
.
data
!=
NULL
)
{
toku_free
(
ft
->
cmp_descriptor
.
dbt
.
data
);
}
// TODO: use real dbt function
ft
->
cmp_descriptor
.
dbt
.
size
=
ft
->
descriptor
.
dbt
.
size
;
ft
->
cmp_descriptor
.
dbt
.
data
=
toku_xmemdup
(
ft
->
descriptor
.
dbt
.
data
,
ft
->
descriptor
.
dbt
.
size
);
// cleanup the old cmp descriptor and clone it as the in-memory descriptor
toku_destroy_dbt
(
&
ft
->
cmp_descriptor
.
dbt
);
toku_clone_dbt
(
&
ft
->
cmp_descriptor
.
dbt
,
ft
->
descriptor
.
dbt
);
}
DESCRIPTOR
toku_ft_get_descriptor
(
FT_HANDLE
ft_handle
)
{
...
...
src/ydb_db.cc
View file @
80c444ec
...
...
@@ -565,11 +565,12 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, uint32_t f
HANDLE_DB_ILLEGAL_WORKING_PARENT_TXN
(
db
,
txn
);
int
r
=
0
;
TOKUTXN
ttxn
=
txn
?
db_txn_struct_i
(
txn
)
->
tokutxn
:
NULL
;
DBT
old_descriptor
;
bool
is_db_hot_index
=
((
flags
&
DB_IS_HOT_INDEX
)
!=
0
);
bool
update_cmp_descriptor
=
((
flags
&
DB_UPDATE_CMP_DESCRIPTOR
)
!=
0
);
toku_init_dbt
(
&
old_descriptor
);
DBT
old_descriptor_dbt
;
toku_init_dbt
(
&
old_descriptor_dbt
);
if
(
!
db_opened
(
db
)
||
!
descriptor
||
(
descriptor
->
size
>
0
&&
!
descriptor
->
data
)){
r
=
EINVAL
;
goto
cleanup
;
...
...
@@ -582,23 +583,12 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, uint32_t f
if
(
r
!=
0
)
{
goto
cleanup
;
}
}
// TODO: use toku_clone_dbt(&old-descriptor, db->descriptor);
old_descriptor
.
size
=
db
->
descriptor
->
dbt
.
size
;
old_descriptor
.
data
=
toku_memdup
(
db
->
descriptor
->
dbt
.
data
,
db
->
descriptor
->
dbt
.
size
);
toku_ft_change_descriptor
(
db
->
i
->
ft_handle
,
&
old_descriptor
,
descriptor
,
true
,
ttxn
,
update_cmp_descriptor
);
toku_clone_dbt
(
&
old_descriptor_dbt
,
db
->
descriptor
->
dbt
);
toku_ft_change_descriptor
(
db
->
i
->
ft_handle
,
&
old_descriptor_dbt
,
descriptor
,
true
,
ttxn
,
update_cmp_descriptor
);
cleanup:
if
(
old_descriptor
.
data
)
{
toku_free
(
old_descriptor
.
data
);
}
toku_destroy_dbt
(
&
old_descriptor_dbt
);
return
r
;
}
...
...
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