File 0001-vgchange-check-for-mounted-fs.patch of Package lvm2.1005

From 0e9ddbba5fcd26088f788ba823fd4d5be9f08d33 Mon Sep 17 00:00:00 2001
From: Zdenek Kabelac <zkabelac@redhat.com>
Date: Thu, 8 Mar 2012 23:43:28 +0100
Subject: [PATCH 1/1] vgchange: check for mounted fs

Check for mounted fs also for vgchange command, not just lvchange.

NOTE: Code is using lv_info() just like lvs_in_vg_opened().
It should be probably converted into  lv_is_active_locally().

Acked-by: Lidong Zhong<lzhong@suse.com>
Git-commit: 2ada982e73872
References: bnc#938419
---
 LVM2.2.02.98/tools/vgchange.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/tools/vgchange.c b/tools/vgchange.c
index a897a85..7168e42 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -218,6 +218,8 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
 		      activation_change_t activate)
 {
 	int lv_open, active, monitored = 0, r = 1, do_activate = 1;
+    const struct lv_list *lvl;
+    struct lvinfo info;
 
 	if ((activate == CHANGE_AN) || (activate == CHANGE_ALN))
 		do_activate = 0;
@@ -230,9 +232,14 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
 
 	/* FIXME: Force argument to deactivate them? */
 	if (!do_activate && (lv_open = lvs_in_vg_opened(vg))) {
-		log_error("Can't deactivate volume group \"%s\" with %d open "
-			  "logical volume(s)", vg->name, lv_open);
-		return 0;
+        dm_list_iterate_items(lvl, &vg->lvs)
+            if (lv_is_visible(lvl->lv) &&
+                lv_info(cmd, lvl->lv, 0, &info, 1, 0) &&
+                !lv_check_not_in_use(cmd, lvl->lv, &info)) {
+                log_error("Can't deactivate volume group \"%s\" with %d open "
+                      "logical volume(s)", vg->name, lv_open);
+                return 0;
+            }
 	}
 
 	/* FIXME Move into library where clvmd can use it */
-- 
1.8.4.5

openSUSE Build Service is sponsored by