Skip to content

fbtl/posix: fix data-sieving calculations #11932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions ompi/mca/fbtl/posix/fbtl_posix_preadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ static ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock
static ssize_t mca_fbtl_posix_preadv_generic (ompio_file_t *fh, struct flock *lock, int *lock_counter);
static ssize_t mca_fbtl_posix_preadv_single (ompio_file_t *fh, struct flock *lock, int *lock_counter);

#define MAX_RETRIES 10

ssize_t mca_fbtl_posix_preadv (ompio_file_t *fh )
{
Expand Down Expand Up @@ -108,7 +107,6 @@ ssize_t mca_fbtl_posix_preadv_single (ompio_file_t *fh, struct flock *lock, int
return OMPI_ERROR;
}

int retries = 0;
size_t len = fh->f_io_array[0].length;
while ( total_bytes < len ) {
ret_code = pread(fh->fd, (char*)fh->f_io_array[0].memory_address+total_bytes,
Expand All @@ -121,13 +119,7 @@ ssize_t mca_fbtl_posix_preadv_single (ompio_file_t *fh, struct flock *lock, int
}
if ( ret_code == 0 ) {
// end of file
retries++;
if ( retries == MAX_RETRIES ) {
break;
}
else {
continue;
}
break;
}
total_bytes += ret_code;
}
Expand Down Expand Up @@ -206,7 +198,6 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock,
return OMPI_ERROR;
}
size_t total_bytes = 0;
int retries = 0;

while ( total_bytes < len ) {
ret_code = pread (fh->fd, temp_buf+total_bytes, len-total_bytes, start+total_bytes);
Expand All @@ -218,13 +209,7 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock,
}
if ( ret_code == 0 ) {
// end of file
retries++;
if ( retries == MAX_RETRIES ) {
break;
}
else {
continue;
}
break;
}
total_bytes += ret_code;
}
Expand All @@ -236,12 +221,12 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock,
size_t start_offset = (size_t) fh->f_io_array[startindex].offset;
for ( i = startindex ; i < endindex ; i++) {
pos = (size_t) fh->f_io_array[i].offset - start_offset;
if ( (ssize_t) pos > ret_code ) {
if ( (ssize_t) pos > total_bytes ) {
break;
}
num_bytes = fh->f_io_array[i].length;
if ( ((ssize_t) pos + (ssize_t)num_bytes) > ret_code ) {
num_bytes = ret_code - (ssize_t)pos;
if ( ((ssize_t) pos + (ssize_t)num_bytes) > total_bytes ) {
num_bytes = total_bytes - (ssize_t)pos;
}

memcpy (fh->f_io_array[i].memory_address, temp_buf + pos, num_bytes);
Expand Down
11 changes: 1 addition & 10 deletions ompi/mca/fbtl/posix/fbtl_posix_pwritev.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ static ssize_t mca_fbtl_posix_pwritev_datasieving (ompio_file_t *fh, struct floc
static ssize_t mca_fbtl_posix_pwritev_generic (ompio_file_t *fh, struct flock *lock, int *lock_counter );
static ssize_t mca_fbtl_posix_pwritev_single (ompio_file_t *fh, struct flock *lock, int *lock_counter );

#define MAX_RETRIES 10

ssize_t mca_fbtl_posix_pwritev(ompio_file_t *fh )
{
ssize_t bytes_written=0;
Expand Down Expand Up @@ -192,7 +190,6 @@ ssize_t mca_fbtl_posix_pwritev_datasieving (ompio_file_t *fh, struct flock *lock
return OMPI_ERROR;
}

int retries=0;
while ( total_bytes < len ) {
ret_code = pread (fh->fd, temp_buf, len, start);
if ( ret_code == -1 ) {
Expand All @@ -203,13 +200,7 @@ ssize_t mca_fbtl_posix_pwritev_datasieving (ompio_file_t *fh, struct flock *lock
}
if ( ret_code == 0 ) {
// end of file
retries++;
if ( retries == MAX_RETRIES ) {
break;
}
else {
continue;
}
break;
}
total_bytes += ret_code;
}
Expand Down