diff --git a/src/client/sysint/sys-osd-io.sm b/src/client/sysint/sys-osd-io.sm index 76ac150..7395c8c 100644 --- a/src/client/sysint/sys-osd-io.sm +++ b/src/client/sysint/sys-osd-io.sm @@ -401,7 +401,7 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) sm_p->msgarray[i].osd_sgl = sgl; /* free sgl later */ - + hdr_offset = 0; if (flag) { gossip_debug(GOSSIP_IO_DEBUG, "%s: Building STRIDED read from: Offset/Length pairs" " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); @@ -416,6 +416,7 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) set_htonll(sgl, sresult.segs); hdr_offset = sizeof(uint64_t); for ( j = 0; j < sresult.segs; j+=1 ) { + set_htonll((uint8_t *)sgl + hdr_offset, target_offset[j]); hdr_offset += sizeof(uint64_t); set_htonll((uint8_t *)sgl + hdr_offset, target_size[j]); @@ -526,7 +527,6 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) command->outdata = sgl; command->outlen = ddt_size; - } else { ret = -EINVAL; @@ -560,11 +560,8 @@ static int osd_io_completion_fn( struct osd_command *command = &sm_p->msgarray[index].osd_command; PVFS_size result_size; - if (sm_p->msgarray[index].osd_sgl != NULL) - free(sm_p->msgarray[index].osd_sgl); - if (sm_p->msgarray[index].osd_iov != NULL) - free(sm_p->msgarray[index].osd_iov); + /* fixup short read error */ @@ -600,10 +597,48 @@ static int osd_io_completion_fn( * No residual on write, always same as what we asked for, or * will get status error and fail. */ - result_size = (io->io_type == PVFS_IO_READ) ? - command->inlen : command->outlen; + + if (io->io_type == PVFS_IO_READ) { + gossip_debug(GOSSIP_IO_DEBUG, "%s: Read Completed\n", __func__); + result_size = command->inlen; + } else { + gossip_debug(GOSSIP_IO_DEBUG, "%s: Write Completed\n", __func__); + result_size = command->outlen; + if (osd_command_get_ddt(command) == DDT_CONTIG) { + /* do nothing */ + gossip_debug(GOSSIP_IO_DEBUG, "%s: CONTIG: %lld bytes complete\n", + __func__, lld(result_size)); + } else if (osd_command_get_ddt(command) == DDT_SGL) { + if (command->iov_outlen > 0) { /*buffer no longer has the data + directly in it but has IOVs*/ + uint64_t addr; + memcpy(&addr, command->outdata, sizeof(uint64_t)); + result_size -= ((get_ntohll((void *)addr) * sizeof(uint64_t) * 2) + + sizeof(uint64_t)); + gossip_debug(GOSSIP_IO_DEBUG, "%s: SGL: %lld bytes complete\n", + __func__, lld(result_size)); + } else { + gossip_err("%s: Invalid IOV count\n", __func__); + return -PVFS_EINVAL; + } + } else if (osd_command_get_ddt(command) == DDT_VEC) { + result_size -= (2 * sizeof(uint64_t)); + gossip_debug(GOSSIP_IO_DEBUG, "%s: VEC: %lld bytes complete\n", + __func__, lld(result_size)); + } else { + gossip_err("%s: Inavalid DDT OP\n", __func__); + return -PVFS_EINVAL; + } + } } + if (sm_p->msgarray[index].osd_sgl != NULL) + free(sm_p->msgarray[index].osd_sgl); + + if (sm_p->msgarray[index].osd_iov != NULL) + free(sm_p->msgarray[index].osd_iov); + + io->dfile_size_array[index] += result_size; io->total_size += result_size; @@ -615,12 +650,16 @@ static int osd_io_maybe_xfer_more(struct PINT_smcb *smcb, job_status_s *js_p) struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); struct PINT_client_io_sm *io = &sm_p->u.io; int i, more = 1; + /* only need to look at the first one */ + //~ struct osd_command *command = &sm_p->msgarray[0].osd_command; + + + gossip_debug(GOSSIP_IO_DEBUG, "%s: total %lld want %lld.\n", __func__, + lld(io->total_size), lld(io->mem_req->aggregate_size)); + + if (io->total_size == io->mem_req->aggregate_size) + more = 0; - /* all written (or entire read)? done */ - gossip_debug(GOSSIP_IO_DEBUG, "%s: total %lld want %lld\n", __func__, - lld(io->total_size), lld(io->mem_req->aggregate_size)); - if (io->total_size >= io->mem_req->aggregate_size) - more = 0; /* * If all short read, done. @@ -648,6 +687,9 @@ static int osd_io_maybe_xfer_more(struct PINT_smcb *smcb, job_status_s *js_p) } } + gossip_debug(GOSSIP_IO_DEBUG, "%s: End result is: More %d\n", __func__, + more); + js_p->error_code = more ? LOOP_NEXT_CHUNK : 0; return 1; }