Skip to contentSkip to conversation

SCSI: kill compat SDEV_MEDIA_CHANGE event

PATCH In review Tejun Heo 2 participants 2 messages Dec 28, 2010 SCSI

lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 SCSI: kill compat SDEV_MEDIA_CHANGE event

SDEV_MEDIA_CHANGE event was first added by commit a341cd0f (SCSI: add asynchronous event notification API) for SATA AN support and then extended to cover generic media change events by commit 285e9670 ([SCSI] sr,sd: send media state change modification events).

This event was mapped to block device in userland with all properties stripped to simulate CHANGE event on the block device, which, in turn, was used to trigger further userspace action on media change.

The recent addition of disk event framework kept this event for backward compatibility but it turns out to be unnecessary and causes erratic and inefficient behavior. The new disk event generates proper events on the block devices and the compat events are mapped to block device with all properties stripped, so the block device ends up generating multiple duplicate events for single actual event.

This patch removes the compat event generation from both sr and sd as suggested by Kay Sievers. Both existing and newer versions of udev and the associated tools will behave better with the removal of these events as they from the beginning were expecting events on the block devices.

Cc Kay Sievers <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Jeff Garzik <[email protected]>
---
 drivers/scsi/sd.c |    5 -----
 drivers/scsi/sr.c |    4 ----
 2 files changed, 9 deletions(-)
drivers/scsi/sd.c +0 -5
index 7d25746..e567302 100644
@@ -1086,13 +1086,8 @@ out:
 	 *
 	 *	Medium present state has changed in either direction.
 	 *	Device has indicated UNIT_ATTENTION.
-	 *
-	 * Report SDEV_EVT_MEDIA_CHANGE too for backward compatibility.
 	 */
-	if (sdp->changed)
-		sdev_evt_send_simple(sdp, SDEV_EVT_MEDIA_CHANGE, GFP_KERNEL);
 	kfree(sshdr);
-
 	retval = sdp->changed ? DISK_EVENT_MEDIA_CHANGE : 0;
 	sdp->changed = 0;
 	return retval;
drivers/scsi/sr.c +0 -4
index be6baf8..aefadc6 100644
@@ -249,10 +249,6 @@ skip_tur:
 		cd->device->changed = 0;
 	}
 
-	/* for backward compatibility */
-	if (events & DISK_EVENT_MEDIA_CHANGE)
-		sdev_evt_send_simple(cd->device, SDEV_EVT_MEDIA_CHANGE,
-				     GFP_KERNEL);
 	return events;
 }
 
Tested-by on v1 1/1
#1 lore raw
Quoted 22 lines · Tejun Heo

SDEV_MEDIA_CHANGE event was first added by commit a341cd0f (SCSI: add asynchronous event notification API) for SATA AN support and then extended to cover generic media change events by commit 285e9670 ([SCSI] sr,sd: send media state change modification events).

This event was mapped to block device in userland with all properties stripped to simulate CHANGE event on the block device, which, in turn, was used to trigger further userspace action on media change.

The recent addition of disk event framework kept this event for backward compatibility but it turns out to be unnecessary and causes erratic and inefficient behavior.  The new disk event generates proper events on the block devices and the compat events are mapped to block device with all properties stripped, so the block device ends up generating multiple duplicate events for single actual event.

This patch removes the compat event generation from both sr and sd as suggested by Kay Sievers.  Both existing and newer versions of udev and the associated tools will behave better with the removal of these events as they from the beginning were expecting events on the block devices.

Quoted 4 lines
Cc Kay Sievers <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Jeff Garzik <[email protected]>

Here's my:

Works fine for me with udev/udisks.

Udev uses a rule to "forward" the SCSI events to the block device, and fake an event there. Now that we have the events proper from the device itself, where they belong to, we can stop doing such weird hacks.

I'm happy to see that mess cleaned up. Thanks a lot for doing all that!

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html