Data corruption with freebsd VM resets

Arif Khan mohdarif.khan at gmail.com
Wed Mar 10 20:25:20 UTC 2021


Hi All,

  I am facing a strange issue with freebsd 11.4. The sync() or O_SYNC flag
not working if we reset the box (un graceful shutdown) within 45 seconds.
The data written to file is lost.
However the same thing works in 8.4 atleast initial few lines are written.

main(*int* argc, *char* **argv)

{

*int* sz;

*int* i;

*int* count =  atoi(argv[*1*]);

*int* fd_sync = open(*"foo_sync"*, O_CREAT|O_RDWR | O_APPEND| O_SYNC, *0*
*644*);

*int* fd_nosync = open(*"foo_nosync"*, O_CREAT|O_RDWR | O_APPEND, *0**644*);

*if* (fd_sync < *0* || fd_nosync < *0*)

   {

      perror(*"r1"*);

      exit(*1*);

   }

*for* (i=*0*; i < count;i++) {

   sz = write(fd_sync, *"hello geeks**\n**"*, strlen(*"hello geeks**\n**"*
));

   sz = write(fd_nosync, *"hello geeks**\n**"*, strlen(*"hello geeks**\n**"*
));

  }

  close(fd_sync);

  close(fd_nosync);
}

This work effectively if we have kern.cam.ada.write_cache: 0
Is there a way I can get some few lines written when running sync().

-- 
thanks & regards
Arif


More information about the freebsd-fs mailing list