2 Replies Latest reply on Oct 11, 2011 9:19 AM by quasimir

    behaviour of fsync() call on local vmdk-based VM

    quasimir Lurker



      What does happen when an fsync() call is made in a guest OS backed by a local vmdk disk on a VMFS partition?

      Does ESX ensure that the file is really synced to the physical disk?

      If yes, how does it do it? (The hypervisor has no knowledge of the files in the guest).

      If not, how can the guest OS really be sure that the data has been physically written to disk?


      What about local RDM disks?



        • 1. Re: behaviour of fsync() call on local vmdk-based VM
          weinstein5 Guru User Moderators vExpert

          Welcome to the Community -  The fsync command will be handled by the guest OS - the ESXi server virtualize the resources used by the VM including disk so when the VM issues a write the ESXi takes that write and performs it within the VMDK or RDM - the guest insures the wirte is done the same way it is done in the pphysical world -

          • 2. Re: behaviour of fsync() call on local vmdk-based VM
            quasimir Lurker

            Hi, thanks for your reply. Does that mean that ESX just does its own write caching/syncing to the vmdk file irrespective of the guest syncing requests and that there is no way to control this from the guest?


            More details about my question:


            We have a mail server running on a VM (linux ext2 partition, backed by a local vmdk image) which returns "OK" to the client only after having called fsync() on the received email file to make sure that the message is physically written to disk before sending a confirmation to the client. So if the client gets an "OK", it knows that the file has definitely been received. In case of a crash between fsync() and the "OK" response, the client might re-send the message but that's an acceptable scenario.


            What we have observed is that if we send a lot of emails to the server and "pull the plug" on the ESX host, we actually lose some messages that were confirmed as "OK" by the server. This means that fsync() didn't actually sync the files to the physical disk.


            We did the same test with the smtp server running on physical tin and we saw the normal behaviour (number of messages saved = number of "OK" sent to client)


            So how can we ensure that ESX actually syncs the data to disk?