master - tools: add -b/--background for pvscan --cache -aay
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=008c33a21ba0e0fb27319b63c7bad8fb8136f804 Commit: 008c33a21ba0e0fb27319b63c7bad8fb8136f804 Parent: ea1e8166d57c40a5406b68864e19056df6d2f103 Author: Peter Rajnoha <[email protected]> AuthorDate: Tue Sep 3 16:06:16 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Tue Sep 3 16:49:21 2013 +0200
tools: add -b/--background for pvscan --cache -aay
Udev daemon has recently introduced a limit on the number of udev processes (there was no limit before). This causes a problem when calling pvscan --cache -aay in lvmetad udev rules which is supposed to activate the volumes. This activation is itself synced with udev and so it waits for the activation to complete before the pvscan finishes. The event processing can't continue until this pvscan call is finished.
But if we're at the limit with the udev process count, we can't instatiate any more udev processes, all such events are queued and so we can't process the lvm activation event for which the pvscan is waiting.
Then we're in a deadlock since the udev process with the pvscan --cache -aay call waits for the lvm activation udev processing to complete, but that will never happen as there's this limit hit with the number of udev processes.
The process with pvscan --cache -aay actually times out eventually (3min or 30sec, depends on the version of udev).
This patch makes it possible to run the pvscan --cache -aay in the background so the udev processing can continue and hence we can avoid the deadlock mentioned above.
--- WHATS_NEW | 2 + man/pvscan.8.in | 4 ++ tools/commands.h | 5 ++- tools/lvmcmdline.c | 8 ++++ tools/polldaemon.c | 76 +--------------------------------------- tools/toollib.c | 77 +++++++++++++++++++++++++++++++++++++++++ tools/toollib.h | 2 + udev/69-dm-lvm-metad.rules.in | 2 +- 8 files changed, 98 insertions(+), 78 deletions(-)
WHATS_NEW +2 -0
@@ -1,5 +1,7 @@ Version 2.02.101 - =================================== + Use pvscan -b in udev rules to avoid a deadlock on udev process count limit. + Add pvscan -b/--background for the command to be processed in the background. Don't assume stdin file descriptor is readable. Avoid unlimited recursion when creating dtree containing inactive pvmove LV. Require exactly 3 arguments for lvm2-activation-generator. Remove defaults.
man/pvscan.8.in +4 -0
@@ -19,6 +19,7 @@ pvscan \- scan all disks for physical volumes .RB [ \-h | \-\-help ] .B \-\-cache .RB [ \-a | \-\-activate " " \fIay ] +.RB [ \-b | \-\-background ] .RB [ \-\-major .I major .B \-\-minor
@@ -51,6 +52,9 @@ activation/auto_activation_volume_list set in lvm.conf. If this list is not set, all volumes are considered for autoactivation. The autoactivation is not yet supported for logical volumes that are part of partial or clustered volume groups. .TP +.BR \-b ", " \-\-background +Run the command in the background. +.TP .BR \-\-cache " [" \-\-major " " \fImajor " " \-\-minor " " \fIminor " | " \fIDevicePath " ]..." Scan one or more devices and instruct the lvmetad daemon to update its cached state accordingly. Called internally by udev rules.
tools/commands.h +3 -2
@@ -724,6 +724,7 @@ xx(pvscan,"List all physical volumes" ,PERMITTED_READ_ONLY ,"pvscan " "\n" +"\t[-b|--background]\n" "\t[--cache [-a|--activate ay] [ DevicePath | --major major --minor minor]...]\n" "\t[-d|--debug] " "\n" "\t{-e|--exported | -n|--novolumegroup} " "\n"
@@ -735,8 +736,8 @@ xx(pvscan,"\t[-v|--verbose] " "\n" "\t[--version]\n" , - activate_ARG, available_ARG, cache_ARG, exported_ARG, - ignorelockingfailure_ARG, major_ARG, minor_ARG, + activate_ARG, available_ARG, background_ARG, cache_ARG, + exported_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG, novolumegroup_ARG, partial_ARG, short_ARG, uuid_ARG) xx(segtypes,
tools/lvmcmdline.c +8 -0
@@ -1097,6 +1097,14 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)set_cmd_name (cmd->command->name); +if (arg_count (cmd, background_ARG)) { +if (!become_daemon (cmd,1 )) { +/* parent - quit immediately */ + ret =ECMD_PROCESSED ; + goto out; + } + } +if (arg_count (cmd, config_ARG))if (!override_config_tree_from_string (cmd,arg_str_value (cmd, config_ARG,"" ))) { ret =EINVALID_CMD_LINE ;
tools/polldaemon.c +1 -75
88 lines not on this page · raw message
tools/toollib.c +77 -0
89 lines not on this page · raw message
tools/toollib.h +2 -0
@@ -18,6 +18,8 @@#include "metadata-exported.h" +int become_daemon (struct cmd_context *cmd,int skip_lvm); +int autobackup_set (void );int autobackup_init (const char *backup_dir,int keep_days,int keep_number,int autobackup);
udev/69-dm-lvm-metad.rules.in +1 -1
@@ -34,6 +34,6 @@ KERNEL!="dm-[0-9]*", ACTION!="add", GOTO="lvm_end" KERNEL=="dm-[0-9]*", ENV{DM_ACTIVATION}!="1", GOTO="lvm_end" LABEL="lvm_scan" -RUN+="(LVM_EXEC)/lvm pvscan --cache --activate ay --major $major --minor $minor" +RUN+="(LVM_EXEC)/lvm pvscan --background --cache --activate ay --major $major --minor $minor" LABEL="lvm_end"