On Thu, Aug 15, 2013 at 8:59 PM, Richard W.M. Jones <rjo...@redhat.com> wrote: > On Thu, Aug 15, 2013 at 08:41:53PM +0200, richard -rw- weinberger wrote: >> Meant regarding fsync()... > > Ah right, see what you mean :-) > > It calls sync(2). Then it opens each /dev/ubdX device and calls fsync > on the file descriptor: > > https://github.com/libguestfs/libguestfs/blob/master/daemon/sync.c#L54 > > The reason for this is a bit complicated, but has to do with write > barriers. I believe this has been fixed since then. > > https://github.com/libguestfs/libguestfs/commit/c0a3c9ce70b98171e737e49e6dccc4457963f2ec > > In any case, we're calling sync & fsync in the guest, and that ain't > causing the host cache to be flushed.
Hmm, AFAIK a fsync() after sync() is pointless. > It's pretty easy to show this with libguestfs: > > LIBGUESTFS_BACKEND=uml LIBGUESTFS_HV=~/d/linux-um/linux \ > time ./run ./fish/guestfish -N fs:ext2:1G -m /dev/sda1 fallocate64 /data 800M > time sync > > The first command finishes in 8 seconds, with barely any disk > activity. The sync afterwards takes 9 seconds with the disk light on > the whole time, while it actually writes the whole 800 MB of data. I think you don't see the desired effect because UML does not open the backing file with O_SYNC. But you can tell UML to do so. e.g. write ubdas=/foo instead of ubda=/foo. See: ubd<n><flags>=<filename>[(:|,)<filename2>] This is used to associate a device with a file in the underlying filesystem. When specifying two filenames, the first one is the COW name and the second is the backing file name. As separator you can use either a ':' or a ',': the first one allows writing things like; ubd0=~/Uml/root_cow:~/Uml/root_backing_file while with a ',' the shell would not expand the 2nd '~'. When using only one filename, UML will detect whether to treat it like a COW file or a backing file. To override this detection, add the 'd' flag: ubd0d=BackingFile Usually, there is a filesystem in the file, but that's not required. Swap devices containing swap files can be specified like this. Also, a file which doesn't contain a filesystem can have its contents read in the virtual machine by running 'dd' on the device. <n> must be in the range 0 to 7. Appending an 'r' to the number will cause that device to be mounted read-only. For example ubd1r=./ext_fs. Appending an 's' will cause data to be written to disk on the host immediately. 'c' will cause the device to be treated as being shared between multiple UMLs and file locking will be turned off - this is appropriate for a cluster filesystem and inappropriate at almost all other times. Please let me know if that helps. :-) -- Thanks, //richard ------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel