Skip to content

Commit

Permalink
add util_fsync to address zfs issue #768
Browse files Browse the repository at this point in the history
  • Loading branch information
edoapra committed May 11, 2023
1 parent 45137a9 commit 3b53eb2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/util/util_file_name.F
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ double precision function util_scratch_dir_avail_for_me()
ierr=eaf_delete(mine)
ierr=eaf_open(mine, eaf_rw, fd)
ierr = eaf_stat(mine, avail0, fstype)
call util_fsync(mine)
ierr = eaf_stat(mine, avail0, fstype)
if(avail0.gt.fiftytb) toolarge=1
else
ierr=0
Expand Down Expand Up @@ -882,6 +884,7 @@ double precision function util_scratch_dir_avail_for_me()
nuse_fail=0
if(io_node) then
ierr = eaf_stat(mine, avail1, fstype)
call util_fsync(mine)
if (ierr .ne. 0) call errquit(
U 'util_scratch_avail: eaf_stat',ierr,DISK_ERR)
ierr=eaf_delete(mine)
Expand Down Expand Up @@ -1161,3 +1164,27 @@ subroutine cphf_fname_parallel(cphf_str1,cphf_str2)
A cphf_str2(1:inp_strlen(cphf_str2))
return
end
subroutine util_fsync(fname)
implicit none
character*(*),intent(in) :: fname
c
integer iunit
integer*4 fd_in
c
interface
function fsync (fd) bind(c,name="fsync")
use iso_c_binding, only: c_int
integer(c_int), value :: fd
integer(c_int) :: fsync
end function fsync
end interface
iunit=10
open (iunit,file=fname)
c flush(iunit)
fd_in=fnum(iunit)
c Flush and sync
if(fsync(fd_in).ne.0) call
c errquit("Error calling FSYNC",0,0)

return
end

0 comments on commit 3b53eb2

Please sign in to comment.