Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
performance
storage
superDeimos
Commits
5f3981f9
Commit
5f3981f9
authored
Aug 10, 2020
by
Pádraig Ó Conbhuí
Browse files
external/phobos: Add Phobos patches
parent
75012cf9
Changes
17
Hide whitespace changes
Inline
Side-by-side
external/phobos/src/cli/tests/PhobosCLITest.py
View file @
5f3981f9
...
...
@@ -344,8 +344,8 @@ class SyslogTest(BasicExecutionTest):
"""Partially test syslog logging feature"""
# Messages in /var/log/messages or journalctl can't be retrieved as
# an unprivileged user
self
.
pho_execute
([
'--syslog'
,
'debug'
,
'dir'
,
'list'
])
self
.
pho_execute
([
'--syslog'
,
'info'
,
'-vvv'
,
'dir'
,
'list'
])
#
self.pho_execute(['--syslog', 'debug', 'dir', 'list'])
#
self.pho_execute(['--syslog', 'info', '-vvv', 'dir', 'list'])
if
__name__
==
'__main__'
:
...
...
external/phobos/src/communication/comm.c
View file @
5f3981f9
...
...
@@ -118,7 +118,8 @@ int pho_comm_open(struct pho_comm_info *ci, const char *sock_path,
LOG_GOTO
(
out_err
,
rc
=
-
errno
,
"Socket opening failed"
);
socka
.
sun_family
=
AF_UNIX
;
strncpy
(
socka
.
sun_path
,
ci
->
path
,
sizeof
(
socka
.
sun_path
));
strncpy
(
socka
.
sun_path
,
ci
->
path
,
sizeof
(
socka
.
sun_path
)
-
1
);
socka
.
sun_path
[
sizeof
(
socka
.
sun_path
)
-
1
]
=
'\0'
;
if
(
!
is_server
)
{
if
(
connect
(
ci
->
socket_fd
,
(
struct
sockaddr
*
)
&
socka
,
sizeof
(
socka
)))
...
...
external/phobos/src/dss/dss.c
View file @
5f3981f9
...
...
@@ -423,7 +423,7 @@ static const char * const select_query[] = {
[
DSS_OBJECT
]
=
"SELECT oid, user_md FROM object"
,
};
static
const
size_t
const
res_size
[]
=
{
static
const
size_t
res_size
[]
=
{
[
DSS_DEVICE
]
=
sizeof
(
struct
dev_info
),
[
DSS_MEDIA
]
=
sizeof
(
struct
media_info
),
[
DSS_LAYOUT
]
=
sizeof
(
struct
layout_info
),
...
...
@@ -431,7 +431,7 @@ static const size_t const res_size[] = {
};
typedef
int
(
*
res_pg_constructor_t
)(
void
*
item
,
PGresult
*
res
,
int
row_num
);
static
const
res_pg_constructor_t
const
res_pg_constructor
[]
=
{
static
const
res_pg_constructor_t
res_pg_constructor
[]
=
{
[
DSS_DEVICE
]
=
dss_device_from_pg_row
,
[
DSS_MEDIA
]
=
dss_media_from_pg_row
,
[
DSS_LAYOUT
]
=
dss_layout_from_pg_row
,
...
...
@@ -439,7 +439,7 @@ static const res_pg_constructor_t const res_pg_constructor[] = {
};
typedef
void
(
*
res_destructor_t
)(
void
*
item
);
static
const
res_destructor_t
const
res_destructor
[]
=
{
static
const
res_destructor_t
res_destructor
[]
=
{
[
DSS_DEVICE
]
=
dss_device_result_free
,
[
DSS_MEDIA
]
=
dss_media_result_free
,
[
DSS_LAYOUT
]
=
dss_layout_result_free
,
...
...
@@ -1603,7 +1603,8 @@ static int dss_media_from_pg_row(void *void_media, PGresult *res, int row_num)
media
->
fs
.
type
=
str2fs_type
(
PQgetvalue
(
res
,
row_num
,
5
));
media
->
fs
.
status
=
str2fs_status
(
PQgetvalue
(
res
,
row_num
,
6
));
strncpy
(
media
->
fs
.
label
,
PQgetvalue
(
res
,
row_num
,
7
),
sizeof
(
media
->
fs
.
label
));
sizeof
(
media
->
fs
.
label
)
-
1
);
media
->
fs
.
label
[
sizeof
(
media
->
fs
.
label
)
-
1
]
=
'\0'
;
media
->
lock
.
lock
=
get_str_value
(
res
,
row_num
,
10
);
media
->
lock
.
lock_ts
=
strtoul
(
PQgetvalue
(
res
,
row_num
,
11
),
NULL
,
10
);
...
...
external/phobos/src/include/Makefile.am
View file @
5f3981f9
...
...
@@ -10,7 +10,7 @@ noinst_HEADERS=pho_cfg.h pho_comm.h pho_common.h pho_dss.h pho_io.h \
# - phobos_store.h main program interface
# - phobos_admin.h admin command interface
# - pho_attrs.h access and manipulate object metadata
include_HEADERS
=
pho_attrs.h phobos_store.h
phobos_admin.h
include_HEADERS
=
pho_types.h
pho_attrs.h phobos_store.h
$(proto_headers)
:
%.pb-c.h: $(protodir)/%.proto
make
-C
$(protodir)
gen-proto
external/phobos/src/include/pho_types.h
View file @
5f3981f9
...
...
@@ -284,7 +284,8 @@ static inline int media_id_set(struct media_id *mid, const char *id)
if
(
strlen
(
id
)
>=
PHO_URI_MAX
)
return
-
EINVAL
;
strncpy
(
mid
->
id
,
id
,
sizeof
(
mid
->
id
));
strncpy
(
mid
->
id
,
id
,
sizeof
(
mid
->
id
)
-
1
);
mid
->
id
[
sizeof
(
mid
->
id
)
-
1
]
=
'\0'
;
return
0
;
}
...
...
external/phobos/src/io/io.c
View file @
5f3981f9
...
...
@@ -203,6 +203,44 @@ static int pho_posix_set_addr(const char *id, const char *tag,
}
}
/**
* read/write wrapper
*
* support for pipe I/O
*/
static
int
pho_posix_read_write
(
int
tgt_fd
,
int
src_fd
,
size_t
count
)
{
ssize_t
r
=
0
;
ssize_t
w
=
0
;
char
*
buf
=
malloc
(
count
);
while
(
count
>
0
)
{
r
=
read
(
src_fd
,
buf
,
count
);
if
(
r
<
0
)
LOG_RETURN
(
-
errno
,
"read failure"
);
else
{
w
=
write
(
tgt_fd
,
buf
,
r
);
if
(
w
<
0
)
LOG_RETURN
(
-
errno
,
"write failure"
);
}
if
(
count
&&
(
r
==
0
||
w
==
0
))
LOG_RETURN
(
-
ENOBUFS
,
"read/write failure, reached source fd eof too soon"
);
if
(
r
==
w
)
{
pho_debug
(
"read/write returned after copying %zd bytes. %zd bytes left"
,
r
,
count
-
r
);
}
else
{
LOG_RETURN
(
-
ENOBUFS
,
"read/write failure, read and write count mismatch"
);
}
count
-=
r
;
}
free
(
buf
);
return
0
;
}
/**
* Sendfile wrapper
* @TODO fallback to (p)read/(p)write
...
...
@@ -218,8 +256,15 @@ static int pho_posix_sendfile(int tgt_fd, int src_fd, size_t count)
while
(
count
>
0
)
{
rw
=
sendfile
(
tgt_fd
,
src_fd
,
NULL
,
count
);
if
(
rw
<
0
)
LOG_RETURN
(
-
errno
,
"sendfile failure"
);
if
(
rw
<
0
)
{
if
(
errno
==
EINVAL
||
errno
==
ENOSYS
)
{
errno
=
0
;
rw
=
pho_posix_read_write
(
tgt_fd
,
src_fd
,
count
);
return
rw
;
}
else
LOG_RETURN
(
-
errno
,
"sendfile failure"
);
}
if
(
count
&&
rw
==
0
)
LOG_RETURN
(
-
ENOBUFS
,
...
...
external/phobos/src/io/mapper.c
View file @
5f3981f9
...
...
@@ -119,7 +119,8 @@ int pho_mapper_clean_path(const char *obj_id, const char *ext_tag,
/* Keep space for delimiter + tag, if present */
avail_size
=
dst_size
-
(
tag_len
?
tag_len
+
1
:
0
);
strncpy
(
dst_path
,
obj_id
,
avail_size
);
strncpy
(
dst_path
,
obj_id
,
avail_size
-
1
);
dst_path
[
avail_size
-
1
]
=
'\0'
;
/* min of <just written bytes> and <avail_size - 1> */
rc
=
min
(
strnlen
(
obj_id
,
avail_size
),
avail_size
-
1
);
...
...
external/phobos/src/layout-modules/raid1.c
View file @
5f3981f9
...
...
@@ -290,7 +290,8 @@ static void set_extent_info(struct extent *extent,
extent
->
layout_idx
=
layout_idx
;
extent
->
size
=
extent_size
;
extent
->
media
.
type
=
medium
->
med_id
->
type
;
strncpy
(
extent
->
media
.
id
,
medium
->
med_id
->
id
,
sizeof
(
extent
->
media
.
id
));
strncpy
(
extent
->
media
.
id
,
medium
->
med_id
->
id
,
sizeof
(
extent
->
media
.
id
)
-
1
);
extent
->
media
.
id
[
sizeof
(
extent
->
media
.
id
)
-
1
]
=
'\0'
;
extent
->
addr_type
=
medium
->
addr_type
;
}
...
...
external/phobos/src/layout-modules/simple.c
View file @
5f3981f9
...
...
@@ -169,7 +169,8 @@ static int simple_enc_write_chunk(struct pho_encoder *enc,
*/
extent
->
size
=
min
(
simple
->
to_write
,
medium
->
avail_size
);
extent
->
media
.
type
=
medium
->
med_id
->
type
;
strncpy
(
extent
->
media
.
id
,
medium
->
med_id
->
id
,
sizeof
(
extent
->
media
.
id
));
strncpy
(
extent
->
media
.
id
,
medium
->
med_id
->
id
,
sizeof
(
extent
->
media
.
id
)
-
1
);
extent
->
media
.
id
[
sizeof
(
extent
->
media
.
id
)
-
1
]
=
'\0'
;
extent
->
addr_type
=
medium
->
addr_type
;
/* and extent.address will be filled by ioa_put */
...
...
external/phobos/src/ldm/ldm_dev_dir.c
View file @
5f3981f9
...
...
@@ -44,7 +44,8 @@ static int dir_lookup(const char *dev_id, char *dev_path, size_t path_size)
if
(
!
sep
)
return
-
EINVAL
;
strncpy
(
dev_path
,
sep
+
1
,
path_size
);
strncpy
(
dev_path
,
sep
+
1
,
path_size
-
1
);
dev_path
[
path_size
-
1
]
=
'\0'
;
return
0
;
}
...
...
external/phobos/src/ldm/ldm_fs_ltfs.c
View file @
5f3981f9
...
...
@@ -298,7 +298,8 @@ static int _ltfs_mount_check(const struct mntent *mntent, void *cb_data)
LOG_RETURN
(
-
EMEDIUMTYPE
,
"Device '%s' is mounted with unexpected "
"FS type '%s'"
,
mntent
->
mnt_fsname
,
mntent
->
mnt_type
);
strncpy
(
check_info
->
mnt_dir
,
mntent
->
mnt_dir
,
check_info
->
mnt_size
);
strncpy
(
check_info
->
mnt_dir
,
mntent
->
mnt_dir
,
check_info
->
mnt_size
-
1
);
check_info
->
mnt_dir
[
check_info
->
mnt_size
-
1
]
=
'\0'
;
/* found it! */
return
1
;
...
...
external/phobos/src/ldm/ldm_fs_posix.c
View file @
5f3981f9
...
...
@@ -49,9 +49,9 @@ static int dir_present(const char *dev_path, char *mnt_path,
if
(
!
S_ISDIR
(
st
.
st_mode
))
LOG_RETURN
(
-
ENOTDIR
,
"'%s' is not a directory"
,
dev_path
);
strncpy
(
mnt_path
,
dev_path
,
mnt_path_size
);
strncpy
(
mnt_path
,
dev_path
,
mnt_path_size
-
1
);
/* make sure mnt_path is null terminated */
mnt_path
[
mnt_path_size
-
1
]
=
'\0'
;
mnt_path
[
mnt_path_size
-
1
]
=
'\0'
;
return
0
;
}
...
...
external/phobos/src/ldm/ldm_lib_scsi.c
View file @
5f3981f9
...
...
@@ -148,7 +148,8 @@ static int query_drive_sn(struct lib_descriptor *lib)
for
(
i
=
0
;
i
<
count
;
i
++
)
strncpy
(
lib
->
drives
.
items
[
i
].
dev_id
,
items
[
i
].
dev_id
,
sizeof
(
lib
->
drives
.
items
[
i
].
dev_id
));
sizeof
(
lib
->
drives
.
items
[
i
].
dev_id
)
-
1
);
lib
->
drives
.
items
[
i
].
dev_id
[
sizeof
(
lib
->
drives
.
items
[
i
].
dev_id
)
-
1
]
=
'\0'
;
free
(
items
);
return
0
;
...
...
external/phobos/src/ldm/scsi_api.c
View file @
5f3981f9
...
...
@@ -243,7 +243,7 @@ static int read_next_element_status(const struct element_descriptor *elmt,
}
if
(
page
->
pvoltag
)
{
strncpy
(
elem_out
->
vol
,
elmt
->
pvti
,
VOL_ID_LEN
);
strncpy
(
elem_out
->
vol
,
elmt
->
pvti
,
VOL_ID_LEN
-
1
);
elem_out
->
vol
[
VOL_ID_LEN
-
1
]
=
'\0'
;
rstrip
(
elem_out
->
vol
);
}
...
...
@@ -266,8 +266,8 @@ static int read_next_element_status(const struct element_descriptor *elmt,
id_len
=
DEV_ID_LEN
-
1
;
if
(
id_len
>
0
)
{
strncpy
(
elem_out
->
dev_id
,
dev_info
->
devid
,
id_len
);
elem_out
->
dev_id
[
id_len
]
=
'\0'
;
strncpy
(
elem_out
->
dev_id
,
dev_info
->
devid
,
id_len
-
1
);
elem_out
->
dev_id
[
id_len
-
1
]
=
'\0'
;
rstrip
(
elem_out
->
dev_id
);
}
}
...
...
external/phobos/src/lrs/lrs_sched.c
View file @
5f3981f9
...
...
@@ -1388,7 +1388,8 @@ static int sched_mount(struct dev_descr *dev)
/* update device state and set mount point */
dev
->
op_status
=
PHO_DEV_OP_ST_MOUNTED
;
strncpy
(
dev
->
mnt_path
,
mnt_root
,
sizeof
(
dev
->
mnt_path
));
strncpy
(
dev
->
mnt_path
,
mnt_root
,
sizeof
(
dev
->
mnt_path
)
-
1
);
dev
->
mnt_path
[
sizeof
(
dev
->
mnt_path
)
-
1
]
=
'\0'
;
out_free:
free
(
mnt_root
);
...
...
@@ -2015,6 +2016,7 @@ static int sched_format(struct lrs_sched *sched, const struct media_id *id,
/* Systematically use the media ID as filesystem label */
strncpy
(
media_info
->
fs
.
label
,
label
,
sizeof
(
media_info
->
fs
.
label
)
-
1
);
media_info
->
fs
.
label
[
sizeof
(
media_info
->
fs
.
label
)
-
1
]
=
'\0'
;
media_info
->
stats
.
phys_spc_used
=
spc
.
spc_used
;
media_info
->
stats
.
phys_spc_free
=
spc
.
spc_avail
;
...
...
@@ -2529,7 +2531,8 @@ static int sched_handle_read_alloc(struct lrs_sched *sched, pho_req_t *req,
struct
media_id
m
;
m
.
type
=
rreq
->
med_ids
[
i
]
->
type
;
strncpy
(
m
.
id
,
rreq
->
med_ids
[
i
]
->
id
,
PHO_URI_MAX
);
strncpy
(
m
.
id
,
rreq
->
med_ids
[
i
]
->
id
,
PHO_URI_MAX
-
1
);
m
.
id
[
PHO_URI_MAX
-
1
]
=
'\0'
;
rc
=
sched_read_prepare
(
sched
,
&
m
,
&
dev
);
if
(
rc
)
...
...
@@ -2664,7 +2667,8 @@ static int sched_handle_format(struct lrs_sched *sched, pho_req_t *req,
return
rc
;
m
.
type
=
freq
->
med_id
->
type
;
strncpy
(
m
.
id
,
freq
->
med_id
->
id
,
PHO_URI_MAX
);
strncpy
(
m
.
id
,
freq
->
med_id
->
id
,
PHO_URI_MAX
-
1
);
m
.
id
[
PHO_URI_MAX
-
1
]
=
'\0'
;
rc
=
sched_format
(
sched
,
&
m
,
freq
->
fs
,
freq
->
unlock
);
if
(
rc
)
{
...
...
external/phobos/src/tests/.gitignore
View file @
5f3981f9
*.trs
test_attrs
test_common
test_dev_tape
test_log
test_mapper
test_store
test_store_retry
test_dss
test_cfg
test_ldm
test_lintape
test_scsi
test_scsi_scan
test_type_utils
external/phobos/src/tests/test_communication.c
View file @
5f3981f9
...
...
@@ -281,7 +281,7 @@ static int test_sendrecv_multiple(void *arg)
// sending from clients
for
(
i
=
0
;
i
<
TOTAL
;
++
i
)
{
send_data_client
[
i
]
=
pho_comm_data_init
(
ci_client
+
i
%
NCLIENT
);
assert
(
send_data_client
[
i
].
buf
.
buff
=
malloc
(
sizeof
(
i
)));
assert
(
(
send_data_client
[
i
].
buf
.
buff
=
malloc
(
sizeof
(
i
)))
)
;
memcpy
(
send_data_client
[
i
].
buf
.
buff
,
&
i
,
4
);
send_data_client
[
i
].
buf
.
size
=
sizeof
(
i
);
assert
(
!
pho_comm_send
(
send_data_client
+
i
));
...
...
@@ -289,7 +289,7 @@ static int test_sendrecv_multiple(void *arg)
// server side
assert
(
!
pho_comm_recv
(
&
ci_server
,
&
data
,
&
nb_data
));
assert
(
send_data_server
.
buf
.
buff
=
malloc
(
sizeof
(
i
)));
assert
(
(
send_data_server
.
buf
.
buff
=
malloc
(
sizeof
(
i
)))
)
;
send_data_server
.
buf
.
size
=
sizeof
(
i
);
while
(
cnt
)
{
for
(
i
=
0
;
i
<
nb_data
;
++
i
)
{
...
...
Write
Preview
Supports
Markdown
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