public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: agk@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2/libdm libdm-common.c
Date: Wed, 05 Aug 2009 19:50:00 -0000	[thread overview]
Message-ID: <20090805195009.6429.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-08-05 19:50:08

Modified files:
	libdm          : libdm-common.c 

Log message:
	Additional logging

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74

--- LVM2/libdm/libdm-common.c	2009/08/03 18:33:08	1.73
+++ LVM2/libdm/libdm-common.c	2009/08/05 19:50:08	1.74
@@ -854,41 +854,50 @@
 	return 0;
 }
 
-static int _udev_notify_sem_inc(int semid)
+static int _udev_notify_sem_inc(uint32_t cookie, int semid)
 {
 	struct sembuf sb = {0, 1, 0};
 
 	if (semop(semid, &sb, 1) < 0) {
-		log_error("semid %d: semop failed: %s", semid, strerror(errno));
+		log_error("semid %d: semop failed for cookie 0x%" PRIx32 ": %s",
+			  semid, cookie, strerror(errno));
 		return 0;
 	}
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
+		  cookie, semid);
+
 	return 1;
 }
 
-static int _udev_notify_sem_dec(int semid)
+static int _udev_notify_sem_dec(uint32_t cookie, int semid)
 {
 	struct sembuf sb = {0, -1, IPC_NOWAIT};
 
 	if (semop(semid, &sb, 1) < 0) {
 		switch (errno) {
 			case EAGAIN:
-				log_error("semid %d: semop failed: "
+				log_error("semid %d: semop failed for cookie "
+					  "0x%" PRIx32 ": "
 					  "incorrect semaphore state",
-					  semid);
+					  semid, cookie);
 				break;
 			default:
-				log_error("semid %d: semop failed: %s",
-					  semid, strerror(errno));
+				log_error("semid %d: semop failed for cookie "
+					  "0x%" PRIx32 ": %s",
+					  semid, cookie, strerror(errno));
 				break;
 		}
 		return 0;
 	}
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) decremented",
+		  cookie, semid);
+
 	return 1;
 }
 
-static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
+static int _udev_notify_sem_destroy(uint32_t cookie, int semid)
 {
 	if (semctl(semid, 0, IPC_RMID, 0) < 0) {
 		log_error("Could not cleanup notification semaphore "
@@ -897,6 +906,9 @@
 		return 0;
 	}
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) destroyed", cookie,
+		  semid);
+
 	return 1;
 }
 
@@ -950,14 +962,20 @@
 		}
 	} while (!base_cookie);
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) created",
+		  gen_cookie, gen_semid);
+
 	if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
 		log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
 		/* We have to destroy just created semaphore
 		 * so it won't stay in the system. */
-		(void) _udev_notify_sem_destroy(gen_semid, gen_cookie);
+		(void) _udev_notify_sem_destroy(gen_cookie, gen_semid);
 		goto bad;
 	}
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
+		  gen_cookie, gen_semid);
+
 	if (close(fd))
 		stack;
 
@@ -990,7 +1008,7 @@
 	} else if (!_udev_notify_sem_create(cookie, &semid))
 		goto_bad;
 
-	if (!_udev_notify_sem_inc(semid)) {
+	if (!_udev_notify_sem_inc(*cookie, semid)) {
 		log_error("Could not set notification semaphore "
 			  "identified by cookie value %" PRIu32 " (0x%x)",
 			  *cookie, *cookie);
@@ -999,6 +1017,10 @@
 
 	dmt->event_nr = *cookie;
 	dmt->cookie_set = 1;
+
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task",
+		  dmt->event_nr, semid);
+
 	return 1;
 
 bad:
@@ -1016,7 +1038,7 @@
 	if (!_get_cookie_sem(cookie, &semid))
 		return_0;
 
-	if (!_udev_notify_sem_dec(semid)) {
+	if (!_udev_notify_sem_dec(cookie, semid)) {
 		log_error("Could not signal waiting process using notification "
 			  "semaphore identified by cookie value %" PRIu32 " (0x%x)",
 			  cookie, cookie);
@@ -1037,15 +1059,18 @@
 	if (!_get_cookie_sem(cookie, &semid))
 		return_0;
 
-	if (!_udev_notify_sem_dec(semid)) {
+	if (!_udev_notify_sem_dec(cookie, semid)) {
 		log_error("Failed to set a proper state for notification "
 			  "semaphore identified by cookie value %" PRIu32 " (0x%x) "
 			  "to initialize waiting for incoming notifications.",
 			  cookie, cookie);
-		(void) _udev_notify_sem_destroy(semid, cookie);
+		(void) _udev_notify_sem_destroy(cookie, semid);
 		return 0;
 	}
 
+	log_debug("Udev cookie 0x%" PRIx32 " (semid %d): Waiting for zero",
+		  cookie, semid);
+
 repeat_wait:
 	if (semop(semid, &sb, 1) < 0) {
 		if (errno == EINTR)
@@ -1053,11 +1078,11 @@
 		log_error("Could not set wait state for notification semaphore "
 			  "identified by cookie value %" PRIu32 " (0x%x): %s",
 			  cookie, cookie, strerror(errno));
-		(void) _udev_notify_sem_destroy(semid, cookie);
+		(void) _udev_notify_sem_destroy(cookie, semid);
 		return 0;
 	}
 
-	return _udev_notify_sem_destroy(semid, cookie);
+	return _udev_notify_sem_destroy(cookie, semid);
 }
 
 #endif		/* UDEV_SYNC_SUPPORT */


             reply	other threads:[~2009-08-05 19:50 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05 19:50 agk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-02-13 14:39 zkabelac
2012-01-25 21:47 zkabelac
2011-09-24 11:47 prajnoha
2011-07-08 15:34 agk
2011-07-05 16:17 agk
2011-06-28  9:24 agk
2011-03-02  8:40 zkabelac
2010-12-13 12:44 prajnoha
2010-12-13 12:30 prajnoha
2010-12-13 12:18 prajnoha
2010-11-29 10:11 zkabelac
2009-09-25 19:06 agk
2009-09-25 18:19 agk
2009-09-25 18:13 agk
2009-09-11 16:11 prajnoha
2009-09-11 15:57 prajnoha
2009-08-06 15:00 prajnoha
2009-08-03 18:33 agk
2009-08-03 11:01 agk
2009-07-31 16:57 agk

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=20090805195009.6429.qmail@sourceware.org \
    --to=agk@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).