Skip to contentSkip to conversation

Udev integration: Provide --noudevwait option for LVM commands

PATCH New Peter Rajnoha 1 participant 1 message May 27, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Udev integration: Provide --noudevwait option for LVM commands

This patch adds --noudevwait option for LVM commands (only the ones where it has a meaning -- where there are uevents generated, so the udev rules will apply). This way we can disable the wait for the notification.

(The "else" part with dm_udev_notif_enable() call is needed because of the LVM shell -- we keep the enable/disable flag as global var)

The option is added for these commands:
lvchange, lvconvert, lvcreate, lvextend/lvreduce/lvresize, lvremove, lvrename, pvmove, vgchange and vgremove

Peter

tools/args.h +1 -0
index c3f2332..11b1175 100644
@@ -59,6 +59,7 @@ arg(unquoted_ARG, '\0', "unquoted", NULL, 0)
 arg(rows_ARG, '\0', "rows", NULL, 0)
 arg(dataalignment_ARG, '\0', "dataalignment", size_kb_arg, 0)
 arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
+arg(noudevwait_ARG, '\0', "noudevwait", NULL, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
tools/commands.h +34 -20

196 lines not on this page · raw message

tools/lvchange.c +5 -0
index 4a314a3..6795cf6 100644
@@ -725,6 +725,11 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
 		return EINVALID_CMD_LINE;
 	}
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
 			       &lvchange_single);
 }
tools/lvconvert.c +5 -0
index f1186cf..42bb751 100644
@@ -228,6 +228,11 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
 	if (!_lvconvert_name_params(lp, cmd, &argc, &argv))
 		return_0;
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	lp->pv_count = argc;
 	lp->pvs = argv;
 
tools/lvcreate.c +5 -0
index 67d065c..37012e0 100644
@@ -607,6 +607,11 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
 	struct lvinfo info;
 	uint32_t pv_extent_count;
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
 		log_error("Logical volume \"%s\" already exists in "
 			  "volume group \"%s\"", lp->lv_name, lp->vg_name);
tools/lvremove.c +5 -0
index 712f175..33e2fa1 100644
@@ -41,6 +41,11 @@ int lvremove(struct cmd_context *cmd, int argc, char **argv)
 
 	cmd->handles_missing_pvs = 1;
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
 			       &lvremove_single);
 }
tools/lvrename.c +5 -0
index fae82c3..73a232f 100644
@@ -113,6 +113,11 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
 		goto error;
 	}
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	if (!lv_rename(cmd, lvl->lv, lv_name_new))
 		goto error;
 
tools/lvresize.c +5 -0
index 420e570..ee78bcc 100644
@@ -200,6 +200,11 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
 	if (!strcmp(cmd_name, "lvextend"))
 		lp->resize = LV_EXTEND;
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	/*
 	 * Allow omission of extents and size if the user has given us
 	 * one or more PVs.  Most likely, the intent was "resize this
tools/pvmove.c +5 -0
index 9ece646..30cdc4c 100644
@@ -370,6 +370,11 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
 	argc--;
 	argv++;
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	/* Find PV (in VG) */
 	if (!(pv = find_pv_by_name(cmd, pv_name))) {
 		stack;
tools/vgchange.c +5 -0
index 84cbf1a..dc2b9b5 100644
@@ -631,6 +631,11 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
 		return EINVALID_CMD_LINE;
 	}
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	return process_each_vg(cmd, argc, argv,
 			       (arg_count(cmd, available_ARG)) ?
 			       LCK_VG_READ : LCK_VG_WRITE, 0, NULL,
tools/vgremove.c +5 -0
index 38f9ee3..7f0c69e 100644
@@ -40,6 +40,11 @@ int vgremove(struct cmd_context *cmd, int argc, char **argv)
 		return ECMD_FAILED;
 	}
 
+	if (arg_count(cmd, noudevwait_ARG))
+		dm_udev_notif_disable();
+	else
+		dm_udev_notif_enable();
+
 	ret = process_each_vg(cmd, argc, argv,
 			      LCK_VG_WRITE, 1,
 			      NULL, &vgremove_single);