Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
712dead9
Commit
712dead9
authored
Aug 20, 2014
by
Victor.Kotlyar
Committed by
Steven Murray
Sep 16, 2014
Browse files
bug #105098: rtcpd flushes to tape before trailer
Moved flush logic into tclose after a trailer label is written to tape.
parent
aef01265
Changes
3
Hide whitespace changes
Inline
Side-by-side
h/rtcp_server.h
View file @
712dead9
...
...
@@ -240,7 +240,9 @@ int rtcpd_CheckFileReq (file_list_t *);
int
rtcp_CheckReqStructures
(
int
*
,
rtcpClientInfo_t
*
,
tape_list_t
*
);
int
tellClient
(
int
*
,
tape_list_t
*
,
file_list_t
*
,
int
);
int
topen
(
tape_list_t
*
,
file_list_t
*
);
int
tclose
(
const
int
,
tape_list_t
*
const
,
file_list_t
*
const
,
const
uint32_t
);
int
tclose
(
const
int
,
tape_list_t
*
const
,
file_list_t
*
const
,
const
uint32_t
,
uint64_t
*
const
,
uint64_t
*
const
,
const
uint64_t
,
const
uint64_t
,
int
*
const
,
uint64_t
*
const
);
int
tcloserr
(
int
,
tape_list_t
*
,
file_list_t
*
);
int
twrite
(
const
int
,
char
*
const
,
const
int
,
tape_list_t
*
const
,
file_list_t
*
const
,
const
uint32_t
);
int
tread
(
int
,
char
*
,
int
,
tape_list_t
*
,
file_list_t
*
);
...
...
rtcopy/rtcpd_Tape.c
View file @
712dead9
...
...
@@ -639,67 +639,15 @@ static int MemoryToTape(
}
}
/* End of for (;;) */
/* If data should be flushed to tape every N files */
if
(
TAPEBRIDGE_ONE_FLUSH_PER_N_FILES
==
tapeFlushMode
)
{
/* Update the number of bytes and files written without a flush to */
/* tape */
(
*
nbFilesWrittenWithoutFlush
)
++
;
*
nbBytesWrittenWithoutFlush
+=
filereq
->
bytes_in
;
/* If the maximum number of bytes or the maximum number of files */
/* before a flush to tape has been reached */
if
(
maxBytesBeforeFlush
<=
*
nbBytesWrittenWithoutFlush
||
maxFilesBeforeFlush
<=
*
nbFilesWrittenWithoutFlush
)
{
/* Flush data to tape */
rc
=
wrttpmrk
(
tape_fd
,
filereq
->
tape_path
,
0
,
0
);
if
(
-
1
==
rc
)
{
rtcp_log
(
LOG_ERR
,
"wrttpmrk() error: %s
\n
"
,
sstrerror
(
serrno
));
tl_rtcpd
.
tl_log
(
&
tl_rtcpd
,
3
,
3
,
"func"
,
TL_MSG_PARAM_STR
,
"MemoryToTape"
,
"Message"
,
TL_MSG_PARAM_STR
,
"wrttpmrk"
,
"Error"
,
TL_MSG_PARAM_STR
,
sstrerror
(
serrno
));
return
(
-
1
);
}
{
const
char
*
const
maxBytesBeforeFlushReachedStr
=
maxBytesBeforeFlush
<=
*
nbBytesWrittenWithoutFlush
?
"TRUE"
:
"FALSE"
;
const
char
*
const
maxFilesBeforeFlushReachedStr
=
maxFilesBeforeFlush
<=
*
nbFilesWrittenWithoutFlush
?
"TRUE"
:
"FALSE"
;
char
logMsg
[
256
];
snprintf
(
logMsg
,
sizeof
(
logMsg
),
"Flushed to tape"
": maxBytesBeforeFlushReached=%s"
" maxFilesBeforeFlushReachedStr=%s"
,
maxBytesBeforeFlushReachedStr
,
maxFilesBeforeFlushReachedStr
);
logMsg
[
sizeof
(
logMsg
)
-
1
]
=
'\0'
;
rtcp_log
(
LOG_INFO
,
"%s(): %s
\n
"
,
__FUNCTION__
,
logMsg
);
tl_rtcpd
.
tl_log
(
&
tl_rtcpd
,
10
,
2
,
"func"
,
TL_MSG_PARAM_STR
,
__FUNCTION__
,
"Message"
,
TL_MSG_PARAM_STR
,
logMsg
);
}
/* Indicate a flush to tape has been done */
*
flushedToTapeAfterNFiles
=
1
;
/* Reset the number of bytes and files written without a flush */
*
nbBytesWrittenWithoutFlush
=
0
;
*
nbFilesWrittenWithoutFlush
=
0
;
}
}
TP_STATUS
(
RTCP_PS_CLOSE
);
if
(
proc_err
==
0
)
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
);
if
(
proc_err
==
0
)
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
,
nbBytesWrittenWithoutFlush
,
nbFilesWrittenWithoutFlush
,
maxBytesBeforeFlush
,
maxFilesBeforeFlush
,
flushedToTapeAfterNFiles
,
batchBytesToTape
);
TP_STATUS
(
RTCP_PS_NOBLOCKING
);
/* tclose updates compression statistics per file */
*
batchBytesToTape
+=
file
->
filereq
.
bytes_out
;
return
(
rc
);
}
...
...
@@ -966,10 +914,23 @@ static int TapeToMemory(int tape_fd, int *indxp, int *firstblk,
*/
TP_STATUS
(
RTCP_PS_CLOSE
);
{
/*
tapeFlushMode is
ignored for reads */
/*
all following variables are
ignored for reads */
const
uint32_t
tapeFlushMode
=
TAPEBRIDGE_N_FLUSHES_PER_FILE
;
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
);
uint64_t
nbBytesWrittenWithoutFlush
=
0
;
uint64_t
nbFilesWrittenWithoutFlush
=
0
;
const
uint64_t
maxBytesBeforeFlush
=
0
;
const
uint64_t
maxFilesBeforeFlush
=
0
;
int
flushedToTapeAfterNFiles
=
0
;
uint64_t
batchBytesToTape
=
0
;
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
,
&
nbBytesWrittenWithoutFlush
,
&
nbFilesWrittenWithoutFlush
,
maxBytesBeforeFlush
,
maxFilesBeforeFlush
,
&
flushedToTapeAfterNFiles
,
&
batchBytesToTape
);
}
TP_STATUS
(
RTCP_PS_NOBLOCKING
);
if
(
rc
==
-
1
)
{
...
...
@@ -1147,9 +1108,23 @@ static int TapeToMemory(int tape_fd, int *indxp, int *firstblk,
if
(
proc_err
==
0
&&
tape_fd
>=
0
)
{
TP_STATUS
(
RTCP_PS_CLOSE
);
{
/*
tapeFlushMode is
ignored for reads */
/*
all following variables are
ignored for reads */
const
uint32_t
tapeFlushMode
=
TAPEBRIDGE_N_FLUSHES_PER_FILE
;
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
);
uint64_t
nbBytesWrittenWithoutFlush
=
0
;
uint64_t
nbFilesWrittenWithoutFlush
=
0
;
const
uint64_t
maxBytesBeforeFlush
=
0
;
const
uint64_t
maxFilesBeforeFlush
=
0
;
int
flushedToTapeAfterNFiles
=
0
;
uint64_t
batchBytesToTape
=
0
;
rc
=
tclose
(
tape_fd
,
tape
,
file
,
tapeFlushMode
,
&
nbBytesWrittenWithoutFlush
,
&
nbFilesWrittenWithoutFlush
,
maxBytesBeforeFlush
,
maxFilesBeforeFlush
,
&
flushedToTapeAfterNFiles
,
&
batchBytesToTape
);
}
TP_STATUS
(
RTCP_PS_NOBLOCKING
);
}
...
...
rtcopy/rtcpd_TapeIO.c
View file @
712dead9
...
...
@@ -35,6 +35,8 @@
#include
<rtcp_lbl.h>
#include
"tplogger_api.h"
#include
"h/tapebridge_constants.h"
extern
int
AbortFlag
;
char
*
getconfent
(
char
*
,
char
*
,
int
);
...
...
@@ -491,6 +493,83 @@ int topen(tape_list_t *tape, file_list_t *file) {
return
(
fd
);
}
/**
* Checks if data should be flushed to tape every N files. Updates the number
* of bytes and files written without a flush to tape. Flush data to tape if
* the maximum number of bytes or the maximum number of files before a flush
* to tape has been reached.
*
* @return 0 if there was not any error inside wrttpmrk else -1.
* In case of error serrno is set by wrttpmrk.
*/
int
checkAndFlushDataToTape
(
const
int
tape_fd
,
char
*
const
filereqTapePath
,
const
uint64_t
filereqBytesIn
,
const
uint32_t
tapeFlushMode
,
uint64_t
*
const
nbBytesWrittenWithoutFlush
,
uint64_t
*
const
nbFilesWrittenWithoutFlush
,
const
uint64_t
maxBytesBeforeFlush
,
const
uint64_t
maxFilesBeforeFlush
,
int
*
const
flushedToTapeAfterNFiles
)
{
/* If data should be flushed to tape every N files */
if
(
TAPEBRIDGE_ONE_FLUSH_PER_N_FILES
==
tapeFlushMode
)
{
/* Update the number of bytes and files written without a flush to */
/* tape */
(
*
nbFilesWrittenWithoutFlush
)
++
;
*
nbBytesWrittenWithoutFlush
+=
filereqBytesIn
;
/* If the maximum number of bytes or the maximum number of files */
/* before a flush to tape has been reached */
if
(
maxBytesBeforeFlush
<=
*
nbBytesWrittenWithoutFlush
||
maxFilesBeforeFlush
<=
*
nbFilesWrittenWithoutFlush
)
{
/* Flush data to tape */
int
rc
;
rc
=
wrttpmrk
(
tape_fd
,
filereqTapePath
,
0
,
0
);
if
(
-
1
==
rc
)
{
rtcp_log
(
LOG_ERR
,
"wrttpmrk() error: %s
\n
"
,
sstrerror
(
serrno
));
tl_rtcpd
.
tl_log
(
&
tl_rtcpd
,
3
,
3
,
"func"
,
TL_MSG_PARAM_STR
,
"MemoryToTape"
,
"Message"
,
TL_MSG_PARAM_STR
,
"wrttpmrk"
,
"Error"
,
TL_MSG_PARAM_STR
,
sstrerror
(
serrno
));
return
(
-
1
);
}
{
const
char
*
const
maxBytesBeforeFlushReachedStr
=
maxBytesBeforeFlush
<=
*
nbBytesWrittenWithoutFlush
?
"TRUE"
:
"FALSE"
;
const
char
*
const
maxFilesBeforeFlushReachedStr
=
maxFilesBeforeFlush
<=
*
nbFilesWrittenWithoutFlush
?
"TRUE"
:
"FALSE"
;
char
logMsg
[
256
];
snprintf
(
logMsg
,
sizeof
(
logMsg
),
"Flushed to tape"
": maxBytesBeforeFlushReached=%s"
" maxFilesBeforeFlushReachedStr=%s"
,
maxBytesBeforeFlushReachedStr
,
maxFilesBeforeFlushReachedStr
);
logMsg
[
sizeof
(
logMsg
)
-
1
]
=
'\0'
;
rtcp_log
(
LOG_INFO
,
"%s(): %s
\n
"
,
__FUNCTION__
,
logMsg
);
tl_rtcpd
.
tl_log
(
&
tl_rtcpd
,
10
,
2
,
"func"
,
TL_MSG_PARAM_STR
,
__FUNCTION__
,
"Message"
,
TL_MSG_PARAM_STR
,
logMsg
);
}
/* Indicate a flush to tape has been done */
*
flushedToTapeAfterNFiles
=
1
;
/* Reset the number of bytes and files written without a flush */
*
nbBytesWrittenWithoutFlush
=
0
;
*
nbFilesWrittenWithoutFlush
=
0
;
}
}
return
(
0
);
}
/*
* Closing tape file.
*/
...
...
@@ -498,7 +577,13 @@ int tclose(
const
int
fd
,
tape_list_t
*
const
tape
,
file_list_t
*
const
file
,
const
uint32_t
tapeFlushMode
)
{
const
uint32_t
tapeFlushMode
,
uint64_t
*
const
nbBytesWrittenWithoutFlush
,
uint64_t
*
const
nbFilesWrittenWithoutFlush
,
const
uint64_t
maxBytesBeforeFlush
,
const
uint64_t
maxFilesBeforeFlush
,
int
*
const
flushedToTapeAfterNFiles
,
uint64_t
*
const
batchBytesToTape
)
{
int
rc
=
0
;
int
save_serrno
=
0
;
int
save_errno
=
0
;
...
...
@@ -588,6 +673,15 @@ int tclose(
"err"
,
TL_MSG_PARAM_STR
,
sstrerror
(
save_serrno
)
);
serrno
=
save_serrno
;
}
rc
=
checkAndFlushDataToTape
(
fd
,
filereq
->
tape_path
,
filereq
->
bytes_in
,
tapeFlushMode
,
nbBytesWrittenWithoutFlush
,
nbFilesWrittenWithoutFlush
,
maxBytesBeforeFlush
,
maxFilesBeforeFlush
,
flushedToTapeAfterNFiles
);
}
if
(
(
rc
!=
-
1
)
&&
(
file
->
trec
>
0
)
)
{
/*******************************************************************************
...
...
@@ -663,6 +757,7 @@ int tclose(
filereq
->
host_bytes
=
filereq
->
bytes_in
=
filereq
->
bytes_out
;
}
}
*
batchBytesToTape
+=
file
->
filereq
.
bytes_out
;
(
void
)
close
(
fd
)
;
filereq
->
TEndTransferTape
=
(
int
)
time
(
NULL
);
if
(
file
->
cksumRoutine
!=
(
unsigned
long
(
*
)
(
unsigned
long
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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