From: Tejun Heo <htejun@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: udev queue error
Date: Tue, 28 Jun 2011 15:53:22 +0000 [thread overview]
Message-ID: <20110628155322.GF3386@htj.dyndns.org> (raw)
In-Reply-To: <BANLkTim9kJEroUeqpqNoE-tCRvxa5=nghw@mail.gmail.com>
Hello, again.
Please test this one. The previous one was broken and I also updated
it such that tur_mismatch is cleared iff !tur_changed &&
!get_event_changed.
Thanks.
---
drivers/scsi/sr.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
drivers/scsi/sr.h | 7 +++++++
2 files changed, 49 insertions(+), 4 deletions(-)
Index: work/drivers/scsi/sr.c
=================================--- work.orig/drivers/scsi/sr.c
+++ work/drivers/scsi/sr.c
@@ -221,14 +221,33 @@ static unsigned int sr_check_events(stru
return 0;
events = sr_get_events(cd->device);
+ cd->get_event_changed |= events & DISK_EVENT_MEDIA_CHANGE;
+
+ /*
+ * If earlier GET_EVENT_STATUS_NOTIFICATION and TUR did not agree
+ * for a couple of times in a row. We rely on TUR only for this
+ * likely broken device, to prevent generating incorrect media
+ * changed events for every open().
+ */
+ if (cd->ignore_get_event) {
+ events &= ~DISK_EVENT_MEDIA_CHANGE;
+ goto do_tur;
+ }
+
/*
* GET_EVENT_STATUS_NOTIFICATION is enough unless MEDIA_CHANGE
* is being cleared. Note that there are devices which hang
* if asked to execute TUR repeatedly.
*/
- if (!(clearing & DISK_EVENT_MEDIA_CHANGE))
- goto skip_tur;
+ if (cd->device->changed) {
+ events |= DISK_EVENT_MEDIA_CHANGE;
+ cd->device->changed = 0;
+ cd->tur_changed = true;
+ }
+ if (!(clearing & DISK_EVENT_MEDIA_CHANGE))
+ return events;
+do_tur:
/* let's see whether the media is there with TUR */
last_present = cd->media_present;
ret = scsi_test_unit_ready(cd->device, SR_TIMEOUT, MAX_RETRIES, &sshdr);
@@ -242,12 +261,31 @@ static unsigned int sr_check_events(stru
(scsi_sense_valid(&sshdr) && sshdr.asc != 0x3a);
if (last_present != cd->media_present)
- events |= DISK_EVENT_MEDIA_CHANGE;
-skip_tur:
+ cd->device->changed = 1;
+
if (cd->device->changed) {
events |= DISK_EVENT_MEDIA_CHANGE;
cd->device->changed = 0;
+ cd->tur_changed = true;
+ }
+
+ if (cd->ignore_get_event)
+ return events;
+
+ /* check for spurious changed events from GET_EVENT */
+ if (!cd->tur_changed) {
+ if (cd->get_event_changed) {
+ if (cd->tur_mismatch++ > 8) {
+ sdev_printk(KERN_WARNING, cd->device,
+ "GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n");
+ cd->ignore_get_event = true;
+ }
+ } else {
+ cd->tur_mismatch = 0;
+ }
}
+ cd->tur_changed = false;
+ cd->get_event_changed = false;
return events;
}
Index: work/drivers/scsi/sr.h
=================================--- work.orig/drivers/scsi/sr.h
+++ work/drivers/scsi/sr.h
@@ -41,6 +41,13 @@ typedef struct scsi_cd {
unsigned readcd_known:1; /* drive supports READ_CD (0xbe) */
unsigned readcd_cdda:1; /* reading audio data using READ_CD */
unsigned media_present:1; /* media is present */
+
+ /* GET_EVENT spurious event handling, block guarantees exclusion */
+ int tur_mismatch; /* nr of get_event TUR mismatches */
+ bool tur_changed:1; /* changed according to TUR */
+ bool get_event_changed:1; /* changed according to GET_EVENT */
+ bool ignore_get_event:1; /* get_event is unreliable, use TUR */
+
struct cdrom_device_info cdi;
/* We hold gendisk and scsi_device references on probe and use
* the refs on this kref to decide when to release them */
next prev parent reply other threads:[~2011-06-28 15:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-30 19:46 udev queue error Markus Rathgeb
2011-05-30 20:06 ` Kay Sievers
2011-05-31 15:31 ` Tejun Heo
2011-05-31 15:34 ` Markus Rathgeb
2011-05-31 15:40 ` Kay Sievers
2011-05-31 15:46 ` Kay Sievers
2011-06-01 1:39 ` Tejun Heo
2011-06-01 2:10 ` Kay Sievers
2011-06-01 4:42 ` Tejun Heo
2011-06-08 11:55 ` Kay Sievers
2011-06-09 11:54 ` Tejun Heo
2011-06-09 12:36 ` Kay Sievers
2011-06-12 12:28 ` Tejun Heo
2011-06-13 19:02 ` Kay Sievers
2011-06-14 20:24 ` Kay Sievers
2011-06-15 7:13 ` Tejun Heo
2011-06-15 9:34 ` Kay Sievers
2011-06-15 9:40 ` Tejun Heo
2011-06-18 21:41 ` Kay Sievers
2011-06-28 13:45 ` Tejun Heo
2011-06-28 15:53 ` Tejun Heo [this message]
2011-06-28 15:57 ` Tejun Heo
2011-06-28 22:20 ` Kay Sievers
2011-06-28 22:21 ` Kay Sievers
2011-06-29 20:54 ` Markus Rathgeb
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=20110628155322.GF3386@htj.dyndns.org \
--to=htejun@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).