Mar 292013

The Linux device mapper provides a “snapshot” capability which makes it possible to cheaply get a copy of a block device by using copy-on-write to only store the modified sections of the device.  Systems like LVM and EVMS use this to provide a temporary copy of a filesystem for back-up while other software continues to modify the original.  However it has some other interesting uses.

I’ve been using the software RAID feature of the Linux kernel for more than a decade on many machines.  A couple times I have found myself in the unfortunate situation of having a failed software RAID from which I would like to retrieve data.  (Of course one should rely on backups as much as possible, but sometimes it’s still beneficial to get at the very last contents of the disk on a server.)  While doing this, you want to avoid any accidental modification of the original disks (or copies of their contents if you’re working from disk image files).  One way to do this is with the device mapper’s snapshot capability.  Using it this way is not well documented, so I thought I’d write up how I did this.

Continue reading »

Aug 232012

Some modern languages claim to have better concurrency support than languages like Java or C/C++ (Go, Erlang, etc.).  Their features are often touted as making it easier to “get concurrency right,” as though it’s somehow difficult to have similar capabilities in other languages.  Sometimes this sounds to me like the closures vs. objects debate.

To demonstrate what I mean, here’s one way to implement a Go-style message channel for inter-thread communication in C++ (using C++11’s thread support):

Continue reading »