From 5687d771ea1f3cac44e7980d8f5c595007d41dab Mon Sep 17 00:00:00 2001 From: Pete Wyckoff Date: Sat, 23 Feb 2008 12:52:33 -0500 Subject: [PATCH] Convert tabs to 4-spaces; old editor tab workaround. --- src/client/sysint/sys-osd-io.sm | 760 ++++++++++++++++---------------- 1 file changed, 380 insertions(+), 380 deletions(-) diff --git a/src/client/sysint/sys-osd-io.sm b/src/client/sysint/sys-osd-io.sm index cc40db6..9946a3a 100644 --- a/src/client/sysint/sys-osd-io.sm +++ b/src/client/sysint/sys-osd-io.sm @@ -176,52 +176,52 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) PVFS_object_attr *attr = &sm_p->getattr.attr; int i, ret = 0; struct osd_command *command; - struct bsg_iovec *iov; - int dfile_count = sm_p->u.io.datafile_count; + struct bsg_iovec *iov; + int dfile_count = sm_p->u.io.datafile_count; /* clients offset and length pairs */ PVFS_offset offseta[OSD_INIT_MAX_IOVEC]; PVFS_size sizea[OSD_INIT_MAX_IOVEC]; - int csegs_count; - PVFS_size cagg_len; + int csegs_count; + PVFS_size cagg_len; - /* temporary space for querying offset length pairs */ - PVFS_offset temp_offset[OSD_INIT_MAX_IOVEC]; + /* temporary space for querying offset length pairs */ + PVFS_offset temp_offset[OSD_INIT_MAX_IOVEC]; PVFS_size temp_size[OSD_INIT_MAX_IOVEC]; /* targets offset and length pairs */ PVFS_offset target_offset[OSD_INIT_MAX_IOVEC]; PVFS_size target_size[OSD_INIT_MAX_IOVEC]; - /* total bytes to read/write from each io server */ + /* total bytes to read/write from each io server */ PVFS_size sbytemax = io->mem_req->aggregate_size; - PVFS_size this_aggregate_size = 0; + PVFS_size this_aggregate_size = 0; - /* structures to pass into req proc engine */ + /* structures to pass into req proc engine */ PINT_Request_result sresult, cresult; - /* kernel SCSI layer can only handle so many pages at once */ + /* kernel SCSI layer can only handle so many pages at once */ if (sbytemax > KERNEL_BUFSIZE) { - gossip_debug(GOSSIP_IO_DEBUG, "%s: SCSI buffer %lld cant handle %lld\n", - __func__, lld(KERNEL_BUFSIZE), lld(sbytemax)); - sbytemax = KERNEL_BUFSIZE; + gossip_debug(GOSSIP_IO_DEBUG, "%s: SCSI buffer %lld cant handle %lld\n", + __func__, lld(KERNEL_BUFSIZE), lld(sbytemax)); + sbytemax = KERNEL_BUFSIZE; - } + } - /* for each datafile/io server/osd write ALL of its data */ + /* for each datafile/io server/osd write ALL of its data */ for (i = 0; i < dfile_count; i++) { uint8_t *p; uint32_t len; PVFS_offset cur_offset; - PVFS_handle datafile_handle; - int j; + PVFS_handle datafile_handle; + int j; - datafile_handle = attr->u.meta.dfile_array[io->datafile_index_array[i]]; + datafile_handle = attr->u.meta.dfile_array[io->datafile_index_array[i]]; if (PINT_REQUEST_DONE(&io->file_req_state[i]) || io->short_read[i]) { - gossip_debug(GOSSIP_IO_DEBUG, "%s: Nothing to do for server %d\n", - __func__, i); + gossip_debug(GOSSIP_IO_DEBUG, "%s: Nothing to do for server %d\n", + __func__, i); sm_p->msgarray[i].suppress = 1; /* disable this entry */ continue; } @@ -237,351 +237,351 @@ static int osd_io_setup_msgpairs(struct PINT_smcb *smcb, job_status_s *js_p) lld(io->file_req_state[i].type_offset), lld(io->file_req_state[i].target_offset), lld(io->file_req_state[i].final_offset), - lld(cur_offset), - lld(sbytemax)); + lld(cur_offset), + lld(sbytemax)); - PINT_REQUEST_STATE_RST(io->temp_req_state); + PINT_REQUEST_STATE_RST(io->temp_req_state); - /* */ - /* figure out servers offset/lengths should get all in one go */ - /* */ - sresult.segs = 0; + /* */ + /* figure out servers offset/lengths should get all in one go */ + /* */ + sresult.segs = 0; sresult.bytes = 0; sresult.bytemax = sbytemax; /* request full size */ - sresult.offset_array = target_offset; + sresult.offset_array = target_offset; sresult.size_array = target_size; sresult.segmax = OSD_INIT_MAX_IOVEC; - /* set up the io req state to pass in */ - io->temp_req_state->target_offset = cur_offset; /*may or may not be 0 */ + /* set up the io req state to pass in */ + io->temp_req_state->target_offset = cur_offset; /*may or may not be 0 */ io->temp_req_state->final_offset = io->file_req_state[i].final_offset; - ret = PINT_process_request(io->temp_req_state, NULL, &io->file_data[i], + ret = PINT_process_request(io->temp_req_state, NULL, &io->file_data[i], &sresult, PINT_SERVER); if (ret) { gossip_err("%s: server %d process_request call failed\n", - __func__, i); + __func__, i); goto out; } - this_aggregate_size += sresult.bytes; - - gossip_debug(GOSSIP_IO_DEBUG, "%s: Current Offset %lld\n", __func__, - lld(target_offset[0])); - - #if 0 - printf("SERVER INFO [%d]:\n", i); - printf("Total size %lld \n", lld(sresult.bytes)); - for (j = 0; j < sresult.segs; j++) { - printf("offset= %lld length= %lld\n", lld(target_offset[j]), - lld(target_size[j])); - } - #endif - - /* */ - /* figure out clinets offset/lengths one stripe at a time */ - /* */ - csegs_count = 0; - cagg_len = 0; - - while (cagg_len != sresult.bytes) { - cresult.segs = 0; - cresult.bytes = 0; - cresult.bytemax = sresult.bytes; - cresult.offset_array = temp_offset; - cresult.size_array = temp_size; - cresult.segmax = OSD_INIT_MAX_IOVEC - csegs_count; - - ret = PINT_process_request(&io->file_req_state[i], - &io->mem_req_state[i], &io->file_data[i], - &cresult, PINT_CLIENT); - if (ret) { - gossip_err("%s: client %d process_request call failed\n", - __func__, i); - goto out; - } - - /* now move the results for this strip to the perm array */ - for (j = 0; j < cresult.segs; j++) { - offseta[csegs_count + j] = temp_offset[j]; - sizea[csegs_count + j] = temp_size[j]; - } - csegs_count += cresult.segs; - cagg_len += cresult.bytes; - - if(cagg_len > sresult.bytes) { - gossip_err("%s: Client Agg len too big\n", __func__); - ret = -EINVAL; - goto out; - } - } - - #if 0 - printf("CLIENT INFO [%d]:\n", i); - printf("Total size %lld\n", lld(cagg_len)); - for( j = 0; j < csegs_count; j++ ) { - printf("offset= %lld length= %lld\n", lld(offseta[j]), - lld(sizea[j])); - } - #endif - - gossip_debug(GOSSIP_IO_DEBUG, "%s: %d: %d Server Segments, %lld bytes\n", - __func__, i, sresult.segs, lld(sresult.bytes)); - gossip_debug(GOSSIP_IO_DEBUG, "%s: %d: %d Client Segments, %lld bytes\n", - __func__, i, csegs_count, lld(cagg_len)); + this_aggregate_size += sresult.bytes; + + gossip_debug(GOSSIP_IO_DEBUG, "%s: Current Offset %lld\n", __func__, + lld(target_offset[0])); + + #if 0 + printf("SERVER INFO [%d]:\n", i); + printf("Total size %lld \n", lld(sresult.bytes)); + for (j = 0; j < sresult.segs; j++) { + printf("offset= %lld length= %lld\n", lld(target_offset[j]), + lld(target_size[j])); + } + #endif + + /* */ + /* figure out clinets offset/lengths one stripe at a time */ + /* */ + csegs_count = 0; + cagg_len = 0; + + while (cagg_len != sresult.bytes) { + cresult.segs = 0; + cresult.bytes = 0; + cresult.bytemax = sresult.bytes; + cresult.offset_array = temp_offset; + cresult.size_array = temp_size; + cresult.segmax = OSD_INIT_MAX_IOVEC - csegs_count; + + ret = PINT_process_request(&io->file_req_state[i], + &io->mem_req_state[i], &io->file_data[i], + &cresult, PINT_CLIENT); + if (ret) { + gossip_err("%s: client %d process_request call failed\n", + __func__, i); + goto out; + } + + /* now move the results for this strip to the perm array */ + for (j = 0; j < cresult.segs; j++) { + offseta[csegs_count + j] = temp_offset[j]; + sizea[csegs_count + j] = temp_size[j]; + } + csegs_count += cresult.segs; + cagg_len += cresult.bytes; + + if(cagg_len > sresult.bytes) { + gossip_err("%s: Client Agg len too big\n", __func__); + ret = -EINVAL; + goto out; + } + } + + #if 0 + printf("CLIENT INFO [%d]:\n", i); + printf("Total size %lld\n", lld(cagg_len)); + for( j = 0; j < csegs_count; j++ ) { + printf("offset= %lld length= %lld\n", lld(offseta[j]), + lld(sizea[j])); + } + #endif + + gossip_debug(GOSSIP_IO_DEBUG, "%s: %d: %d Server Segments, %lld bytes\n", + __func__, i, sresult.segs, lld(sresult.bytes)); + gossip_debug(GOSSIP_IO_DEBUG, "%s: %d: %d Client Segments, %lld bytes\n", + __func__, i, csegs_count, lld(cagg_len)); command = &sm_p->msgarray[i].osd_command; - /* must be initalized to NULL for later check */ - sm_p->msgarray[i].osd_iov = NULL; - sm_p->msgarray[i].osd_sgl = NULL; + /* must be initalized to NULL for later check */ + sm_p->msgarray[i].osd_iov = NULL; + sm_p->msgarray[i].osd_sgl = NULL; p = io->buffer; - if (sresult.segs == 1) { /* contiguous server buff to write to */ - if (csegs_count == 1) { - p += offseta[0]; - len = sizea[0]; - csegs_count = 0; /* do not build a 1-unit iovec */ - } else if (csegs_count > 1) { - iov = malloc(csegs_count * sizeof(*iov)); - if (iov == NULL) { - ret = -ENOMEM; - goto out; - } - len = 0; - int j; - for (j=0; jmsgarray[i].osd_iov = p; /* free IOV later */ - } else { - ret = -EINVAL; - goto out; - } - - /* Build the command for this server, using physical offset. */ - if (io->io_type == PVFS_IO_READ) { - osd_command_set_read(command, PVFS_OSD_DATA_PID, datafile_handle, - len, target_offset[0]); - command->indata = p; - command->inlen_alloc = len; - command->iov_inlen = csegs_count; - - } else if (io->io_type == PVFS_IO_WRITE) { - osd_command_set_write(command, PVFS_OSD_DATA_PID, datafile_handle, - len, target_offset[0]); - command->outdata = p; - command->outlen = len; - command->iov_outlen = csegs_count; - } - - } else { /* either need a SGL or optimized SGL */ - int j, flag, stride, segl, total_len; - void *sgl = NULL; - len = 0; - uint64_t ddt_size, hdr_offset; - - if (sresult.segs <= 1) { - ret = -EINVAL; - goto out; - } - - /* check to see if we can optimize things a bit - * much quicker to walk the array than transmit over - * the network -- hopefully - */ - flag = 1; - stride = target_offset[1] - target_offset[0]; - segl = target_size[0]; - total_len = 0; - for (j = 0; j < sresult.segs; j += 1) { - int t; - if (j+1 < sresult.segs) { /* really only j-1 segments for j offsets */ - t = target_offset[j+1] - target_offset[j]; - if (stride != t){ - flag = 0; - break; - } - } - if (segl != target_size[j]) { - flag = 0; - break; - } - total_len += segl; - } - - //~ flag=0; /* force SGL mode always so we can compare to VEC later */ - /* move this into a config file or something -- remove eventually*/ - - if (io->io_type == PVFS_IO_WRITE) { - iov = malloc((csegs_count + 1) * sizeof(*iov)); - if (iov == NULL) { - ret = -ENOMEM; - goto out; - } - sm_p->msgarray[i].osd_iov = iov; /* free iov later */ - - len = 0; - - if (flag) { - ddt_size = sizeof(uint64_t) * 2; - } else { - ddt_size = (sizeof(uint64_t) * sresult.segs * 2) + sizeof(uint64_t); - } - - sgl = malloc(ddt_size); - if (sgl == NULL) { - ret = -ENOMEM; - goto out; - } - 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)); - set_htonll((uint8_t *)sgl, stride); - hdr_offset = sizeof(uint64_t); - set_htonll((uint8_t *)sgl + hdr_offset, segl); - hdr_offset += sizeof(uint64_t); - len = total_len; - } else { - gossip_debug(GOSSIP_IO_DEBUG, "%s: Building SGL: Offset/Length pairs" - " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); - 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]); - len += target_size[j]; - hdr_offset += sizeof(uint64_t); - } - } - - iov[0].iov_base = (uintptr_t)sgl; - iov[0].iov_len = ddt_size; - for (j=1; j<=csegs_count; j++) { - iov[j].iov_base = (uintptr_t)(p + offseta[j-1]); - iov[j].iov_len = sizea[j-1]; - } - - p = (void *) iov; - - if (len != sresult.bytes) { - ret = -EINVAL; - goto out; - } - - len += ddt_size; - - osd_command_set_write(command, PVFS_OSD_DATA_PID, datafile_handle, - len, 0); - command->outdata = p; - command->outlen = len; - command->iov_outlen = csegs_count+1; - - if (flag) - osd_command_set_ddt(command, DDT_VEC); - else - osd_command_set_ddt(command, DDT_SGL); - - } else if (io->io_type == PVFS_IO_READ) { - if (csegs_count == 1) { - p += offseta[0]; - len = sizea[0]; - csegs_count = 0; /* do not build a 1-unit iovec */ - } else if (csegs_count > 1) { - iov = malloc(csegs_count * sizeof(*iov)); - if (iov == NULL) { - ret = -ENOMEM; - goto out; - } - len = 0; - sm_p->msgarray[i].osd_iov = iov; /* free sgl later */ - - for (i=0; iindata = p; - command->inlen_alloc = len; - command->iov_inlen = csegs_count; - - len = 0; - - if (flag) { - osd_command_set_ddt(command, DDT_VEC); - ddt_size = sizeof(uint64_t) * 2; - } else { - osd_command_set_ddt(command, DDT_SGL); - ddt_size = (sizeof(uint64_t) * sresult.segs * 2) + sizeof(uint64_t); - } - - sgl = malloc(ddt_size); - if (sgl == NULL) { - ret = -ENOMEM; - goto out; - } - sm_p->msgarray[i].osd_sgl = sgl; /* free sgl later */ - - hdr_offset = 0; - if (flag) { - gossip_debug(GOSSIP_IO_DEBUG, "%s: Building STRIDED from: Offset/Length pairs" - " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); - set_htonll((uint8_t *)sgl, stride); - hdr_offset += sizeof(uint64_t); - set_htonll((uint8_t *)sgl + hdr_offset, segl); - hdr_offset += sizeof(uint64_t); - len = total_len; - } else { - gossip_debug(GOSSIP_IO_DEBUG, "%s: Building SGL: Offset/Length pairs" - " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); - 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]); - len += target_size[j]; - hdr_offset += sizeof(uint64_t); - } - } - if (len != command->inlen_alloc) { - ret = -EINVAL; - goto out; - } - - command->outdata = sgl; - command->outlen = ddt_size; - - } - else { - ret = -EINVAL; - goto out; - } - - } + if (sresult.segs == 1) { /* contiguous server buff to write to */ + if (csegs_count == 1) { + p += offseta[0]; + len = sizea[0]; + csegs_count = 0; /* do not build a 1-unit iovec */ + } else if (csegs_count > 1) { + iov = malloc(csegs_count * sizeof(*iov)); + if (iov == NULL) { + ret = -ENOMEM; + goto out; + } + len = 0; + int j; + for (j=0; jmsgarray[i].osd_iov = p; /* free IOV later */ + } else { + ret = -EINVAL; + goto out; + } + + /* Build the command for this server, using physical offset. */ + if (io->io_type == PVFS_IO_READ) { + osd_command_set_read(command, PVFS_OSD_DATA_PID, datafile_handle, + len, target_offset[0]); + command->indata = p; + command->inlen_alloc = len; + command->iov_inlen = csegs_count; + + } else if (io->io_type == PVFS_IO_WRITE) { + osd_command_set_write(command, PVFS_OSD_DATA_PID, datafile_handle, + len, target_offset[0]); + command->outdata = p; + command->outlen = len; + command->iov_outlen = csegs_count; + } + + } else { /* either need a SGL or optimized SGL */ + int j, flag, stride, segl, total_len; + void *sgl = NULL; + len = 0; + uint64_t ddt_size, hdr_offset; + + if (sresult.segs <= 1) { + ret = -EINVAL; + goto out; + } + + /* check to see if we can optimize things a bit + * much quicker to walk the array than transmit over + * the network -- hopefully + */ + flag = 1; + stride = target_offset[1] - target_offset[0]; + segl = target_size[0]; + total_len = 0; + for (j = 0; j < sresult.segs; j += 1) { + int t; + if (j+1 < sresult.segs) { /* really only j-1 segments for j offsets */ + t = target_offset[j+1] - target_offset[j]; + if (stride != t){ + flag = 0; + break; + } + } + if (segl != target_size[j]) { + flag = 0; + break; + } + total_len += segl; + } + + //~ flag=0; /* force SGL mode always so we can compare to VEC later */ + /* move this into a config file or something -- remove eventually*/ + + if (io->io_type == PVFS_IO_WRITE) { + iov = malloc((csegs_count + 1) * sizeof(*iov)); + if (iov == NULL) { + ret = -ENOMEM; + goto out; + } + sm_p->msgarray[i].osd_iov = iov; /* free iov later */ + + len = 0; + + if (flag) { + ddt_size = sizeof(uint64_t) * 2; + } else { + ddt_size = (sizeof(uint64_t) * sresult.segs * 2) + sizeof(uint64_t); + } + + sgl = malloc(ddt_size); + if (sgl == NULL) { + ret = -ENOMEM; + goto out; + } + 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)); + set_htonll((uint8_t *)sgl, stride); + hdr_offset = sizeof(uint64_t); + set_htonll((uint8_t *)sgl + hdr_offset, segl); + hdr_offset += sizeof(uint64_t); + len = total_len; + } else { + gossip_debug(GOSSIP_IO_DEBUG, "%s: Building SGL: Offset/Length pairs" + " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); + 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]); + len += target_size[j]; + hdr_offset += sizeof(uint64_t); + } + } + + iov[0].iov_base = (uintptr_t)sgl; + iov[0].iov_len = ddt_size; + for (j=1; j<=csegs_count; j++) { + iov[j].iov_base = (uintptr_t)(p + offseta[j-1]); + iov[j].iov_len = sizea[j-1]; + } + + p = (void *) iov; + + if (len != sresult.bytes) { + ret = -EINVAL; + goto out; + } + + len += ddt_size; + + osd_command_set_write(command, PVFS_OSD_DATA_PID, datafile_handle, + len, 0); + command->outdata = p; + command->outlen = len; + command->iov_outlen = csegs_count+1; + + if (flag) + osd_command_set_ddt(command, DDT_VEC); + else + osd_command_set_ddt(command, DDT_SGL); + + } else if (io->io_type == PVFS_IO_READ) { + if (csegs_count == 1) { + p += offseta[0]; + len = sizea[0]; + csegs_count = 0; /* do not build a 1-unit iovec */ + } else if (csegs_count > 1) { + iov = malloc(csegs_count * sizeof(*iov)); + if (iov == NULL) { + ret = -ENOMEM; + goto out; + } + len = 0; + sm_p->msgarray[i].osd_iov = iov; /* free sgl later */ + + for (i=0; iindata = p; + command->inlen_alloc = len; + command->iov_inlen = csegs_count; + + len = 0; + + if (flag) { + osd_command_set_ddt(command, DDT_VEC); + ddt_size = sizeof(uint64_t) * 2; + } else { + osd_command_set_ddt(command, DDT_SGL); + ddt_size = (sizeof(uint64_t) * sresult.segs * 2) + sizeof(uint64_t); + } + + sgl = malloc(ddt_size); + if (sgl == NULL) { + ret = -ENOMEM; + goto out; + } + sm_p->msgarray[i].osd_sgl = sgl; /* free sgl later */ + + hdr_offset = 0; + if (flag) { + gossip_debug(GOSSIP_IO_DEBUG, "%s: Building STRIDED from: Offset/Length pairs" + " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); + set_htonll((uint8_t *)sgl, stride); + hdr_offset += sizeof(uint64_t); + set_htonll((uint8_t *)sgl + hdr_offset, segl); + hdr_offset += sizeof(uint64_t); + len = total_len; + } else { + gossip_debug(GOSSIP_IO_DEBUG, "%s: Building SGL: Offset/Length pairs" + " %d. DDT Size %lld\n", __func__, sresult.segs, lld(ddt_size)); + 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]); + len += target_size[j]; + hdr_offset += sizeof(uint64_t); + } + } + if (len != command->inlen_alloc) { + ret = -EINVAL; + goto out; + } + + command->outdata = sgl; + command->outlen = ddt_size; + + } + else { + ret = -EINVAL; + goto out; + } + + } } - gossip_debug(GOSSIP_IO_DEBUG, "%s: Aggreagte Transferred: %lld\n", __func__, - lld(this_aggregate_size)); + gossip_debug(GOSSIP_IO_DEBUG, "%s: Aggreagte Transferred: %lld\n", __func__, + lld(this_aggregate_size)); out: - js_p->error_code = ret; + js_p->error_code = ret; return 1; } @@ -638,45 +638,45 @@ static int osd_io_completion_fn( * will get status error and fail. */ - 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 (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_sgl != NULL) + free(sm_p->msgarray[index].osd_sgl); - if (sm_p->msgarray[index].osd_iov != NULL) - free(sm_p->msgarray[index].osd_iov); + 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; @@ -692,11 +692,11 @@ static int osd_io_maybe_xfer_more(struct PINT_smcb *smcb, job_status_s *js_p) struct PINT_client_io_sm *io = &sm_p->u.io; int i, more = 1; - gossip_debug(GOSSIP_IO_DEBUG, "%s: total %lld want %lld.\n", __func__, + 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 (io->total_size == io->mem_req->aggregate_size) + more = 0; /* @@ -725,10 +725,10 @@ 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__, + gossip_debug(GOSSIP_IO_DEBUG, "%s: End result is: More %d\n", __func__, more); - js_p->error_code = more ? LOOP_NEXT_CHUNK : 0; + js_p->error_code = more ? LOOP_NEXT_CHUNK : 0; return 1; }