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 1035871 - lvm2 calculates snapshot space incorrectly
Summary: lvm2 calculates snapshot space incorrectly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2
Version: 6.5
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: ---
Assignee: Zdenek Kabelac
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks: 1066977
TreeView+ depends on / blocked
 
Reported: 2013-11-28 17:11 UTC by Mikuláš Patočka
Modified: 2014-10-14 08:24 UTC (History)
13 users (show)

Fixed In Version: lvm2-2.02.107-1.el6
Doc Type: Bug Fix
Doc Text:
Cause: Incorrect assumption in formula for estimation of maximum size for snapshot's COW device size. Consequence: Estimated maximum size of snapshot volume could have been too small to hold all changed blocks from origin volume. Such snapshot is than automatically marked as invalidated and it is lost. Fix: Formula for size estimation has been fixed. Result: Maximum size of snapshot has correct size.
Clone Of:
: 1066977 (view as bug list)
Environment:
Last Closed: 2014-10-14 08:24:55 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1387 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2014-10-14 01:39:47 UTC

Description Mikuláš Patočka 2013-11-28 17:11:49 UTC
Description of problem:

In RHEL6, the lvm2 tool was modified so that it calculates maximum space that
a snapshot could use and restricts the user-supplied snapshot size so that it is
never larger than the maximum useable space. However, this calculation is
incorrect. Under certain circumstances lvm2 may allocate snapshot that is too
small. When this snapshot is filled up, it overflows and all data in the snapshot
is lost.

Version-Release number of selected component (if applicable):
2.02.100(2)-RHEL6 (2013-10-23)

How reproducible:
Always

Steps to Reproduce:
Use this script. Set the variable VG to some real volume group. The volume
group must have extent size 4MiB or less (by default, extent size is 4MiB) and it
must have at least 4GiB free space.

#!/bin/sh
VG=vg1
lvremove -f $VG/origin
set -e
lvcreate -L 2143289344b -n origin $VG
lvcreate -n snap -c 8k -L 2304M -s $VG/origin
dd if=/dev/zero of=/dev/$VG/snap bs=1M oflag=direct

Actual results:
The snapshot overflows and all data in it is lost.

Expected results:
The snapshot should not overflow. The user specified sufficient size (2304MiB),
but lvm2 trimmed the size to a smaller value.

Additional info:
See the bug report at
http://www.redhat.com/archives/dm-devel/2013-November/msg00153.html

Comment 2 Zdenek Kabelac 2014-02-26 13:58:42 UTC
Upstreamed updated version of Mikulas' patch:

http://www.redhat.com/archives/lvm-devel/2014-February/msg00161.html

Comment 3 Zdenek Kabelac 2014-03-06 16:38:06 UTC
Upstream test case:

https://www.redhat.com/archives/lvm-devel/2014-March/msg00045.html

Comment 6 Nenad Peric 2014-06-30 11:50:53 UTC
Ran 5 iteration of aforementioned test without issues:

============================================================
Iteration 5 of 5 started at Mon Jun 30 13:43:47 CEST 2014
============================================================
SCENARIO - [calc_maximum_usable_space]
Making origin volume
lvcreate -n origin -L 2143289344b snapper
Creating snap requiring LVM to recaluculate its total space
lvcreate -n calc_snap -c 8k -L 2304M -s /dev/snapper/origin

Attempting to fill snap
dd if=/dev/zero of=/dev/snapper/calc_snap bs=1M oflag=direct
dd: writing `/dev/snapper/calc_snap': No space left on device
2045+0 records in
2044+0 records out
2143289344 bytes (2.1 GB) copied, 33.7317 s, 63.5 MB/s

Read from snap
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 1.22551 s, 85.6 MB/s

current snap attr: swi-a-s---
Removing volume snapper/calc_snap
Removing origin snapper/origin


Deleting VG snapper
Deleting PVs /dev/sdb1 /dev/sdc1



Marking VERIFIED with:

lvm2-2.02.107-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
lvm2-libs-2.02.107-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
lvm2-cluster-2.02.107-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
udev-147-2.55.el6    BUILT: Wed Jun 18 13:30:21 CEST 2014
device-mapper-1.02.86-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
device-mapper-libs-1.02.86-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
device-mapper-event-1.02.86-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
device-mapper-event-libs-1.02.86-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014
device-mapper-persistent-data-0.3.2-1.el6    BUILT: Fri Apr  4 15:43:06 CEST 2014
cmirror-2.02.107-1.el6    BUILT: Mon Jun 23 16:44:45 CEST 2014

Comment 8 errata-xmlrpc 2014-10-14 08:24:55 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1387.html


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