Tuesday, August 25, 2009

Dumping swap partitions

About the only to use a swap partition these days is so there is someplace to store crash dumps. NetBSD will happily swap to files on a filesystem but it won't dump to a file.

Even 30 years, VMS could dump to file. It did so by using a very simple technique, when you specify the dumpfile, the kernel mapped it with a cathedral window. This was a term for a file mapping containing all the extents of the file, basicly a list of starting sector and sector count for each and every file extent used by that file.

There is no reason why NetBSD couldn't do the same thing. When a swapfile is added, simply record all of it extents. Of course, if the swapfile is a sparse file this won't work so rejecting sparse files as swapfiles might be acceptable. This also the problem of needing to find a buffer in low memory situations to read the swapfile extents (since a complete mapping is not stored anywhere). A VFS hook will be needed so prevent the file from deleted or truncated.

To the core dump code, the change is trivial. Instead of a dev_t, it will be a dev_t and a list of extents. Simply fill-up an extent and move the next until all have been exhausted. For the swap partition case, a single extent is supplied starting at 0 and with a length of the partition.

No comments:

Post a Comment