Skip to contentSkip to conversation

master - lvchange: Allow -pr to change kernel only.

PATCH Alasdair Kergon 1 participant 1 message Feb 27, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ee4cd2c73774feeef3794c24865add1c28adb946
Commit:        ee4cd2c73774feeef3794c24865add1c28adb946
Parent:        5b154ae4a3d875009aa7a7d081c8e76cdb6dd50f
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Fri Feb 27 13:38:26 2015 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Fri Feb 27 13:38:26 2015 +0000

lvchange: Allow -pr to change kernel only.

---
 WHATS_NEW        |    1 +
 tools/lvchange.c |    7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)
WHATS_NEW +1 -0
index cc974a6..bc2630c 100644
@@ -1,5 +1,6 @@
 Version 2.02.117 - 
 ====================================
+  Allow lvchange -p to change kernel state only if metadata state differs.
   Fix incorrect persistent .cache after report with label fields only (2.02.106).
   Reinstate PV tag recognition for pvs if reporting label fields only (2.02.105).
   Rescan devices before vgimport with lvmetad so exported VG is seen.
tools/lvchange.c +7 -0
index 6ed953f..bf7e356 100644
@@ -32,6 +32,13 @@ static int _lvchange_permission(struct cmd_context *cmd,
 	}
 
 	if (!(lv_access & LVM_WRITE) && !(lv->status & LVM_WRITE)) {
+		/* Refresh if it's read-only in metadata but read-write in kernel */
+		if (lv_info(cmd, lv, 0, &info, 0, 0) &&
+		    (info_obtained = 1, info.exists) && !info.read_only) {
+			log_print_unless_silent("Logical volume \"%s\" is already read-only.  Refreshing kernel state.",
+						lv->name);
+			return lv_refresh(cmd, lv);
+		}
 		log_error("Logical volume \"%s\" is already read only",
 			  lv->name);
 		return 0;