hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Tue Sep 12 00:56:31 PDT 2006
hald/linux/blockdev.c | 15 ++++++++++++++-
hald/util.c | 27 ---------------------------
2 files changed, 14 insertions(+), 28 deletions(-)
New commits:
diff-tree 10a19455b5e3cdb930a51235df8c0c58d052ae96 (from e35d886bf811baa0c15e9d71a6296f37ef403dde)
Author: David Zeuthen <davidz at redhat.com>
Date: Tue Sep 12 03:55:55 2006 -0400
don't lock the .hal-mtab file at all when checking mount status on unmount
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index cc21ddf..a5196ff 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -287,10 +287,23 @@ blockdev_refresh_mount_state (HalDevice
* hal_util_is_mounted_by_hald() will block until Unmount() returns.
*
* And this is a problem because on Linux /proc/mounts is changed immediately, e.g.
- * we get to here but umount(8) don't return until much later. This is normally
+ * we get to here... but umount(8) don't return until much later. This is normally
* not a problem, it only surfaces under circumstances described in
* https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=194296, e.g. when there
* is a lot of data waiting to be written.
+ *
+ * Actually, when we do the "is Unmount() executing on this device" check, there is
+ * no need to lock the file to check to see if we're unmounted. Because either
+ * a) we're executing Unmount => Unmount() unmounting this => Unmount() cleaning up
+ * the /media mount point => hald needs to do nothing. Or b) we're not executing
+ * Unmount() on this device, so Unmount() already done this => Unmount() not
+ * currently modifying the .hal-mtab entry for this device => safe for hald to look
+ * at this entry.
+ *
+ * This will also take care of nasty lock-ups in the event some long-running
+ * Unmount() method, executing on another device, is holding the lock. So since
+ * we do this check, no locking is necessary. Hence, we've now
+ * changed hal_util_is_mounted_by_hald() to not lock.
*/
if (!device_is_executing_method (dev, "Unmount")) {
if (mount_point != NULL && strlen (mount_point) > 0 &&
diff --git a/hald/util.c b/hald/util.c
index e2cf5aa..225142b 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -986,36 +986,11 @@ hal_util_is_mounted_by_hald (const char
char *hal_mtab_buf;
char **lines;
gboolean found;
- int lock_mtab_fd;
hal_mtab = NULL;
hal_mtab_buf = NULL;
found = FALSE;
- /* take the lock on /media/.hal-mtab-lock so we don't race with the Mount() and Unmount() methods */
-
- /* do not attempt to create the file; tools/hal-storage-shared.c will create it and
- * set the correct ownership so this unprivileged process (running as haldaemon) can
- * lock it too
- */
- lock_mtab_fd = open ("/media/.hal-mtab-lock", 0);
- if (lock_mtab_fd < 0) {
- HAL_INFO (("Cannot open /media/.hal-mtab for locking"));
- goto out;
- }
-
-tryagain:
-#ifdef sun
- if (lockf (lock_mtab_fd, F_LOCK, 0) != 0) {
-#else
- if (flock (lock_mtab_fd, LOCK_EX) != 0) {
-#endif
- if (errno == EINTR)
- goto tryagain;
- HAL_ERROR (("Cannot obtain lock on /media/.hal-mtab"));
- goto out;
- }
-
/*HAL_DEBUG (("examining /media/.hal-mtab for %s", mount_point));*/
hal_mtab = fopen ("/media/.hal-mtab", "r");
@@ -1081,8 +1056,6 @@ tryagain:
}
out:
- if (lock_mtab_fd >= 0)
- close (lock_mtab_fd);
if (hal_mtab != NULL)
fclose (hal_mtab);
if (hal_mtab_buf != NULL)
More information about the hal-commit
mailing list