Commit 8e8831f3 authored by David Goodell's avatar David Goodell
Browse files

[svn-r5374] Fix subarray test failures introduced in r4099.

The MPIDI_CH3U_Request_load_recv_iov function must fill the iov in the
rreq at offset 0 *and* set rreq->dev.iov_offset to 0 because callers of
this function as an OnDataAvail function don't know what action is
occurring in the handler and can't set the offset to zero themselves.

See r4099 and ticket #462 for some info on the previous test1_dt bug.

Reviewed by buntinas@.
parent 4a35b31c
......@@ -1430,6 +1430,10 @@ static int MPID_nem_tcp_recv_handler (struct pollfd *pfd, sockconn_t *sc)
MPID_IOV *iov = &rreq->dev.iov[rreq->dev.iov_offset];
int (*reqFn)(MPIDI_VC_t *, MPID_Request *, int *);
MPIU_Assert(rreq->dev.iov_count > 0);
MPIU_Assert(rreq->dev.iov_offset >= 0);
MPIU_Assert(rreq->dev.iov_count + rreq->dev.iov_offset <= MPID_IOV_LIMIT);
CHECK_EINTR(bytes_recvd, readv(sc->fd, iov, rreq->dev.iov_count));
if (bytes_recvd <= 0)
{
......
......@@ -79,6 +79,9 @@ int MPIDI_CH3_ReqHandler_SendReloadIOV( MPIDI_VC_t *vc ATTRIBUTE((unused)), MPID
{
int mpi_errno;
/* setting the iov_offset to 0 here is critical, since it is intentionally
* not set in the _load_send_iov function */
sreq->dev.iov_offset = 0;
sreq->dev.iov_count = MPID_IOV_LIMIT;
mpi_errno = MPIDI_CH3U_Request_load_send_iov(sreq, sreq->dev.iov,
&sreq->dev.iov_count);
......
......@@ -330,6 +330,7 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
(MPID_IOV_BUF_CAST)((char *) rreq->dev.tmpbuf +
rreq->dev.tmpbuf_off);
rreq->dev.iov[0].MPID_IOV_LEN = data_sz;
rreq->dev.iov_offset = 0;
rreq->dev.iov_count = 1;
MPIU_Assert(rreq->dev.segment_first + data_sz +
rreq->dev.tmpbuf_off <= rreq->dev.recv_data_sz);
......@@ -351,6 +352,7 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
last = rreq->dev.segment_size;
rreq->dev.iov_count = MPID_IOV_LIMIT;
rreq->dev.iov_offset = 0;
MPIU_DBG_MSG_FMT(CH3_CHANNEL,VERBOSE,(MPIU_DBG_FDEST,
"pre-upv: first=" MPIDI_MSG_SZ_FMT ", last=" MPIDI_MSG_SZ_FMT ", iov_n=%d",
rreq->dev.segment_first, last, rreq->dev.iov_count));
......@@ -358,7 +360,7 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
MPIU_Assert(last > 0);
MPID_Segment_unpack_vector(rreq->dev.segment_ptr,
rreq->dev.segment_first,
&last, &rreq->dev.iov[rreq->dev.iov_offset], &rreq->dev.iov_count);
&last, &rreq->dev.iov[0], &rreq->dev.iov_count);
MPIU_DBG_MSG_FMT(CH3_CHANNEL,VERBOSE,(MPIU_DBG_FDEST,
"post-upv: first=" MPIDI_MSG_SZ_FMT ", last=" MPIDI_MSG_SZ_FMT ", iov_n=%d, iov_offset=%d",
rreq->dev.segment_first, last, rreq->dev.iov_count, rreq->dev.iov_offset));
......@@ -380,6 +382,10 @@ int MPIDI_CH3U_Request_load_recv_iov(MPID_Request * const rreq)
mpi_errno = MPIDI_CH3U_Request_load_recv_iov(rreq);
goto fn_exit;
}
else
{
MPIU_Assert(rreq->dev.iov_offset < rreq->dev.iov_count);
}
/* --END ERROR HANDLING-- */
if (last == rreq->dev.recv_data_sz)
......
......@@ -527,6 +527,9 @@ static int MPIDI_CH3I_Send_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
MPIDI_FUNC_ENTER(MPID_STATE_MEMCPY);
MPIU_Memcpy(*dataloop, target_dtp->dataloop, target_dtp->dataloop_size);
MPIDI_FUNC_EXIT(MPID_STATE_MEMCPY);
/* the dataloop can have undefined padding sections, so we need to let
* valgrind know that it is OK to pass this data to writev later on */
MPIU_VG_MAKE_MEM_DEFINED(*dataloop, target_dtp->dataloop_size);
if (rma_op->type == MPIDI_RMA_PUT)
{
......@@ -752,6 +755,10 @@ static int MPIDI_CH3I_Recv_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
MPIU_Memcpy(*dataloop, dtp->dataloop, dtp->dataloop_size);
MPIDI_FUNC_EXIT(MPID_STATE_MEMCPY);
/* the dataloop can have undefined padding sections, so we need to let
* valgrind know that it is OK to pass this data to writev later on */
MPIU_VG_MAKE_MEM_DEFINED(*dataloop, dtp->dataloop_size);
get_pkt->dataloop_size = dtp->dataloop_size;
iov[0].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)get_pkt;
......@@ -760,7 +767,7 @@ static int MPIDI_CH3I_Recv_rma_msg(MPIDI_RMA_ops *rma_op, MPID_Win *win_ptr,
iov[1].MPID_IOV_LEN = sizeof(*dtype_info);
iov[2].MPID_IOV_BUF = (MPID_IOV_BUF_CAST)*dataloop;
iov[2].MPID_IOV_LEN = dtp->dataloop_size;
MPIU_THREAD_CS_ENTER(CH3COMM,vc);
mpi_errno = MPIU_CALL(MPIDI_CH3,iStartMsgv(vc, iov, 3, &req));
MPIU_THREAD_CS_EXIT(CH3COMM,vc);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment