linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Vagin <avagin@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udev: fix problem due to unsorted events
Date: Tue, 06 Mar 2012 08:48:01 +0000	[thread overview]
Message-ID: <1331023681-27958-1-git-send-email-avagin@gmail.com> (raw)

From: Andrey Vagin <avagin@openvz.org>

A kernel gives events, but this events can be unsorted.
For example, here is log from system:
udevd[77]: seq 924 queued, 'add' 'bdi'
udevd[77]: seq 926 queued, 'add' 'block'
udevd[77]: seq 927 queued, 'add' 'block'
udevd[77]: seq 928 queued, 'add' 'block
udevd[77]: seq 925 queued, 'add' 'drivers'

In this case "udevadm settle" returns an error:
queue is empty but kernel events still pending [928]<->[925]

Let's look at update_queue(). It contains the follow code:

/* now write to the queue */
if (state = DEVICE_QUEUED) {
        udev_queue_export->queued_count++;
        udev_queue_export->seqnum_min = seqnum;
}

where seqnum_min is latest sequence number in queue file. Probably we
should check that seqnum is not less than seqnum_min and update it only
in this case.

https://bugzilla.redhat.com/show_bug.cgi?idy9834

Signed-off-by: Andrey Vagin <avagin@gmail.com>
---
 src/libudev-queue-private.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/libudev-queue-private.c b/src/libudev-queue-private.c
index 7177195..6a689c4 100644
--- a/src/libudev-queue-private.c
+++ b/src/libudev-queue-private.c
@@ -376,7 +376,8 @@ static int update_queue(struct udev_queue_export *udev_queue_export,
         /* now write to the queue */
         if (state = DEVICE_QUEUED) {
                 udev_queue_export->queued_count++;
-                udev_queue_export->seqnum_min = seqnum;
+                if (udev_queue_export->seqnum_min < seqnum)
+                        udev_queue_export->seqnum_min = seqnum;
         } else {
                 udev_queue_export->waste_bytes += queue_record_size(devpath_len) + queue_record_size(0);
                 udev_queue_export->queued_count--;
-- 
1.7.7.6


             reply	other threads:[~2012-03-06  8:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06  8:48 Andrey Vagin [this message]
2012-03-06 11:06 ` [PATCH] udev: fix problem due to unsorted events Kay Sievers
2012-03-06 12:43 ` Kay Sievers
2012-03-06 20:06   ` [PATCH] uevent: send events in correct order according to seqnum Andrew Vagin
2012-03-06 21:03     ` Kay Sievers
2012-03-06 21:14       ` avagin
2012-03-07  5:52         ` Greg Kroah-Hartman
2012-03-07  9:59     ` [PATCH] uevent: send events in correct order according to seqnum (v2) Andrew Vagin
2012-03-07 10:18       ` Kay Sievers
2012-03-07 10:49     ` [PATCH] uevent: send events in correct order according to seqnum (v3) Andrew Vagin
2012-03-07 11:03       ` Kay Sievers
2012-03-07 15:45       ` Greg Kroah-Hartman
2012-03-07 17:34         ` Andrew Wagin
2012-03-07 17:47           ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331023681-27958-1-git-send-email-avagin@gmail.com \
    --to=avagin@gmail.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).