Bug 1210981

Summary: udevadm settle ignores the timeout when --timeout=0
Product: Red Hat Enterprise Linux 7 Reporter: Nir Soffer <nsoffer>
Component: systemdAssignee: systemd-maint
Status: CLOSED ERRATA QA Contact: Frantisek Sumsal <fsumsal>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.1CC: amureini, bmcclain, fsumsal, jscotka, lnykryn, msekleta, systemd-maint-list
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-219-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 15:00:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nir Soffer 2015-04-11 20:10:56 UTC
Description of problem:

When running udevadm settle with zero timeout, it should check if the
event queue is empty and return immediately.

udevadm(8) says:

    ...
    udevadm settle [options]
       Watches the udev event queue, and exits if all current events are
       handled.

       --timeout=seconds
           Maximum number of seconds to wait for the event queue to become
           empty. The default value is 120 seconds. A value of 0 will check
           if the queue is empty and always return immediately.
    ...

Version-Release number of selected component (if applicable):
rhel >= 7

How reproducible:
Always

Steps to Reproduce:
1. Ensure that the event queue is not empty
2. udevadm settle --timeout=0

Actual results:
Waits until the event queue is empty - as if called without the
--timeout argument.

Expected results:
If the event queue is empty, should return immediately

Additional info:

In rhel 6 (udev-147) udevadm behaved according to the manual.

The behavior changed in:

commit ead7c62ab7641e150c6d668f939c102a6771ce60
Author: Kay Sievers <kay.sievers>
Date:   Wed Apr 20 02:18:22 2011 +0200

    udevadm: settle - kill alarm()

Looking at the patch, the behavior change seems to be unintended.

Comment 1 Nir Soffer 2015-04-11 20:12:17 UTC
Addding Regression - behavior changed since RHEL 6.

Comment 5 Allon Mureinik 2015-04-28 07:52:02 UTC
(In reply to Nir Soffer from comment #1)
> Addding Regression - behavior changed since RHEL 6.
As this is a regression, it would be nice to also have a fix for RHEL 7.1.z.
Bronce - could you please raise the correct flag for this - I do not have the permissions.

Comment 6 Nir Soffer 2015-04-28 11:51:15 UTC
Fixed in:

commit bf23b9f86f6807c3029a6a46e1999ae0c87ca22a
Author: Nir Soffer <nirsof>
Date:   Sun Apr 19 03:41:26 2015 +0300

    udev: settle should return immediately when timeout is 0
    
    udevadm manual says:
    
        A value of 0 will check if the queue is empty and always return
        immediately.
    
    However, currently we ignore the deadline if the value is 0, and wait
    without any limit.
    
    Zero timeout behaved according to the documentation until commit
    ead7c62ab7 (udevadm: settle - kill alarm()). Looking at this patch, it
    seems that the behavior change was unintended.
    
    This patch restores the documented behavior.

Comment 7 Bronce McClain 2015-05-11 15:26:30 UTC
(In reply to Allon Mureinik from comment #5)
> (In reply to Nir Soffer from comment #1)
> > Addding Regression - behavior changed since RHEL 6.
> As this is a regression, it would be nice to also have a fix for RHEL 7.1.z.
> Bronce - could you please raise the correct flag for this - I do not have
> the permissions.
7.1.z? added

Comment 9 Michal Sekletar 2015-05-13 14:39:57 UTC
To test the backport in the VM one might follow instructions bellow,



#!/bin/bash

# export NAME and MAJOR MINOR numbers for partition where /boot is
export $(lsblk -P | awk '{ if ($0 ~ /MOUNTPOINT="\/boot"/) { split($1,name,"="); gsub("\"", "", name[2]); split($2,nums,"="); gsub("\"","",nums[2]); split(nums[2],res,":"); printf "NAME=%s MAJOR=%s MINOR=%s\n", name[2], res[1], res[2]; } }')

# write the test rule 
printf "ACTION==\"add\", ENV{MAJOR}==\"$MAJOR\", ENV{MINOR}==\"$MINOR\", RUN+=\"/bin/sleep 7200\"\n" > /etc/udev/rules.d/99-test.rules

# reload rules
udevadm control --reload

# syntetize udev add event for the device
echo "add" > /sys$(udevadm info --query=path --name=$NAME)/uevent

# check if event is still being processed
udevadm settle --timeout 0 >/dev/null 2>&1

[[ $? == 0 ]] && echo 'FAILED' || echo 'PASS'

Comment 12 errata-xmlrpc 2015-11-19 15:00:21 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2092.html