Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 236168

Summary: pvcreate should automatically make a backup of what it overwrites
Product: Red Hat Enterprise Linux 5 Reporter: Milan Broz <mbroz>
Component: lvm2Assignee: Petr Rockai <prockai>
Status: CLOSED DUPLICATE QA Contact: Corey Marthaler <cmarthal>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.0CC: agk, dwysocha, james.brown, jbrassow, mbroz, prockai, pvrabec, syeghiay
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-06-18 14:16:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Milan Broz 2007-04-12 08:26:12 UTC
RHEL 5.1 clone - some code exists (see bug 174701),
nice to have this in RHEL5 too.

+++ This bug was initially created as a clone of Bug #174701 +++

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]

...

-- Additional comment from prockai on 2007-04-11 12:43 EST --
Created an attachment (id=152288)
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.

Comment 2 RHEL Program Management 2007-10-16 04:02:27 UTC
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.

Comment 7 RHEL Program Management 2008-06-02 20:38:03 UTC
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.

Comment 8 Petr Rockai 2008-07-02 10:03:02 UTC
From #174701:

> 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.

That means it might be done in 5.3 timeframe, or might not (although I'd hope 
for the former). Hotspare capabilities get priority over this.

Comment 9 RHEL Program Management 2008-10-27 18:21:46 UTC
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.