Skip to content

Commit

Permalink
io/ompio: file file_seek calculation
Browse files Browse the repository at this point in the history
fix the file_seek calculations when using SEEK_END.
Thanks @tukss for reporting the issue.

Fixes #12952

Signed-off-by: Edgar Gabriel <[email protected]>
  • Loading branch information
edgargabriel committed Dec 30, 2024
1 parent 88cd4a5 commit d82d905
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ompi/mca/io/ompio/io_ompio_file_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,21 @@ static void mca_io_ompio_file_get_eof_offset (ompio_file_t *fh,
in_offset -= fh->f_fview.f_disp;
if ( fh->f_fview.f_view_size > 0 ) {
/* starting offset of the current copy of the filew view */
start_offset = in_offset / fh->f_fview.f_view_extent;
start_offset = (in_offset / fh->f_fview.f_view_extent) * fh->f_fview.f_view_extent;

index_in_file_view = 0;
/* determine block id that the offset is located in and
the starting offset of that block */
while ( offset <= in_offset && index_in_file_view < fh->f_fview.f_iov_count) {
prev_offset = offset;
while (offset <= in_offset && index_in_file_view < fh->f_fview.f_iov_count) {
offset = start_offset + (OMPI_MPI_OFFSET_TYPE)(intptr_t) fh->f_fview.f_decoded_iov[index_in_file_view++].iov_base;
if (offset <= in_offset) {
prev_offset = offset;
}
}

offset = prev_offset;
blocklen = fh->f_fview.f_decoded_iov[index_in_file_view-1].iov_len;
while ( offset <= in_offset && k <= blocklen ) {
while (offset <= in_offset && k <= blocklen) {
prev_offset = offset;
offset += fh->f_fview.f_etype_size;
k += fh->f_fview.f_etype_size;
Expand Down

0 comments on commit d82d905

Please sign in to comment.