Bug 1021051 - lvchange -p should change in-kernel permission if it differs from metadata setting
lvchange -p should change in-kernel permission if it differs from metadata se...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2 (Show other bugs)
6.4
Unspecified Unspecified
high Severity high
: pre-dev-freeze
: 6.7
Assigned To: Alasdair Kergon
cluster-qe@redhat.com
Steven J. Levine
: FutureFeature
Depends On:
Blocks: 1173188 905665 1002699
  Show dependency treegraph
 
Reported: 2013-10-18 17:27 EDT by Alasdair Kergon
Modified: 2015-07-22 03:37 EDT (History)
15 users (show)

See Also:
Fixed In Version: lvm2-2.02.117-1.el6
Doc Type: Enhancement
Doc Text:
lvchange -p now corrects in-kernel permissions on a logical volume If a logical volume is read-only and active but its metadata states that it should be writeable (a situation that can arise if the configuration setting activation/read_only_volume_list is changed), you can now use the "lvchange --permission rw" command to bring the active copy in line with the metadata and make it writeable. Executing an "lvchange --refresh" command can do this as well, but this new feature might be more convenient in some circumstances. The opposite is also true: The "lvchange --permission r" command will now refresh an active logical volume that should be read-only. For information on the lvchange command, see the lvchange(8) man page.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-07-22 03:37:02 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alasdair Kergon 2013-10-18 17:27:33 EDT
1) If an LV is activated read-only (using read_only_volume_list), and then that setting is cleared, it would be useful if lvchange -prw would make it rw in the kernel as an alternative to lvchange --refresh.

2) If for any other reason an LV happens to be read-only in the kernel, but its metadata says it should be read-write, it would be useful if lvchange -prw would make it rw in the kernel.

Requested for RHEV's use.
Comment 5 Alasdair Kergon 2015-02-26 13:45:39 EST
Create LV (writeable as normal) inactive.  Set read_only_volume_list in config to activate it read-only.  Activate it.  lvs shows R:
                                            
  lvol0  vg6  -Ri-a----- 12.00m  

Remove the read_only_volume_list setting.
run lvchange -prw with current code:

  Logical volume "lvol0" is already writable

Run with new code:

  Logical volume "lvol0" is already writable.  Refreshing kernel state.
  Logical volume "lvol0" changed.

Side-effect: The same happens repeatedly if you still have read_only_volume_list set.

https://lists.fedorahosted.org/pipermail/lvm2-commits/2015-February/003577.html
Comment 6 Alasdair Kergon 2015-02-27 08:40:51 EST
Same for -pr if kernel is rw but metadata is already ro.

https://lists.fedorahosted.org/pipermail/lvm2-commits/2015-February/003585.html
Comment 8 Corey Marthaler 2015-04-01 12:17:22 EDT
SCENARIO (raid1) - [kernel_perm_changes_tag_removal]
Verify in-kernel permission changes are possible when the metadata setting is different
Create a raid with tags that match what is present in the read_only_volume_list and then change the in-kernel permissions

# in /etc/lvm/lvm.conf
    read_only_volume_list = [ "@RO" ]

lvcreate  --type raid1 -n kern_perm -L 300M --addtag RO raid_sanity
  /dev/raid_sanity/kern_perm: write failed after 0 of 4096 at 0: Operation not permitted

kern_perm: attr=rRi-a-r---
kern_perm_rimage_0: attr=IRi-aor---
kern_perm_rimage_1: attr=IRi-aor---

Remove the tags from the raid volume, and attempt to change the in kernel RW permissions
lvchange --deltag RO raid_sanity/kern_perm
lvchange -prw raid_sanity/kern_perm
kern_perm: attr=rwi-a-r---
kern_perm_rimage_0: attr=iwi-aor---
kern_perm_rimage_1: attr=iwi-aor---

Add the tags back to the raid volume, and attempt to change the in kernel RW permissions
lvchange --addtag RO raid_sanity/kern_perm
lvchange -pr raid_sanity/kern_perm
kern_perm: attr=rri-a-r---
kern_perm_rimage_0: attr=iRi-aor---
kern_perm_rimage_1: attr=iRi-aor---

Shouldn't the top level raid volume now have the 'R' (Read-only activation of non-read-only volume) again like it did when originally created?

[root@host-111 ~]# lvs -a -o +devices,lv_tags
  LV                   Attr       LSize   Cpy%Sync Devices                                     LV Tags
  kern_perm            rri-a-r--- 300.00m 100.00   kern_perm_rimage_0(0),kern_perm_rimage_1(0) RO
  [kern_perm_rimage_0] iRi-aor--- 300.00m          /dev/sda2(1)
  [kern_perm_rimage_1] iRi-aor--- 300.00m          /dev/sda1(1)
  [kern_perm_rmeta_0]  eRi-aor---   4.00m          /dev/sda2(0)
  [kern_perm_rmeta_1]  eRi-aor---   4.00m          /dev/sda1(0)
Comment 9 Alasdair Kergon 2015-04-01 12:30:23 EDT
(In reply to Corey Marthaler from comment #8)

> lvchange -prw raid_sanity/kern_perm
> lvchange --addtag RO raid_sanity/kern_perm

> lvchange -pr raid_sanity/kern_perm

This changes both on-disk and in-kernel perms to read-only.

This bugzilla is about making 'lvchange -p' check (and change) the in-kernel permissions even if the on-disk permissions are already in the desired state.
Comment 10 Corey Marthaler 2015-04-01 18:26:37 EDT
Filed bug 1208269 for the inconsistencies in the attributes mentioned in comment #8.
Comment 11 Corey Marthaler 2015-04-01 18:42:37 EDT
Feature verified in the latest rpms.

2.6.32-546.el6.x86_64
lvm2-2.02.118-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
lvm2-libs-2.02.118-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
lvm2-cluster-2.02.118-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
udev-147-2.61.el6    BUILT: Mon Mar  2 05:08:11 CST 2015
device-mapper-1.02.95-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
device-mapper-libs-1.02.95-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
device-mapper-event-1.02.95-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
device-mapper-event-libs-1.02.95-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015
device-mapper-persistent-data-0.3.2-1.el6    BUILT: Fri Apr  4 08:43:06 CDT 2014
cmirror-2.02.118-1.el6    BUILT: Tue Mar 24 08:25:21 CDT 2015



# RO -> RW
lvcreate  --type raid1 -n kern_perm -L 300M --addtag RO raid_sanity
  /dev/raid_sanity/kern_perm: write failed after 0 of 4096 at 0: Operation not permitted

[root@host-111 ~]# lvs -a -o +devices
  LV                   Attr       LSize   Cpy%Sync Devices
  kern_perm            rRi-a-r--- 300.00m 100.00   kern_perm_rimage_0(0),kern_perm_rimage_1(0)
  [kern_perm_rimage_0] iRi-aor--- 300.00m          /dev/sda2(1)
  [kern_perm_rimage_1] iRi-aor--- 300.00m          /dev/sda1(1)
  [kern_perm_rmeta_0]  eRi-aor---   4.00m          /dev/sda2(0)
  [kern_perm_rmeta_1]  eRi-aor---   4.00m          /dev/sda1(0)

lvchange --deltag RO raid_sanity/kern_perm

[root@host-111 ~]# lvchange -prw raid_sanity/kern_perm
  Logical volume "kern_perm" is already writable.  Refreshing kernel state.
  Logical volume "kern_perm" changed.

[root@host-111 ~]# lvs -a -o +devices
  LV                   Attr       LSize   Cpy%Sync Devices
  kern_perm            rwi-a-r--- 300.00m 100.00   kern_perm_rimage_0(0),kern_perm_rimage_1(0)
  [kern_perm_rimage_0] iwi-aor--- 300.00m          /dev/sda2(1)
  [kern_perm_rimage_1] iwi-aor--- 300.00m          /dev/sda1(1)
  [kern_perm_rmeta_0]  ewi-aor---   4.00m          /dev/sda2(0)
  [kern_perm_rmeta_1]  ewi-aor---   4.00m          /dev/sda1(0)


# RW -> RO
lvcreate  --type raid1 -m 1 -n kern_perm -L 300M raid_sanity

[root@host-111 ~]# lvs -a -o +devices
  LV                   Attr       LSize   Cpy%Sync Devices
  kern_perm            rwi-a-r--- 300.00m 100.00   kern_perm_rimage_0(0),kern_perm_rimage_1(0)
  [kern_perm_rimage_0] iwi-aor--- 300.00m          /dev/sda2(1)
  [kern_perm_rimage_1] iwi-aor--- 300.00m          /dev/sda1(1)
  [kern_perm_rmeta_0]  ewi-aor---   4.00m          /dev/sda2(0)
  [kern_perm_rmeta_1]  ewi-aor---   4.00m          /dev/sda1(0)

lvchange --addtag RO raid_sanity/kern_perm

[root@host-111 ~]# lvchange -pr raid_sanity/kern_perm
  Logical volume "kern_perm" changed.

[root@host-111 ~]# lvs -a -o +devices
  LV                   Attr       LSize   Cpy%Sync Devices
  kern_perm            rri-a-r--- 300.00m 100.00   kern_perm_rimage_0(0),kern_perm_rimage_1(0)
  [kern_perm_rimage_0] iRi-aor--- 300.00m          /dev/sda2(1)
  [kern_perm_rimage_1] iRi-aor--- 300.00m          /dev/sda1(1)
  [kern_perm_rmeta_0]  eRi-aor---   4.00m          /dev/sda2(0)
  [kern_perm_rmeta_1]  eRi-aor---   4.00m          /dev/sda1(0)
Comment 12 Corey Marthaler 2015-04-08 19:19:27 EDT
Is this supposed to work with clvmd as well? (see bug 1210105)
Comment 13 errata-xmlrpc 2015-07-22 03:37:02 EDT
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.

https://rhn.redhat.com/errata/RHBA-2015-1411.html

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