[squeak-dev] Image damaged due to IO error while saving

David T. Lewis lewis at mail.msen.com
Sat Feb 1 19:48:00 UTC 2020


On Thu, Jan 30, 2020 at 06:20:01AM -0800, Eliot Miranda wrote:
> Hi Dave,
> 
> 
> > On Jan 30, 2020, at 5:18 AM, David T. Lewis <lewis at mail.msen.com> wrote:
> > 
> > ???My suggestion is to just try some ideas in your own image and see
> > if it's something you want to live with. The intentions are good but
> > I have a feeling that this is the kind of thing where the inintended
> > side effects are worse than the problem to be solved.
> 
> +1
> 
> > 
> > In my own experience, I have encountered an IO error while saving
> > the image several times over the years. In every case, the cause has
> > been a file system full condition. A solution that uses more disc
> > space would not have been helpful.
> 
> Good point.  The snapshot primitive *could* make a conservative estimate
> of the file size needed (easy; it knows how big the heap is), create
> a file, write that many zeros (only way to actually commit the disc
> space), and then overwrite with the real data, but that???s twice
> the disc traffic.
> 

That's a good idea, and on a unix platform we can use statvfs()
to check space availability without adding any disc traffic.
To prove out the idea, I implemented it as a primitive in the
unix OSProcess plugin so that you can test it like this:

primSpaceFor: byteSize InDirectoryPath: dirPath
	<primitive: 'primitiveSpaceForByteSizeInDirectoryPath' module: 'UnixOSProcessPlugin'>
	^ self primitiveFailed

If you want to give it a try, the primitive is now in the latest
UnixOSProcessPlugin in www.squeaksource.com/OSProcessPlugin in
VMConstruction-Plugins-OSProcessPlugin-dtl.47, and I merged it
into VMConstruction-Plugins-OSProcessPlugin.oscog-dtl.67 for the
Cog/Spur VMs.

I also added access from OSProcess is added in OSProcess-dtl.114.

I have not really looked into how best to put this into the VM
proper, but we could consider either adding a primitive similar
to the one in OSPP, or maybe add a check directly into the image
write function (which is currently a macro that we could override).

I also have not looked into how to implement this on Windows. I'm
sure there is a way but I have not yet checked. It's likely that
statvsf() is available on Windows but I have not looked.

In any case, treat this is a proof of concept to illustrate a
way to handle the file system full scenario.

Dave



More information about the Squeak-dev mailing list