All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald Hoyer <harald@redhat.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev git head: cdrom_id regression
Date: Tue, 06 Apr 2010 12:43:38 +0000	[thread overview]
Message-ID: <4BBB2C7A.9010200@redhat.com> (raw)
In-Reply-To: <20100406121935.GA1924@piware.de>

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

Am 06.04.2010 14:26, schrieb Kay Sievers:
> On Tue, Apr 6, 2010 at 14:19, Martin Pitt<martin.pitt@ubuntu.com>  wrote:
>> Kay, do you know why [2] was done in the first place? Do you happen to
>> have a pointer to a bug etc. which describes the problems with CD
>> burning sessions?
>
> Harald said, he has several bugs with cd burning caused by cdrom_id
> and blkid opening the device when a uevent is handled during cd
> burning. I did not receive any such bug.
>
> Kay


https://bugzilla.redhat.com/show_bug.cgi?id=481346
https://bugzilla.redhat.com/show_bug.cgi?id=566535

We might want to apply the attached patches.

[-- Attachment #2: 0001-cdrom_id-remove-debugging-code.patch --]
[-- Type: text/plain, Size: 746 bytes --]

From 194c5c10b65499e52864132ed542845b4c2e757c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 6 Apr 2010 14:34:32 +0200
Subject: [PATCH 1/2] cdrom_id: remove debugging code

---
 extras/cdrom_id/cdrom_id.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c
index e485768..036ef28 100644
--- a/extras/cdrom_id/cdrom_id.c
+++ b/extras/cdrom_id/cdrom_id.c
@@ -126,7 +126,6 @@ static int is_mounted(const char *device)
 	if (fp == NULL)
 		return -ENOSYS;
 	while (fscanf(fp, "%*s %*s %i:%i %*[^\n]", &maj, &min) == 2) {
-		printf("got %u %u\n", maj, min);
 		if (makedev(maj, min) == statbuf.st_rdev) {
 			mounted = 1;
 			break;
-- 
1.6.6.1


[-- Attachment #3: 0002-cdrom_id-retry-to-open-the-device-if-EBUSY.patch --]
[-- Type: text/plain, Size: 1530 bytes --]

From cb3d97513fec69c4f75cf24651a16404dd576da4 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 6 Apr 2010 14:37:21 +0200
Subject: [PATCH 2/2] cdrom_id: retry to open the device, if EBUSY

---
 extras/cdrom_id/cdrom_id.c |   29 +++++++++++++++++++++++------
 1 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c
index 036ef28..5e0ddba 100644
--- a/extras/cdrom_id/cdrom_id.c
+++ b/extras/cdrom_id/cdrom_id.c
@@ -591,12 +591,29 @@ int main(int argc, char *argv[])
 		goto exit;
 	}
 
-	fd = open(node, O_RDONLY|O_NONBLOCK|(is_mounted(node) ? 0 : O_EXCL));
-	if (fd < 0) {
-		info(udev, "unable to open '%s'\n", node);
-		fprintf(stderr, "unable to open '%s'\n", node);
-		rc = 1;
-		goto exit;
+
+	{
+		int errno_open=0;
+		int i = 0;
+
+		do {
+			int excl = is_mounted(node) ? 0 : O_EXCL;
+			fd = open(node, O_RDONLY|O_NONBLOCK|excl);
+			errno_open = errno;
+			if (fd < 0) {
+				if (errno_open != EBUSY || i >= 100) {
+					char *strerr = strerror(errno_open);
+					info(udev, "unable to open '%s': %s\n", node, strerr);
+					fprintf(stderr, "unable to open '%s': %s\n", node, strerr);
+					rc = 1;
+					goto exit;
+				} else {
+					fprintf(stderr, "unable to open '%s' exclusively: retrying (%d/100)\n", node, i);
+					usleep((useconds_t)(400000.0 + 400000.0 * rand() * 1.0 / (RAND_MAX+1.0)));
+					i++; 
+				}
+			}
+		} while ((fd < 0) && (errno_open == EBUSY));
 	}
 	info(udev, "probing: '%s'\n", node);
 
-- 
1.6.6.1


  parent reply	other threads:[~2010-04-06 12:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-06 12:19 udev git head: cdrom_id regression Martin Pitt
2010-04-06 12:26 ` Kay Sievers
2010-04-06 12:43 ` Harald Hoyer [this message]
2010-04-06 13:17 ` Marco d'Itri
2010-04-07 10:58 ` Martin Pitt

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=4BBB2C7A.9010200@redhat.com \
    --to=harald@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.