Udev integration: Provide --noudevwait option for LVM commands
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);