RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1385443 - [RFE] lvreduce warning for reducing XFS formatted LV device
Summary: [RFE] lvreduce warning for reducing XFS formatted LV device
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: lvm2
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: LVM and device-mapper development team
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-17 04:03 UTC by Jayaram
Modified: 2021-09-03 12:37 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-26 13:34:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Jayaram 2016-10-17 04:03:38 UTC
Description of problem: Is that possible to include a warning message, if a user attempted to reduce XFS formatted LV device. As we know there are no utility for reducing an XFS filesystem. The main intention for filing this request is to printing a warning message for XFS LV's if a user is not aware about that shrinking is not possible for XFS.



RHEL7
3.10.0-327.22.2.el7.x86_64
lvm2-2.02.130-5.el7_2.4.x86_64
xfsprogs-3.2.2-2.el7.x86_64

If this is possible, can we expect the same in the next lvm2 release?


How reproducible:



Steps to Reproduce:


>> Whenver we trying to reduce a XFS formatted LV device, we getting below error.

Actual results:

>> lvreduce -L 20M /dev/mapper/test-test
  WARNING: Reducing active logical volume to 20.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.) ==<<<<<<<<<<
Do you really want to reduce test-test? [y/n]: y
  Size of logical volume test-test changed from 52.00 MiB (13 extents) to 20.00 MiB (5 extents).
  Logical volume test-test successfully resized.

Expected results:

>> lvreduce -L 20M /dev/mapper/test-test 
	WARNING: Reducing active logical volume to 20.00 MiB 
	THIS MAY DESTROY YOUR DATA as Filesystem as XFS(filesystem etc.) ==<<<< 
Do you really want to reduce test-test? [y/n]: y 
	Size of logical volume test-test changed from 52.00 MiB (13 extents) to 20.00 MiB (5 extents). 
	Logical volume test-test successfully resized. 

Additional info:

Comment 2 Marian Csontos 2016-10-17 07:36:36 UTC
Re: Additional warning:

We always face the requirements to add more warnings and remove them at the same time. In this case there already is a WARNING and lvreduce asked for confirmation.

Mentioning filesystem does not add any information in this case: if FS was not resized, lvreduce-ing the volume would damage ext4, or any other FS.

Recommendation:

Users should always use lvresize, lvextend and lvreduce with *-r|--resizefs* which ensures FS can be reduced, and does resize volume and filesystem in correct order (with the exception of cryptsetup/LUKS devices, which are not handled at the moment.)

Re: Repair:

To get the data back, the LV must be extended first - if there were no other LVs created on the disk, it may be possible to recover data - look at *vgcfgrestore* and restore from appropriate file in /etc/lvm/archive/. Even if there were LVs created it might work, if there were no data written to the new LVs (including metadata in case of thin-pool, mirror and RAID volumes, and in case of RAID volume leg synchronization.)

However, running resize2fs and xfsgrow was likely to further damage the FS. When repairing volume it is absolutely necessary to revert the steps one by one in reverse order (there may be exceptions), not going further - running fsck, or whatever else.

Comment 3 Jayaram 2016-10-21 07:24:20 UTC
Hello Marian,

Thanks for the update.

I shared the details to customer, but still he expecting filesystem warning in the lvreduce command prompt. 

I explained him about the use case with -r option but he is not happy with this. 

If this feature adding possible, may I know what will be the estimated time.

Thanks
Jayaram

Comment 4 Zdenek Kabelac 2016-10-21 08:38:24 UTC
(In reply to Jayaram from comment #3)
> Hello Marian,
> 
> Thanks for the update.
> 
> I shared the details to customer, but still he expecting filesystem warning
> in the lvreduce command prompt. 
> 
> I explained him about the use case with -r option but he is not happy with
> this. 
> 
> If this feature adding possible, may I know what will be the estimated time.


lvm2 is universal volume manager - it's not oriented for XFS-only usage.
Thus lvm2 cannot know if the device content is the one user wants to still use,
or the one already 'disposed' and meant to be recycled for something else.

As primary warning - we show with BIG CAPITAL letters major warning the
size reduction may lead to significant data loss and it does not matter if there is extra string XFS, Ext4, or  i.e. some raw database content.

Running extra signature identification to tell which exact type of filesystem is actually there IMHO does not bring any more safety. AFAIK when the user always answers 'yes' anyway  it will not be any better if there will be 'XFS' word in the text.

It's the extra '-r'  option we provide to make filesystem (for couple types) 'aware'  resize operation - that's the primary purpose of '-r'.

So this request then looks like the customer here would like to have the option '-r' to be a default (always applied) logic?


BTW when a user realizes after the resize he made a wrong move - he can always go one step back with vgcfgrestore restoring previous metadata  (here it's mandatory  lvm.conf option  issue_discards is set to 0!  (please note that many wrong advices on the internet are suggesting here to use the value 1)
If such operation is made instantly after lvreduce - there is a big chance of minimal damage.

Comment 6 Jayaram 2016-10-26 09:21:49 UTC
Hello Marian,

Please close this request. I explained customer about the scenerio and he happy with the "-r" option so we are good to close this BZ.

Thanks
Jayaram

Comment 7 Zdenek Kabelac 2016-10-26 13:34:57 UTC
Closing as suggested by reporter.


Note You need to log in before you can comment on or make changes to this bug.