Skip to content

Commit 020f828

Browse files
authored
Merge pull request #13026 from edgargabriel/pr/seek-end-fix-v5.0.x
io/ompio: file file_seek calculation - v5.0.x
2 parents 93b0ef4 + 3bb18ec commit 020f828

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
@@ -414,19 +414,21 @@ static void mca_io_ompio_file_get_eof_offset (ompio_file_t *fh,
414414
in_offset -= fh->f_disp;
415415
if ( fh->f_view_size > 0 ) {
416416
/* starting offset of the current copy of the filew view */
417-
start_offset = in_offset / fh->f_view_extent;
417+
start_offset = (in_offset / fh->f_view_extent) * fh->f_view_extent;
418418

419419
index_in_file_view = 0;
420420
/* determine block id that the offset is located in and
421421
the starting offset of that block */
422-
while ( offset <= in_offset && index_in_file_view < fh->f_iov_count) {
423-
prev_offset = offset;
422+
while (offset <= in_offset && index_in_file_view < fh->f_iov_count) {
424423
offset = start_offset + (OMPI_MPI_OFFSET_TYPE)(intptr_t) fh->f_decoded_iov[index_in_file_view++].iov_base;
424+
if (offset <= in_offset) {
425+
prev_offset = offset;
426+
}
425427
}
426428

427429
offset = prev_offset;
428430
blocklen = fh->f_decoded_iov[index_in_file_view-1].iov_len;
429-
while ( offset <= in_offset && k <= blocklen ) {
431+
while (offset <= in_offset && k <= blocklen) {
430432
prev_offset = offset;
431433
offset += fh->f_etype_size;
432434
k += fh->f_etype_size;

0 commit comments

Comments
 (0)