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
f77996b3
Commit
f77996b3
authored
Apr 16, 2013
by
Dave Wells
Committed by
Yoni Fogel
Apr 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge from tokudb.2445
git-svn-id:
file:///svn/toku/tokudb@18387
c7de825b-a66e-492c-adef-691d508d4ae1
parent
b55e48b9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
15 deletions
+38
-15
newbrt/log-internal.h
newbrt/log-internal.h
+2
-0
newbrt/logger.c
newbrt/logger.c
+36
-15
No files found.
newbrt/log-internal.h
View file @
f77996b3
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <toku_pthread.h>
#include <toku_pthread.h>
#include <sys/types.h>
#include <sys/types.h>
#include <string.h>
#include <string.h>
#include <dirent.h>
// Locking for the logger
// Locking for the logger
// For most purposes we use the big ydb lock.
// For most purposes we use the big ydb lock.
...
@@ -71,6 +72,7 @@ struct tokulogger {
...
@@ -71,6 +72,7 @@ struct tokulogger {
BOOL
trim_log_files
;
// for test purposes
BOOL
trim_log_files
;
// for test purposes
int
panic_errno
;
int
panic_errno
;
char
*
directory
;
// file system directory
char
*
directory
;
// file system directory
DIR
*
dir
;
// descriptor for directory
int
fd
;
int
fd
;
CACHETABLE
ct
;
CACHETABLE
ct
;
int
lg_max
;
// The size of the single file in the log. Default is 100MB in TokuDB
int
lg_max
;
// The size of the single file in the log. Default is 100MB in TokuDB
...
...
newbrt/logger.c
View file @
f77996b3
...
@@ -73,6 +73,34 @@ int toku_logger_create (TOKULOGGER *resultp) {
...
@@ -73,6 +73,34 @@ int toku_logger_create (TOKULOGGER *resultp) {
return
r
;
return
r
;
}
}
static
int
fsync_logdir
(
TOKULOGGER
logger
)
{
return
toku_file_fsync_without_accounting
(
dirfd
(
logger
->
dir
)
);
}
static
int
open_logdir
(
TOKULOGGER
logger
,
const
char
*
directory
)
{
if
(
toku_os_is_absolute_name
(
directory
))
{
logger
->
directory
=
toku_strdup
(
directory
);
}
else
{
char
*
cwd
=
getcwd
(
NULL
,
0
);
if
(
cwd
==
NULL
)
return
-
1
;
char
*
new_log_dir
=
toku_malloc
(
strlen
(
cwd
)
+
strlen
(
directory
)
+
2
);
if
(
new_log_dir
==
NULL
)
return
-
2
;
sprintf
(
new_log_dir
,
"%s/%s"
,
cwd
,
directory
);
logger
->
directory
=
new_log_dir
;
}
if
(
logger
->
directory
==
0
)
return
errno
;
logger
->
dir
=
opendir
(
logger
->
directory
);
if
(
logger
->
dir
==
NULL
)
return
-
1
;
return
0
;
}
static
int
close_logdir
(
TOKULOGGER
logger
)
{
return
closedir
(
logger
->
dir
);
}
int
toku_logger_open
(
const
char
*
directory
,
TOKULOGGER
logger
)
{
int
toku_logger_open
(
const
char
*
directory
,
TOKULOGGER
logger
)
{
if
(
logger
->
is_open
)
return
EINVAL
;
if
(
logger
->
is_open
)
return
EINVAL
;
if
(
logger
->
is_panicked
)
return
EINVAL
;
if
(
logger
->
is_panicked
)
return
EINVAL
;
...
@@ -87,23 +115,14 @@ int toku_logger_open (const char *directory, TOKULOGGER logger) {
...
@@ -87,23 +115,14 @@ int toku_logger_open (const char *directory, TOKULOGGER logger) {
logger
->
inbuf
.
max_lsn_in_buf
=
logger
->
lsn
;
logger
->
inbuf
.
max_lsn_in_buf
=
logger
->
lsn
;
logger
->
outbuf
.
max_lsn_in_buf
=
logger
->
lsn
;
logger
->
outbuf
.
max_lsn_in_buf
=
logger
->
lsn
;
// open directory, save pointer for fsyncing t:2445
r
=
open_logdir
(
logger
,
directory
);
if
(
r
!=
0
)
return
r
;
long
long
nexti
;
long
long
nexti
;
r
=
toku_logger_find_next_unused_log_file
(
directory
,
&
nexti
);
r
=
toku_logger_find_next_unused_log_file
(
logger
->
directory
,
&
nexti
);
if
(
r
!=
0
)
return
r
;
if
(
r
!=
0
)
return
r
;
if
(
toku_os_is_absolute_name
(
directory
))
{
logger
->
directory
=
toku_strdup
(
directory
);
}
else
{
char
*
cwd
=
getcwd
(
NULL
,
0
);
if
(
cwd
==
NULL
)
return
-
1
;
char
*
new_log_dir
=
toku_malloc
(
strlen
(
cwd
)
+
strlen
(
directory
)
+
2
);
if
(
new_log_dir
==
NULL
)
return
-
2
;
sprintf
(
new_log_dir
,
"%s/%s"
,
cwd
,
directory
);
logger
->
directory
=
new_log_dir
;
toku_free
(
cwd
);
}
if
(
logger
->
directory
==
0
)
return
errno
;
logger
->
next_log_file_number
=
nexti
;
logger
->
next_log_file_number
=
nexti
;
open_logfile
(
logger
);
open_logfile
(
logger
);
...
@@ -129,6 +148,7 @@ int toku_logger_close(TOKULOGGER *loggerp) {
...
@@ -129,6 +148,7 @@ int toku_logger_close(TOKULOGGER *loggerp) {
}
}
r
=
close
(
logger
->
fd
);
if
(
r
!=
0
)
{
r
=
errno
;
goto
panic
;
}
r
=
close
(
logger
->
fd
);
if
(
r
!=
0
)
{
r
=
errno
;
goto
panic
;
}
}
}
r
=
close_logdir
(
logger
);
if
(
r
!=
0
)
{
r
=
errno
;
goto
panic
;
}
logger
->
fd
=-
1
;
logger
->
fd
=-
1
;
release_output
(
logger
,
fsynced_lsn
);
release_output
(
logger
,
fsynced_lsn
);
...
@@ -479,6 +499,7 @@ static int open_logfile (TOKULOGGER logger)
...
@@ -479,6 +499,7 @@ static int open_logfile (TOKULOGGER logger)
if
(
logger
->
write_log_files
)
{
if
(
logger
->
write_log_files
)
{
logger
->
fd
=
open
(
fname
,
O_CREAT
+
O_WRONLY
+
O_TRUNC
+
O_EXCL
+
O_BINARY
,
S_IRWXU
);
logger
->
fd
=
open
(
fname
,
O_CREAT
+
O_WRONLY
+
O_TRUNC
+
O_EXCL
+
O_BINARY
,
S_IRWXU
);
if
(
logger
->
fd
==-
1
)
return
errno
;
if
(
logger
->
fd
==-
1
)
return
errno
;
int
r
=
fsync_logdir
(
logger
);
if
(
r
!=
0
)
return
r
;
// t:2445
logger
->
next_log_file_number
++
;
logger
->
next_log_file_number
++
;
}
else
{
}
else
{
logger
->
fd
=
open
(
DEV_NULL_FILE
,
O_WRONLY
+
O_BINARY
);
logger
->
fd
=
open
(
DEV_NULL_FILE
,
O_WRONLY
+
O_BINARY
);
...
...
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