hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Thu Jul 19 22:11:31 EEST 2007


 fdi/policy/10osvendor/20-storage-methods.fdi |    4 +++-
 hald/linux/blockdev.c                        |   27 ++++++++++++++++++++++++++-
 hald/linux/blockdev.h                        |    2 ++
 hald/linux/device.c                          |    9 ++++-----
 hald/linux/device.h                          |    2 +-
 hald/linux/hotplug.c                         |   14 ++++++++++++--
 hald/linux/hotplug.h                         |    1 +
 hald/linux/osspec.c                          |    9 ++++++++-
 hald/linux/probing/probe-storage.c           |    2 ++
 tools/hal-setup-keymap-hash-name.h           |    5 ++++-
 10 files changed, 63 insertions(+), 12 deletions(-)

New commits:
diff-tree 1113ce0b76bae9d48bbc894248a167f783c00428 (from 91ee90545a4e4f1d9ee666d8fdb1dfbb49ffca11)
Author: David Zeuthen <davidz at redhat.com>
Date:   Thu Jul 19 15:07:55 2007 -0400

    avoid polling SATA AN capable drives and rely on "change" uevents
    
    This allows us to avoid waking up libata all the freaking time.
    
    Also, to do this refactor and rewire some of the support for "change"
    uevents in the hal core.
    
    See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=halpolling
    for further discussion.

diff --git a/fdi/policy/10osvendor/20-storage-methods.fdi b/fdi/policy/10osvendor/20-storage-methods.fdi
index a54660b..22c45be 100644
--- a/fdi/policy/10osvendor/20-storage-methods.fdi
+++ b/fdi/policy/10osvendor/20-storage-methods.fdi
@@ -7,7 +7,9 @@
     </match>
 
     <match key="storage.media_check_enabled" bool="true">
-      <append key="info.addons" type="strlist">hald-addon-storage</append>
+      <match key="storage.removable.support_async_notification" bool="false">
+        <append key="info.addons" type="strlist">hald-addon-storage</append>
+      </match>
     </match>
 
     <match key="volume.is_disc" bool="true">
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 2ac00d5..83c8781 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1202,6 +1202,17 @@ hotplug_event_begin_add_blockdev (const 
 			hal_device_property_set_uint64 (d, "storage.size", 0);
 		}
 
+                if (is_removable) {
+                        int sysfs_capability;
+                        gboolean support_an;
+
+                        support_an = 
+                                hal_util_get_int_from_file (sysfs_path, "capability", &sysfs_capability, 16) &&
+                                (sysfs_capability&4) != 0;
+                        
+                        hal_device_property_set_bool (d, "storage.removable.support_async_notification", support_an);
+                }
+
 		/* by default, do checks for media if, and only if, the removable file is set to 1
 		 *
 		 * Problematic buses, like IDE, may override this.
@@ -1546,6 +1557,20 @@ out:
 	;
 }
 
+void 
+hotplug_event_refresh_blockdev (gchar *sysfs_path, HalDevice *d, void *end_token)
+{
+	HAL_INFO (("block_change: sysfs_path=%s", sysfs_path));
+
+        if (hal_device_property_get_bool (d, "storage.removable.support_async_notification")) {
+                blockdev_rescan_device (d);
+        }
+
+	/* done with change event */
+	hotplug_event_end (end_token);
+}
+
+
 static void 
 block_rescan_storage_done (HalDevice *d, guint32 exit_type, 
                            gint return_code, gchar **error,
@@ -1599,7 +1624,7 @@ blockdev_rescan_device (HalDevice *d)
 
 	ret = FALSE;
 
-	HAL_INFO (("Entering, udi=%s", hal_device_get_udi (d)));
+	HAL_INFO (("blockdev_rescan_device: udi=%s", hal_device_get_udi (d)));
 
 	/* This only makes sense on storage devices */
 	if (hal_device_property_get_bool (d, "block.is_volume")) {
diff --git a/hald/linux/blockdev.h b/hald/linux/blockdev.h
index 0d28298..02d4b62 100644
--- a/hald/linux/blockdev.h
+++ b/hald/linux/blockdev.h
@@ -32,6 +32,8 @@ void hotplug_event_begin_add_blockdev (c
 
 void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, void *end_token);
 
+void hotplug_event_refresh_blockdev (gchar *sysfs_path, HalDevice *d, void *end_token);
+
 gboolean blockdev_rescan_device (HalDevice *d);
 
 HotplugEvent *blockdev_generate_add_hotplug_event (HalDevice *d);
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 74d1483..f7e3ed5 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3853,12 +3853,12 @@ out:
 }
 
 void
-hotplug_event_refresh_dev (const gchar *subsystem, HalDevice *d, void *end_token)
+hotplug_event_refresh_dev (const gchar *subsystem, const gchar *sysfs_path, HalDevice *d, void *end_token)
 {
 	guint i;
 	DevHandler *handler;
 
-	HAL_INFO (("remove_dev: subsys=%s", subsystem));
+	HAL_INFO (("refresh_dev: subsys=%s", subsystem));
 
 	for (i = 0; dev_handlers [i] != NULL; i++) {
 		handler = dev_handlers[i];
@@ -3870,10 +3870,9 @@ hotplug_event_refresh_dev (const gchar *
 		}
 	}
 
-	/* didn't find anything - thus, ignore this hotplug event */
-	hotplug_event_end (end_token);
 out:
-	;
+	/* done with change event */
+	hotplug_event_end (end_token);
 }
 
 
diff --git a/hald/linux/device.h b/hald/linux/device.h
index bc3afbc..1bd7286 100644
--- a/hald/linux/device.h
+++ b/hald/linux/device.h
@@ -41,7 +41,7 @@ void hotplug_event_begin_add_dev (const 
 				  void *end_token);
 
 void hotplug_event_begin_remove_dev (const gchar *subsystem, const gchar *sysfs_path, void *end_token);
-void hotplug_event_refresh_dev (const gchar *subsystem, HalDevice *d, void *end_token);
+void hotplug_event_refresh_dev (const gchar *subsystem, const gchar *sysfs_path, HalDevice *d, void *end_token);
 
 gboolean dev_rescan_device (HalDevice *d);
 
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index 6178358..71000db 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -89,13 +89,14 @@ hotplug_event_begin_sysfs (HotplugEvent 
 						     "linux.sysfs_path",
 						     hotplug_event->sysfs.sysfs_path);
 
-	/* we should refresh the device when we get a uevent */
+#if 0
+	/* we should refresh the device when we get "change" uevent */
 	if (d != NULL && hotplug_event->action == HOTPLUG_ACTION_ADD) {
 		HAL_ERROR (("device %s already present in the store, so refreshing", hotplug_event->sysfs.sysfs_path));
 		hotplug_event_refresh_dev (hotplug_event->sysfs.subsystem, d, (void *) hotplug_event);
-		hotplug_event_end ((void *) hotplug_event);
 		return;
 	}
+#endif
 
 	/* subsystem "block" are all block devices */
 	if (hotplug_event->type == HOTPLUG_EVENT_SYSFS)
@@ -169,6 +170,11 @@ hotplug_event_begin_sysfs (HotplugEvent 
 			hotplug_event_begin_remove_dev (hotplug_event->sysfs.subsystem,
 							     hotplug_event->sysfs.sysfs_path,
 							     (void *) hotplug_event);
+		} else if (hotplug_event->action == HOTPLUG_ACTION_CHANGE && d != NULL) {
+			hotplug_event_refresh_dev (hotplug_event->sysfs.subsystem,
+                                                   hotplug_event->sysfs.sysfs_path,
+                                                   d,
+                                                   (void *) hotplug_event);
 		}
 	} else if (hotplug_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) {
 		if (hotplug_event->action == HOTPLUG_ACTION_ADD) {
@@ -200,6 +206,10 @@ hotplug_event_begin_sysfs (HotplugEvent 
 		} else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) {
 			hotplug_event_begin_remove_blockdev (hotplug_event->sysfs.sysfs_path,
 							     (void *) hotplug_event);
+		} else if (hotplug_event->action == HOTPLUG_ACTION_CHANGE && d != NULL) {
+			hotplug_event_refresh_blockdev (hotplug_event->sysfs.sysfs_path,
+                                                        d,
+                                                        (void *) hotplug_event);
 		}
 	} else {
 		/* just ignore this hotplug event */
diff --git a/hald/linux/hotplug.h b/hald/linux/hotplug.h
index b9c3501..f4c60cb 100644
--- a/hald/linux/hotplug.h
+++ b/hald/linux/hotplug.h
@@ -36,6 +36,7 @@ typedef enum {
 	HOTPLUG_ACTION_REMOVE,
 	HOTPLUG_ACTION_ONLINE,
 	HOTPLUG_ACTION_OFFLINE,
+	HOTPLUG_ACTION_CHANGE,
 } HotplugActionType;
 
 typedef enum {
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 0030072..717930e 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -234,13 +234,20 @@ hald_udev_data (GIOChannel *source, GIOC
 		   hotplug_event->sysfs.seqnum, action, hotplug_event->sysfs.subsystem, hotplug_event->sysfs.sysfs_path,
 		   hotplug_event->sysfs.device_file, hotplug_event->sysfs.net_ifindex));
 
-	if (strcmp (action, "add") == 0 || strcmp (action, "change") == 0) {
+	if (strcmp (action, "add") == 0) {
 		hotplug_event->action = HOTPLUG_ACTION_ADD;
 		hotplug_event_enqueue (hotplug_event);
 		hotplug_event_process_queue ();
 		goto out;
 	}
 
+	if (strcmp (action, "change") == 0) {
+		hotplug_event->action = HOTPLUG_ACTION_CHANGE;
+		hotplug_event_enqueue (hotplug_event);
+		hotplug_event_process_queue ();
+		goto out;
+	}
+
 	if (strcmp (action, "remove") == 0) {
 		hotplug_event->action = HOTPLUG_ACTION_REMOVE;
 		hotplug_event_enqueue (hotplug_event);
diff --git a/hald/linux/probing/probe-storage.c b/hald/linux/probing/probe-storage.c
index eaa8bd5..83b42bd 100644
--- a/hald/linux/probing/probe-storage.c
+++ b/hald/linux/probing/probe-storage.c
@@ -118,6 +118,8 @@ main (int argc, char *argv[])
 	/* hook in our debug into libvolume_id */
 	volume_id_log_fn = vid_log;
 
+        fprintf (stderr, "woohoo\n");
+
 	/* assume failure */
 	ret = 1;
 
diff --git a/tools/hal-setup-keymap-hash-name.h b/tools/hal-setup-keymap-hash-name.h
index 8205833..741da66 100644
--- a/tools/hal-setup-keymap-hash-name.h
+++ b/tools/hal-setup-keymap-hash-name.h
@@ -1,4 +1,4 @@
-/* C code produced by gperf version 3.0.2 */
+/* C code produced by gperf version 3.0.3 */
 /* Command-line: gperf -t --ignore-case -N lookup_key -H hash_input_names -p -C  */
 /* Computed positions: -k'1-3,5,$' */
 
@@ -145,6 +145,9 @@ hash_input_names (str, len)
 
 #ifdef __GNUC__
 __inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
 #endif
 const struct key *
 lookup_key (str, len)


More information about the hal-commit mailing list