Skip to content

Commit 373bc9c

Browse files
committed
btl/vader: correctly handle short read/write in process_vm_{read,write}v
Thanks Heiko Bauke for the bug report. Refs. #4829 Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent cd35c49 commit 373bc9c

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

opal/mca/btl/vader/btl_vader_get.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/*
33
* Copyright (c) 2010-2014 Los Alamos National Security, LLC. All rights
44
* reserved.
5+
* Copyright (c) 2018 Research Organization for Information Science
6+
* and Technology (RIST). All rights reserved.
57
* $COPYRIGHT$
68
*
79
* Additional copyrights may follow
@@ -23,6 +25,7 @@
2325
#include "opal/sys/cma.h"
2426
#endif /* OPAL_CMA_NEED_SYSCALL_DEFS */
2527

28+
2629
#endif
2730

2831
/**
@@ -71,11 +74,17 @@ int mca_btl_vader_get_cma (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *
7174
struct iovec dst_iov = {.iov_base = local_address, .iov_len = size};
7275
ssize_t ret;
7376

74-
ret = process_vm_readv (endpoint->segment_data.other.seg_ds->seg_cpid, &dst_iov, 1, &src_iov, 1, 0);
75-
if (ret != (ssize_t)size) {
76-
opal_output(0, "Read %ld, expected %lu, errno = %d\n", (long)ret, (unsigned long)size, errno);
77-
return OPAL_ERROR;
78-
}
77+
do {
78+
ret = process_vm_readv (endpoint->segment_data.other.seg_ds->seg_cpid, &dst_iov, 1, &src_iov, 1, 0);
79+
if (0 > ret) {
80+
opal_output(0, "Read %ld, expected %lu, errno = %d\n", (long)ret, (unsigned long)size, errno);
81+
return OPAL_ERROR;
82+
}
83+
src_iov.iov_base = (void *)((char *)src_iov.iov_base + ret);
84+
src_iov.iov_len -= ret;
85+
dst_iov.iov_base = (void *)((char *)dst_iov.iov_base + ret);
86+
dst_iov.iov_len -= ret;
87+
} while (0 < src_iov.iov_len);
7988

8089
/* always call the callback function */
8190
cbfunc (btl, endpoint, local_address, local_handle, cbcontext, cbdata, OPAL_SUCCESS);

opal/mca/btl/vader/btl_vader_put.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
/*
33
* Copyright (c) 2010-2014 Los Alamos National Security, LLC. All rights
44
* reserved.
5-
* Copyright (c) 2014 Research Organization for Information Science
6-
* and Technology (RIST). All rights reserved.
5+
* Copyright (c) 2014-2018 Research Organization for Information Science
6+
* and Technology (RIST). All rights reserved.
77
* $COPYRIGHT$
88
*
99
* Additional copyrights may follow
@@ -69,11 +69,17 @@ int mca_btl_vader_put_cma (mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *
6969
struct iovec dst_iov = {.iov_base = (void *)(intptr_t) remote_address, .iov_len = size};
7070
ssize_t ret;
7171

72-
ret = process_vm_writev (endpoint->segment_data.other.seg_ds->seg_cpid, &src_iov, 1, &dst_iov, 1, 0);
73-
if (ret != (ssize_t)size) {
74-
opal_output(0, "Wrote %ld, expected %lu, errno = %d\n", (long)ret, (unsigned long)size, errno);
75-
return OPAL_ERROR;
76-
}
72+
do {
73+
ret = process_vm_writev (endpoint->segment_data.other.seg_ds->seg_cpid, &src_iov, 1, &dst_iov, 1, 0);
74+
if (0 > ret) {
75+
opal_output(0, "Wrote %ld, expected %lu, errno = %d\n", (long)ret, (unsigned long)size, errno);
76+
return OPAL_ERROR;
77+
}
78+
src_iov.iov_base = (void *)((char *)src_iov.iov_base + ret);
79+
src_iov.iov_len -= ret;
80+
dst_iov.iov_base = (void *)((char *)dst_iov.iov_base + ret);
81+
dst_iov.iov_len -= ret;
82+
} while (0 < src_iov.iov_len);
7783

7884
/* always call the callback function */
7985
cbfunc (btl, endpoint, local_address, local_handle, cbcontext, cbdata, OPAL_SUCCESS);

0 commit comments

Comments
 (0)