[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [linux-lvm] snapshot reset

Bastian Blank wrote:
With LVM2, between those commands, you can just zero out the
start of the cow device (say first 64k).  And then it'll treat
it as if it were a new snapshot (based on current state of filesystem.)

Something like this?
| name=${vg}-${lv}
| dmsetup suspend $name
| dd if=/dev/zero of=/dev/mapper/${name}-cow bs=64k count=1
| dmsetup resume $name

I tried something very much like this a couple of weeks ago (with Linux 2.6.10) and found that it's not reliable. Digging further, I learned that the snapshot device doesn't actually read the cow device when it resumes. (BTW, you only need to blank the first 4 bytes, which contain the magic number.) However, if you use "vgchange -a n; vgchange -a y" after this script, it should work.

My goal was to use snapshot devices to implement filesystem-level transactions. I wanted to write a set of changes to the filesystem only if all of the changes could be committed. I decided that vgchange was too invasive for my purposes, so I wrote a patch for device-mapper that lets you reliably and quickly clear a snapshot device using this command:

dmsetup message ${vg}-${lv} 0 resync

Then I wrote a script that commits the changes from a snapshot device back to the original volume, then clears the snapshot device so it can be reused for more transactions. I was happy with how it turned out; you don't even have to unmount the filesystem to commit a transaction. (Aborting a transaction does require a remount.)

Once I finished, I changed my mind and decided I wanted to gain transactional integrity in a different way. However, if anyone's interested in my work, email me and I'll send you everything.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]