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
8be23627
Commit
8be23627
authored
Apr 28, 2014
by
David COME
Browse files
Added an entry in order to suppress a race detected by hellgrind in SLC5
parent
ffcbb119
Changes
4
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/daemon/TapeReadFileTask.hpp
deleted
100644 → 0
View file @
ffcbb119
/******************************************************************************
* TapeReadFileTask.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include
"castor/tape/tapeserver/daemon/TapeReadTask.hpp"
#include
"castor/tape/tapeserver/daemon/DataFifo.hpp"
#include
"castor/tape/tapeserver/daemon/RecallMemoryManager.hpp"
#include
"castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include
"castor/tape/tapeserver/exception/Exception.hpp"
#include
"castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
class
TapeReadFileTask
:
public
TapeReadTask
{
public:
TapeReadFileTask
(
castor
::
tape
::
tapegateway
::
FileToRecallStruct
*
ftr
,
DataConsumer
&
destination
,
RecallMemoryManager
&
mm
)
:
m_fileToRecall
(
ftr
),
m_fifo
(
destination
),
m_mm
(
mm
)
{}
virtual
void
execute
(
castor
::
tape
::
tapeFile
::
ReadSession
&
rs
,
castor
::
log
::
LogContext
&
lc
)
{
using
castor
::
log
::
Param
;
typedef
castor
::
log
::
LogContext
::
ScopedParam
ScopedParam
;
// Placeholder for the tape file read
// Set the common context for all the omming logs (file info)
ScopedParam
sp0
(
lc
,
Param
(
"NSHOSTNAME"
,
m_fileToRecall
->
nshost
()));
ScopedParam
sp1
(
lc
,
Param
(
"NSFILEID"
,
m_fileToRecall
->
fileid
()));
ScopedParam
sp2
(
lc
,
Param
(
"BlockId"
,
castor
::
tape
::
tapeFile
::
BlockId
::
extract
(
*
m_fileToRecall
)));
ScopedParam
sp3
(
lc
,
Param
(
"fSeq"
,
m_fileToRecall
->
fseq
()));
ScopedParam
sp4
(
lc
,
Param
(
"fileTransactionId"
,
m_fileToRecall
->
fileTransactionId
()));
// Read the file and transmit it
bool
stillReading
=
true
;
int
fileBlock
=
0
;
int
tapeBlock
=
0
;
MemBlock
*
mb
=
NULL
;
try
{
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
rf
(
openReadFile
(
rs
,
lc
));
while
(
stillReading
)
{
// Get a memory block and add information to its metadata
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_fileToRecall
->
fseq
();
mb
->
m_fileBlock
=
fileBlock
++
;
mb
->
m_fileid
=
m_fileToRecall
->
fileid
();
mb
->
m_tapeFileBlock
=
tapeBlock
;
mb
->
m_tapeBlockSize
=
rf
->
getBlockSize
();
try
{
// Fill up the memory block with tape block
// append conveniently returns false when there will not be more space
// for an extra tape block, and throws an exception if we reached the
// end of file. append() also protects against reading too big tape blocks.
while
(
mb
->
m_payload
.
append
(
*
rf
))
{
tapeBlock
++
;
}
}
catch
(
const
castor
::
tape
::
exceptions
::
EndOfFile
&
)
{
// append() signaled the end of the file.
stillReading
=
false
;
}
// Pass the block to the disk write task
m_fifo
.
pushDataBlock
(
mb
);
}
//end of while(stillReading)
}
//end of try
catch
(
castor
::
exception
::
Exception
&
ex
)
{
//we end up there because :
//-- openReadFile brought us here (cant put the tape into position)
//-- m_payload.append brought us here (error while reading the file)
// This is an error case. Log and signal to the disk write task
{
castor
::
log
::
LogContext
::
ScopedParam
sp0
(
lc
,
Param
(
"fileBlock"
,
fileBlock
));
castor
::
log
::
LogContext
::
ScopedParam
sp1
(
lc
,
Param
(
"ErrorMessage"
,
ex
.
getMessageValue
()));
castor
::
log
::
LogContext
::
ScopedParam
sp2
(
lc
,
Param
(
"ErrorCode"
,
ex
.
code
()));
lc
.
log
(
LOG_ERR
,
"Error reading a file block in TapeReadFileTask (backtrace follows)"
);
}
{
castor
::
log
::
LogContext
lc2
(
lc
.
logger
());
lc2
.
logBacktrace
(
LOG_ERR
,
ex
.
backtrace
());
}
//if we end up there because openReadFile brought us here
//then mb is not valid, we need to get a block
if
(
!
mb
)
{
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_fileToRecall
->
fseq
();
mb
->
m_fileid
=
m_fileToRecall
->
fileid
();
}
//mark the block failed and push it
mb
->
markAsFailed
();
m_fifo
.
pushDataBlock
(
mb
);
m_fifo
.
pushDataBlock
(
NULL
);
return
;
}
// In all cases, we have to signal the end of the tape read to the disk write
// task.
m_fifo
.
pushDataBlock
(
NULL
);
lc
.
log
(
LOG_DEBUG
,
"File read completed"
);
}
private:
// Open the file and manage failure (if any)
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
openReadFile
(
castor
::
tape
::
tapeFile
::
ReadSession
&
rs
,
castor
::
log
::
LogContext
&
lc
){
using
castor
::
log
::
Param
;
typedef
castor
::
log
::
LogContext
::
ScopedParam
ScopedParam
;
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
rf
;
try
{
rf
.
reset
(
new
castor
::
tape
::
tapeFile
::
ReadFile
(
&
rs
,
*
m_fileToRecall
));
lc
.
log
(
LOG_DEBUG
,
"Successfully opened the tape file"
);
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
// Log the error
ScopedParam
sp0
(
lc
,
Param
(
"ErrorMessage"
,
ex
.
getMessageValue
()));
ScopedParam
sp1
(
lc
,
Param
(
"ErrorCode"
,
ex
.
code
()));
lc
.
log
(
LOG_ERR
,
"Failed to open tape file for reading"
);
throw
;
}
return
rf
;
}
std
::
auto_ptr
<
castor
::
tape
::
tapegateway
::
FileToRecallStruct
>
m_fileToRecall
;
DataConsumer
&
m_fifo
;
RecallMemoryManager
&
m_mm
;
};
}
}
}
}
castor/tape/tapeserver/daemon/TapeReadTask.hpp
View file @
8be23627
/******************************************************************************
* TapeReadTask.hpp
* TapeRead
File
Task.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
...
...
@@ -24,23 +24,134 @@
#pragma once
#include
"castor/tape/tapeserver/daemon/Exception.hpp"
#include
"castor/tape/tapeserver/drive/Drive.hpp"
#include
"castor/tape/tapeserver/file/File.hpp"
#include
"castor/tape/tapeserver/daemon/TapeReadTask.hpp"
#include
"castor/tape/tapeserver/daemon/DataFifo.hpp"
#include
"castor/tape/tapeserver/daemon/RecallMemoryManager.hpp"
#include
"castor/tape/tapeserver/daemon/DataConsumer.hpp"
#include
"castor/tape/tapeserver/exception/Exception.hpp"
#include
"castor/tape/tapeserver/daemon/AutoReleaseBlock.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
class
TapeReadTask
{
class
TapeReadFileTask
:
public
TapeReadTask
{
public:
virtual
void
execute
(
castor
::
tape
::
tapeFile
::
ReadSession
&
/*rs*/
,
castor
::
log
::
LogContext
&
/*lc*/
)
{
throw
MemException
(
"Tring to execute a non-execuatble TapeReadTask"
);
};
virtual
~
TapeReadTask
()
{}
TapeReadFileTask
(
castor
::
tape
::
tapegateway
::
FileToRecallStruct
*
ftr
,
DataConsumer
&
destination
,
RecallMemoryManager
&
mm
)
:
m_fileToRecall
(
ftr
),
m_fifo
(
destination
),
m_mm
(
mm
)
{}
virtual
void
execute
(
castor
::
tape
::
tapeFile
::
ReadSession
&
rs
,
castor
::
log
::
LogContext
&
lc
)
{
using
castor
::
log
::
Param
;
typedef
castor
::
log
::
LogContext
::
ScopedParam
ScopedParam
;
// Placeholder for the tape file read
// Set the common context for all the omming logs (file info)
ScopedParam
sp0
(
lc
,
Param
(
"NSHOSTNAME"
,
m_fileToRecall
->
nshost
()));
ScopedParam
sp1
(
lc
,
Param
(
"NSFILEID"
,
m_fileToRecall
->
fileid
()));
ScopedParam
sp2
(
lc
,
Param
(
"BlockId"
,
castor
::
tape
::
tapeFile
::
BlockId
::
extract
(
*
m_fileToRecall
)));
ScopedParam
sp3
(
lc
,
Param
(
"fSeq"
,
m_fileToRecall
->
fseq
()));
ScopedParam
sp4
(
lc
,
Param
(
"fileTransactionId"
,
m_fileToRecall
->
fileTransactionId
()));
// Read the file and transmit it
bool
stillReading
=
true
;
int
fileBlock
=
0
;
int
tapeBlock
=
0
;
MemBlock
*
mb
=
NULL
;
try
{
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
rf
(
openReadFile
(
rs
,
lc
));
while
(
stillReading
)
{
// Get a memory block and add information to its metadata
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_fileToRecall
->
fseq
();
mb
->
m_fileBlock
=
fileBlock
++
;
mb
->
m_fileid
=
m_fileToRecall
->
fileid
();
mb
->
m_tapeFileBlock
=
tapeBlock
;
mb
->
m_tapeBlockSize
=
rf
->
getBlockSize
();
try
{
// Fill up the memory block with tape block
// append conveniently returns false when there will not be more space
// for an extra tape block, and throws an exception if we reached the
// end of file. append() also protects against reading too big tape blocks.
while
(
mb
->
m_payload
.
append
(
*
rf
))
{
tapeBlock
++
;
}
}
catch
(
const
castor
::
tape
::
exceptions
::
EndOfFile
&
)
{
// append() signaled the end of the file.
stillReading
=
false
;
}
// Pass the block to the disk write task
m_fifo
.
pushDataBlock
(
mb
);
}
//end of while(stillReading)
}
//end of try
catch
(
castor
::
exception
::
Exception
&
ex
)
{
//we end up there because :
//-- openReadFile brought us here (cant put the tape into position)
//-- m_payload.append brought us here (error while reading the file)
// This is an error case. Log and signal to the disk write task
{
castor
::
log
::
LogContext
::
ScopedParam
sp0
(
lc
,
Param
(
"fileBlock"
,
fileBlock
));
castor
::
log
::
LogContext
::
ScopedParam
sp1
(
lc
,
Param
(
"ErrorMessage"
,
ex
.
getMessageValue
()));
castor
::
log
::
LogContext
::
ScopedParam
sp2
(
lc
,
Param
(
"ErrorCode"
,
ex
.
code
()));
lc
.
log
(
LOG_ERR
,
"Error reading a file block in TapeReadFileTask (backtrace follows)"
);
}
{
castor
::
log
::
LogContext
lc2
(
lc
.
logger
());
lc2
.
logBacktrace
(
LOG_ERR
,
ex
.
backtrace
());
}
//if we end up there because openReadFile brought us here
//then mb is not valid, we need to get a block
if
(
!
mb
)
{
mb
=
m_mm
.
getFreeBlock
();
mb
->
m_fSeq
=
m_fileToRecall
->
fseq
();
mb
->
m_fileid
=
m_fileToRecall
->
fileid
();
}
//mark the block failed and push it
mb
->
markAsFailed
();
m_fifo
.
pushDataBlock
(
mb
);
m_fifo
.
pushDataBlock
(
NULL
);
return
;
}
// In all cases, we have to signal the end of the tape read to the disk write
// task.
m_fifo
.
pushDataBlock
(
NULL
);
lc
.
log
(
LOG_DEBUG
,
"File read completed"
);
}
private:
// Open the file and manage failure (if any)
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
openReadFile
(
castor
::
tape
::
tapeFile
::
ReadSession
&
rs
,
castor
::
log
::
LogContext
&
lc
){
using
castor
::
log
::
Param
;
typedef
castor
::
log
::
LogContext
::
ScopedParam
ScopedParam
;
std
::
auto_ptr
<
castor
::
tape
::
tapeFile
::
ReadFile
>
rf
;
try
{
rf
.
reset
(
new
castor
::
tape
::
tapeFile
::
ReadFile
(
&
rs
,
*
m_fileToRecall
));
lc
.
log
(
LOG_DEBUG
,
"Successfully opened the tape file"
);
}
catch
(
castor
::
exception
::
Exception
&
ex
)
{
// Log the error
ScopedParam
sp0
(
lc
,
Param
(
"ErrorMessage"
,
ex
.
getMessageValue
()));
ScopedParam
sp1
(
lc
,
Param
(
"ErrorCode"
,
ex
.
code
()));
lc
.
log
(
LOG_ERR
,
"Failed to open tape file for reading"
);
throw
;
}
return
rf
;
}
std
::
auto_ptr
<
castor
::
tape
::
tapegateway
::
FileToRecallStruct
>
m_fileToRecall
;
DataConsumer
&
m_fifo
;
RecallMemoryManager
&
m_mm
;
};
}
}
}
}
castor/tape/tapeserver/daemon/TapeReadTaskInterface.hpp
0 → 100644
View file @
8be23627
/******************************************************************************
* TapeReadTask.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include
"castor/tape/tapeserver/daemon/Exception.hpp"
#include
"castor/tape/tapeserver/drive/Drive.hpp"
#include
"castor/tape/tapeserver/file/File.hpp"
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
class
TapeReadTask
{
public:
virtual
void
execute
(
castor
::
tape
::
tapeFile
::
ReadSession
&
/*rs*/
,
castor
::
log
::
LogContext
&
/*lc*/
)
{
throw
MemException
(
"Tring to execute a non-execuatble TapeReadTask"
);
};
virtual
~
TapeReadTask
()
{}
};
}
}
}
}
test/castorThreadedUnitTests.supp
View file @
8be23627
...
...
@@ -139,3 +139,8 @@
Helgrind:Race
fun: _ZNKSs6*
}
{
helgrind-unitTest-castor-basicStringsMutate
Helgrind:Race
fun: _ZNSs9_M_mutateEjjj
}
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