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
d5a8098c
Commit
d5a8098c
authored
Apr 10, 2017
by
Cristina Moraru
Browse files
After feedback
Signed-off-by:
Cristina Moraru
<
cristina-gabriela.moraru@cern.ch
>
parent
c8b74a53
Changes
7
Hide whitespace changes
Inline
Side-by-side
tapeserver/castor/tape/tapeserver/SCSI/Structures.hpp
View file @
d5a8098c
...
...
@@ -1309,6 +1309,7 @@ namespace SCSI {
blockLims
()
{
zeroStruct
(
this
);
}
unsigned
char
fseq
[
10
];
int
begin
;
int
end
;
};
...
...
tapeserver/castor/tape/tapeserver/drive/DriveGeneric.cpp
View file @
d5a8098c
...
...
@@ -33,6 +33,7 @@
#include
<string>
#include
<map>
#include
<list>
namespace
castor
{
namespace
tape
{
...
...
@@ -757,19 +758,12 @@ SCSI::Structures::RAO::udsLimitsPage_t drive::DriveGeneric::getLimitUDS() {
SCSI
::
Structures
::
LinuxSGIO_t
sgh
;
SCSI
::
Structures
::
RAO
::
recieveRAO_t
cdb
;
SCSI
::
Structures
::
senseData_t
<
127
>
senseBuff
;
unsigned
char
dataBuff
[
4
];
SCSI
::
Structures
::
setU32
(
cdb
.
allocationLength
,
SCSI
::
modeRAO
::
DEFAULT_RRAO_ALLOCATION
);
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"IBM"
)
{
cdb
.
serviceAction
=
0x11
;
std
::
cout
<<
"vendor IBM"
<<
std
::
endl
;
}
else
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"STK"
)
{
cdb
.
serviceAction
=
0x1d
;
}
unsigned
char
dataBuff
[
sizeof
(
SCSI
::
Structures
::
RAO
::
udsLimitsPage_t
)];
cdb
.
serviceAction
=
0x1d
;
cdb
.
udsLimits
=
1
;
SCSI
::
Structures
::
setU32
(
cdb
.
allocationLength
,
SCSI
::
modeRAO
::
DEFAULT_RRAO_ALLOCATION
);
sgh
.
setCDB
(
&
cdb
);
sgh
.
setSenseBuffer
(
&
senseBuff
);
sgh
.
setDataBuffer
(
&
dataBuff
);
...
...
@@ -783,26 +777,25 @@ SCSI::Structures::RAO::udsLimitsPage_t drive::DriveGeneric::getLimitUDS() {
SCSI
::
Structures
::
RAO
::
udsLimitsPage_t
&
limits
=
*
(
SCSI
::
Structures
::
RAO
::
udsLimitsPage_t
*
)
dataBuff
;
return
limits
;
}
void
drive
::
DriveGeneric
::
generateRAO
(
std
::
map
<
std
::
string
,
SCSI
::
Structures
::
RAO
::
blockLims
>
block
s
,
int
maxSupported
)
{
void
drive
::
DriveGeneric
::
generateRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
file
s
,
int
maxSupported
)
{
SCSI
::
Structures
::
LinuxSGIO_t
sgh
;
SCSI
::
Structures
::
RAO
::
generateRAO_t
cdb
;
SCSI
::
Structures
::
senseData_t
<
127
>
senseBuff
;
//unsigned char dataBuff[1024];
int
udSize
=
std
::
min
((
int
)
blocks
.
size
(),
maxSupported
);
SCSI
::
Structures
::
RAO
::
udsDescriptor
*
ud
=
new
SCSI
::
Structures
::
RAO
::
udsDescriptor
[
udSize
];
auto
it
=
blocks
.
begin
();
for
(
int
i
=
0
;
i
<
udSize
;
++
i
)
{
memcpy
(
ud
[
i
].
udsName
,
it
->
first
.
c_str
(),
sizeof
(
ud
[
i
].
udsName
));
SCSI
::
Structures
::
setU64
(
ud
[
i
].
beginLogicalObjID
,
it
->
second
.
begin
);
SCSI
::
Structures
::
setU64
(
ud
[
i
].
endLogicalObjID
,
it
->
second
.
end
);
int
udSize
=
std
::
min
((
int
)
files
.
size
(),
maxSupported
);
std
::
unique_ptr
<
SCSI
::
Structures
::
RAO
::
udsDescriptor
[]
>
ud
(
new
SCSI
::
Structures
::
RAO
::
udsDescriptor
[
udSize
]());
auto
it
=
files
.
begin
();
for
(
int
i
=
0
;
i
<
udSize
;
++
i
)
{
strncpy
((
char
*
)
ud
.
get
()[
i
].
udsName
,
(
char
*
)
it
->
fseq
,
10
);
SCSI
::
Structures
::
setU64
(
ud
.
get
()[
i
].
beginLogicalObjID
,
it
->
begin
);
SCSI
::
Structures
::
setU64
(
ud
.
get
()[
i
].
endLogicalObjID
,
it
->
end
);
++
it
;
}
...
...
@@ -810,14 +803,11 @@ void drive::DriveGeneric::generateRAO(std::map<std::string, SCSI::Structures::RA
int
real_params_len
=
sizeof
(
params
)
-
(
2000
-
udSize
)
*
sizeof
(
SCSI
::
Structures
::
RAO
::
udsDescriptor
);
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"IBM"
)
cdb
.
serviceAction
=
0x11
;
else
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"STK"
)
cdb
.
serviceAction
=
0x1d
;
cdb
.
serviceAction
=
0x1d
;
SCSI
::
Structures
::
setU32
(
cdb
.
paramsListLength
,
real_params_len
);
SCSI
::
Structures
::
setU32
(
params
.
additionalData
,
udSize
*
sizeof
(
*
ud
));
memcpy
(
&
params
.
userDataSegmentDescriptors
,
ud
,
udSize
*
sizeof
(
*
ud
));
SCSI
::
Structures
::
setU32
(
params
.
additionalData
,
udSize
*
sizeof
(
*
(
ud
.
get
())
));
memcpy
(
&
params
.
userDataSegmentDescriptors
,
ud
.
get
()
,
udSize
*
sizeof
(
*
(
ud
.
get
())
));
sgh
.
setCDB
(
&
cdb
);
sgh
.
setSenseBuffer
(
&
senseBuff
);
...
...
@@ -836,14 +826,10 @@ void drive::DriveGeneric::receiveRAO(int offset, int allocationLength) {
SCSI
::
Structures
::
LinuxSGIO_t
sgh
;
SCSI
::
Structures
::
RAO
::
recieveRAO_t
cdb
;
SCSI
::
Structures
::
senseData_t
<
255
>
senseBuff
;
unsigned
char
dataBuff
[
64008
];
unsigned
char
dataBuff
[
sizeof
(
SCSI
::
Structures
::
RAO
::
raoList
)
];
cdb
.
udsLimits
=
0
;
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"IBM"
)
cdb
.
serviceAction
=
0x11
;
else
if
(
this
->
getDeviceInfo
().
vendor
.
substr
(
0
,
3
)
==
"STK"
)
cdb
.
serviceAction
=
0x1d
;
cdb
.
serviceAction
=
0x1d
;
SCSI
::
Structures
::
setU32
(
cdb
.
allocationLength
,
allocationLength
);
SCSI
::
Structures
::
setU32
(
cdb
.
raoListOffset
,
offset
);
...
...
@@ -869,34 +855,7 @@ void drive::DriveGeneric::receiveRAO(int offset, int allocationLength) {
}
}
std
::
vector
<
std
::
string
>
split
(
std
::
string
to_split
,
std
::
string
delimiter
)
{
std
::
vector
<
std
::
string
>
toBeReturned
;
int
pos
=
0
;
while
((
pos
=
to_split
.
find
(
delimiter
))
!=
-
1
)
{
std
::
string
token
=
to_split
.
substr
(
0
,
pos
);
toBeReturned
.
push_back
(
token
);
to_split
.
erase
(
0
,
pos
+
delimiter
.
length
());
}
toBeReturned
.
push_back
(
to_split
);
return
toBeReturned
;
}
void
drive
::
DriveGeneric
::
queryRAO
(
char
*
filename
)
{
std
::
map
<
std
::
string
,
SCSI
::
Structures
::
RAO
::
blockLims
>
files
;
std
::
ifstream
ns_file_pick
(
filename
);
if
(
ns_file_pick
.
is_open
())
{
std
::
string
line
;
while
(
getline
(
ns_file_pick
,
line
))
{
std
::
vector
<
std
::
string
>
tokens
=
split
(
line
,
":"
);
SCSI
::
Structures
::
RAO
::
blockLims
lims
;
lims
.
begin
=
std
::
stoi
(
tokens
[
1
]);
lims
.
end
=
std
::
stoi
(
tokens
[
2
]);
files
[
tokens
[
0
]]
=
lims
;
}
}
else
{
throw
-
1
;
}
void
drive
::
DriveGeneric
::
queryRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
files
)
{
SCSI
::
Structures
::
RAO
::
udsLimitsPage_t
limits
=
getLimitUDS
();
generateRAO
(
files
,
limits
.
maxSupported
);
...
...
tapeserver/castor/tape/tapeserver/drive/DriveGeneric.hpp
View file @
d5a8098c
...
...
@@ -458,7 +458,7 @@ namespace drive {
* @param filename The name of the file containing the sequential order of
* a list of files [line format: ID:BLOCK_START:BLOCK_END]
*/
virtual
void
queryRAO
(
char
*
filename
);
virtual
void
queryRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
files
);
protected:
SCSI
::
DeviceInfo
m_SCSIInfo
;
...
...
@@ -507,7 +507,7 @@ namespace drive {
* and a pair of block limits
* @param maxSupported The maximum number of UDS supported - obtained by getLimitUDS()
*/
virtual
void
generateRAO
(
std
::
map
<
std
::
string
,
SCSI
::
Structures
::
RAO
::
blockLims
>
block
s
,
int
maxSupported
);
virtual
void
generateRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
file
s
,
int
maxSupported
);
/**
* Receive the Recommended Access Order
...
...
tapeserver/castor/tape/tapeserver/drive/DriveInterface.hpp
View file @
d5a8098c
...
...
@@ -33,6 +33,8 @@
#include
"common/exception/Exception.hpp"
#include
"common/exception/TimeOut.hpp"
#include
<list>
/**
* Class wrapping the tape server. Has to be templated (and hence fully in .hh)
* to allow unit testing against system wrapper.
...
...
@@ -230,7 +232,7 @@ namespace drive {
virtual
lbpToUse
getLbpToUse
()
=
0
;
virtual
bool
hasTapeInPlace
()
=
0
;
virtual
void
queryRAO
(
char
*
filename
)
=
0
;
virtual
void
queryRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
files
)
=
0
;
/**
* The configuration of the tape drive as parsed from the TPCONFIG file.
...
...
tapeserver/castor/tape/tapeserver/drive/FakeDrive.cpp
View file @
d5a8098c
...
...
@@ -297,7 +297,8 @@ bool castor::tape::tapeserver::drive::FakeDrive::hasTapeInPlace() {
return
true
;
}
void
castor
::
tape
::
tapeserver
::
drive
::
FakeDrive
::
queryRAO
(
char
*
filename
)
{
void
castor
::
tape
::
tapeserver
::
drive
::
FakeDrive
::
queryRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
files
)
{
throw
cta
::
exception
::
Exception
(
"In DriveFakeDrive::queryRAO: Not implemented."
);
}
...
...
tapeserver/castor/tape/tapeserver/drive/FakeDrive.hpp
View file @
d5a8098c
...
...
@@ -109,7 +109,7 @@ namespace drive {
virtual
bool
isTapeBlank
();
virtual
lbpToUse
getLbpToUse
();
virtual
bool
hasTapeInPlace
();
virtual
void
queryRAO
(
char
*
filename
);
virtual
void
queryRAO
(
std
::
list
<
SCSI
::
Structures
::
RAO
::
blockLims
>
&
files
);
};
}}}}
tapeserver/castor/tape/tapeserver/file/BasicReadWriteTest.cpp
View file @
d5a8098c
...
...
@@ -35,6 +35,7 @@
#include
<assert.h>
#include
<memory>
#include
<string>
#include
<list>
char
gen_random
()
{
static
const
char
alphanum
[]
=
...
...
@@ -69,6 +70,18 @@ public:
}
};
std
::
vector
<
std
::
string
>
split
(
std
::
string
to_split
,
std
::
string
delimiter
)
{
std
::
vector
<
std
::
string
>
toBeReturned
;
int
pos
=
0
;
while
((
pos
=
to_split
.
find
(
delimiter
))
!=
-
1
)
{
std
::
string
token
=
to_split
.
substr
(
0
,
pos
);
toBeReturned
.
push_back
(
token
);
to_split
.
erase
(
0
,
pos
+
delimiter
.
length
());
}
toBeReturned
.
push_back
(
to_split
);
return
toBeReturned
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
fail
=
0
;
...
...
@@ -227,7 +240,27 @@ int main (int argc, char *argv[])
}
else
{
drive
->
rewind
();
drive
->
queryRAO
(
argv
[
1
]);
std
::
list
<
castor
::
tape
::
SCSI
::
Structures
::
RAO
::
blockLims
>
files
;
std
::
ifstream
ns_file_pick
(
argv
[
1
]);
if
(
ns_file_pick
.
is_open
())
{
std
::
string
line
;
while
(
getline
(
ns_file_pick
,
line
))
{
std
::
vector
<
std
::
string
>
tokens
=
split
(
line
,
":"
);
castor
::
tape
::
SCSI
::
Structures
::
RAO
::
blockLims
lims
;
std
::
cout
<<
tokens
[
0
].
c_str
()
<<
std
::
endl
;
tokens
[
0
]
+=
'\0'
;
strcpy
((
char
*
)
lims
.
fseq
,
tokens
[
0
].
c_str
());
lims
.
begin
=
std
::
stoi
(
tokens
[
1
]);
lims
.
end
=
std
::
stoi
(
tokens
[
2
]);
files
.
push_back
(
lims
);
}
}
else
{
throw
-
1
;
}
drive
->
queryRAO
(
files
);
}
}
...
...
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