Skip to content

Commit 1176ac1

Browse files
authored
Merge pull request #13025 from edgargabriel/pr/seek-end-fix-v4.1.x
io/ompio: file file_seek calculation - v4.1.x
2 parents 31f6f4d + 5afde40 commit 1176ac1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,19 +402,21 @@ static void mca_io_ompio_file_get_eof_offset (ompio_file_t *fh,
402402
in_offset -= fh->f_disp;
403403
if ( fh->f_view_size > 0 ) {
404404
/* starting offset of the current copy of the filew view */
405-
start_offset = in_offset / fh->f_view_extent;
405+
start_offset = (in_offset / fh->f_view_extent) * fh->f_view_extent;
406406

407407
index_in_file_view = 0;
408408
/* determine block id that the offset is located in and
409409
the starting offset of that block */
410-
while ( offset <= in_offset && index_in_file_view < fh->f_iov_count) {
411-
prev_offset = offset;
410+
while (offset <= in_offset && index_in_file_view < fh->f_iov_count) {
412411
offset = start_offset + (OMPI_MPI_OFFSET_TYPE)(intptr_t) fh->f_decoded_iov[index_in_file_view++].iov_base;
412+
if (offset <= in_offset) {
413+
prev_offset = offset;
414+
}
413415
}
414416

415417
offset = prev_offset;
416418
blocklen = fh->f_decoded_iov[index_in_file_view-1].iov_len;
417-
while ( offset <= in_offset && k <= blocklen ) {
419+
while (offset <= in_offset && k <= blocklen) {
418420
prev_offset = offset;
419421
offset += fh->f_etype_size;
420422
k += fh->f_etype_size;

0 commit comments

Comments
 (0)