Skip to content

Commit 3529113

Browse files
authored
Merge pull request #10562 from edgargabriel/pr/read-data-sieving-fix
fbtl/posix: fix length calculation for data sieving
2 parents e1b66cf + 6891cee commit 3529113

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ompi/mca/fbtl/posix/fbtl_posix_preadv.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock,
160160
}
161161

162162
size_t sstart = (size_t)fh->f_io_array[startindex].offset;
163-
size_t slen=0;
163+
size_t slen=0, maxlen=0;
164+
int maxindex = startindex;
164165

165166
for ( j = startindex; j < fh->f_num_of_io_entries; j++ ) {
166167
endindex = j;
@@ -169,15 +170,19 @@ ssize_t mca_fbtl_posix_preadv_datasieving (ompio_file_t *fh, struct flock *lock,
169170
endindex = j-1;
170171
break;
171172
}
173+
if (slen > maxlen) {
174+
maxlen = slen;
175+
maxindex = endindex;
176+
}
172177
}
173178
// Need to increment the value of endindex
174179
// by one for the loop syntax to work correctly.
175180
endindex++;
176181

177182
start = (size_t)fh->f_io_array[startindex].offset;
178-
end = (size_t)fh->f_io_array[endindex-1].offset + fh->f_io_array[endindex-1].length;
183+
end = (size_t)fh->f_io_array[maxindex].offset + fh->f_io_array[maxindex].length;
179184
len = end - start;
180-
185+
181186
if ( len > bufsize ) {
182187
if ( NULL != temp_buf ) {
183188
free ( temp_buf);

0 commit comments

Comments
 (0)