LVM2 pvcreate should make an automatic backup of the part of the device that it overwrites, so you can undo it. (Could add as a generic option in the low-level write function, so other commands could use it too.) [split off from bugzilla 168330]
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
Created attachment 152288 [details] lvm2-pvcreate-undo-prelim Here comes a preliminary patch implementing basic pvcreate --undo functionality. It has a few rough edges yet, like there is no configuration option to disable pvcreate archive creation (easy to fix) and that offset/length pairs are written out in host byte order (needs ntohll/htonll which seem to be missing from libc? needs investigation). The design is simplistic, it provides new device write primitives suffixed _backup that take an extra file descriptor argument, which they use to write out a copy of whatever they are going to overwrite, prepended with offset and length of the block. The restore function takes a file that contains several such blocks and writes them over in their original positions, in reverse order from the file. This allows for easy backup implementation, where a backup file is created and opened for writing, its fd is passed to every device write operation and file is closed. Then, restore takes the opened device and a filename of backup file. Things like further metadata about the operation are left for higher layers, in this case pvcreate. Current implementation just uses <archive_dir>/<uuid>.pv as backup file and --undo on a PV looks for this file which when found is used for restore. There is room for a more elaborate operation logfile, which may reference the (simplistic) binary backup files. Any checksumming should be probably done on that (operation logfile) level as well. To make it possible for format_text to use the backup-enabled device operations, i have added device_backup_fd to toolcontext. This may need different addressing as well, although there is not much room for maneuvering -- probably either way, all dev_write/dev_set calls that need backup functionality will have to be modified in a way or other (either replace them with versions that take toolcontext parameter, or the _backup versions). I will followup with improved patches either tonight or tomorrow.
Created attachment 152529 [details] lvm2-pvcreate-undo-iter2.diff Second iteration of the patch, fixes byte ordering and configuration file issues, plus minor style cleanups.
This request was previously evaluated by Red Hat Product Management for inclusion in the current Red Hat Enterprise Linux release, but Red Hat was unable to resolve it in time. This request will be reviewed for a future Red Hat Enterprise Linux release.
We have decided with Alasdair to rework this patch differently, for improved maintainability and future-proofness. The feature is not critical in any way and can be deferred for next update. I will followup with updates when the work on this is resumed.
(In reply to comment #14) > The feature is not critical in any way > and can be deferred for next update. We have decided that the risk associated with this feature is not worth the benefit at this point in the life of RHEL 4. Instead, we will defer the feature to RHEL 5.
*** Bug 236168 has been marked as a duplicate of this bug. ***
I'll get to this, now that vg_read and other infrastructure work is mostly settled. I have a good idea what needs to be done so it should be a simple matter of coding. Actually, there might be some user interface issues to sort out, since the move to implicit pvcreate (but this feature also becomes more relevant due to that change).
I'm lowering the priority on this, as this has been in progress for a *long* time. The patch exists, it is mostly merge-ready but it has not been a priority so far. Presumably this will get merged sooner or later.
The latest iteration of this patch is available from https://www.redhat.com/archives/lvm-devel/2010-October/msg00008.html
Superseded by http://www.redhat.com/archives/lvm-devel/2010-November/msg00054.html
This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unfortunately unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate and relevant, in the next release of Red Hat Enterprise Linux.
This request was erroneously denied for the current release of Red Hat Enterprise Linux. The error has been fixed and this request has been re-proposed for the current release.
Patches awaiting my review.
According to current plan, we hope to clear this before May, meaning it should comfortably hit 5.8.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux release for currently deployed products. This request is not yet committed for inclusion in a release.
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.