Subject: Re: unsynced vnd images
To: Greg Troxel <>
From: Florian Stoehr <>
List: netbsd-users
Date: 02/18/2005 17:17:40
On Fri, 18 Feb 2005, Greg Troxel wrote:

>  I thought the system would track which buffers need syncing and use
>  the in-cache version if accessing a not-yet-written file? This does
>  *NOT* work, at least not in the following case:
>  disk.img -> vnd -> cgd -> /mnt
> I'd guess that when accessing via an abstraction that uses the buffer
> cache things rae ok.  If you look in /mnt, the file is there.  There
> are probably dirty buffers that have not yet been written to the
> cgd-provided virtual disk.  Softupdates, or regular ffs behavior, will
> be in effect in the /mnt fs.

Of course. I meant the file is not there if I copy the vnd image file
and revnd/recgd/remount that copied image. Sorry my mail was a bit not
clear enough here.

> I don't know how cgd behaves about caching.  In order to make
> softupdates work correctly it probably has to ensure that the
> underlying disk operation has completed before claiming that the write
> it does is done.  And same for vnd, which would mean fsync I think.
> You may be able to do a downgrade of the fs to readonly.  I saw some
> messages earlier indicating that this might not ensure the cache is
> flushed, but IMHO it is a bug if the change to RO returns before all
> dirty blocks have hit disk.
> There is still the issue of ensuring the file disk.img is consistent
> when cgd reports writes as done.  I suspect that's ok, even if the
> bits on disk aren't quite there yet, and it seems that since you want
> to copy the file that's what counts for you.

Yes. I don't mind whether it is ready on disk or not. The problem seems
to be that it isn't even ready IN CACHE on the physical disk!

I assume this is because the cache knows that the file inside the cgd
is "dirty buffered" - and thus copying the file from the mounted cgd
will work (copying content from cache). But it misses that the image the
cgd resides in is invalid - this itself will be marked a "dirty buffer"
when the cache for the ***cgd*** is flushed -> the physical I/O for the
cgd is actually the cached I/O for the next unit, the vnd being on a 
(buffered) "real" partition.

Hm. "pseudo-disk" is the problem, residing on a physical disk and thus
beeing kinda double-cached. hm. <-- (I guess)

Guess unmounting the cgd and calling sync() afterwards, then doing a
short wait is all I can do?

> -- 
>        Greg Troxel <>