mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Additional logging
This commit is contained in:
parent
ee1e49ec53
commit
fa5617d7f5
@ -854,41 +854,50 @@ static int _get_cookie_sem(uint32_t cookie, int *semid)
|
|||||||
return 0;
|
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};
|
struct sembuf sb = {0, 1, 0};
|
||||||
|
|
||||||
if (semop(semid, &sb, 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
|
||||||
|
cookie, semid);
|
||||||
|
|
||||||
return 1;
|
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};
|
struct sembuf sb = {0, -1, IPC_NOWAIT};
|
||||||
|
|
||||||
if (semop(semid, &sb, 1) < 0) {
|
if (semop(semid, &sb, 1) < 0) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
log_error("semid %d: semop failed: "
|
log_error("semid %d: semop failed for cookie "
|
||||||
|
"0x%" PRIx32 ": "
|
||||||
"incorrect semaphore state",
|
"incorrect semaphore state",
|
||||||
semid);
|
semid, cookie);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_error("semid %d: semop failed: %s",
|
log_error("semid %d: semop failed for cookie "
|
||||||
semid, strerror(errno));
|
"0x%" PRIx32 ": %s",
|
||||||
|
semid, cookie, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) decremented",
|
||||||
|
cookie, semid);
|
||||||
|
|
||||||
return 1;
|
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) {
|
if (semctl(semid, 0, IPC_RMID, 0) < 0) {
|
||||||
log_error("Could not cleanup notification semaphore "
|
log_error("Could not cleanup notification semaphore "
|
||||||
@ -897,6 +906,9 @@ static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) destroyed", cookie,
|
||||||
|
semid);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -950,14 +962,20 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
|
|||||||
}
|
}
|
||||||
} while (!base_cookie);
|
} while (!base_cookie);
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) created",
|
||||||
|
gen_cookie, gen_semid);
|
||||||
|
|
||||||
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
|
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
|
||||||
log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
|
log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
|
||||||
/* We have to destroy just created semaphore
|
/* We have to destroy just created semaphore
|
||||||
* so it won't stay in the system. */
|
* 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;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) incremented",
|
||||||
|
gen_cookie, gen_semid);
|
||||||
|
|
||||||
if (close(fd))
|
if (close(fd))
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
@ -990,7 +1008,7 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie)
|
|||||||
} else if (!_udev_notify_sem_create(cookie, &semid))
|
} else if (!_udev_notify_sem_create(cookie, &semid))
|
||||||
goto_bad;
|
goto_bad;
|
||||||
|
|
||||||
if (!_udev_notify_sem_inc(semid)) {
|
if (!_udev_notify_sem_inc(*cookie, semid)) {
|
||||||
log_error("Could not set notification semaphore "
|
log_error("Could not set notification semaphore "
|
||||||
"identified by cookie value %" PRIu32 " (0x%x)",
|
"identified by cookie value %" PRIu32 " (0x%x)",
|
||||||
*cookie, *cookie);
|
*cookie, *cookie);
|
||||||
@ -999,6 +1017,10 @@ int dm_task_set_cookie(struct dm_task *dmt, uint32_t *cookie)
|
|||||||
|
|
||||||
dmt->event_nr = *cookie;
|
dmt->event_nr = *cookie;
|
||||||
dmt->cookie_set = 1;
|
dmt->cookie_set = 1;
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task",
|
||||||
|
dmt->event_nr, semid);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -1016,7 +1038,7 @@ int dm_udev_complete(uint32_t cookie)
|
|||||||
if (!_get_cookie_sem(cookie, &semid))
|
if (!_get_cookie_sem(cookie, &semid))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
if (!_udev_notify_sem_dec(semid)) {
|
if (!_udev_notify_sem_dec(cookie, semid)) {
|
||||||
log_error("Could not signal waiting process using notification "
|
log_error("Could not signal waiting process using notification "
|
||||||
"semaphore identified by cookie value %" PRIu32 " (0x%x)",
|
"semaphore identified by cookie value %" PRIu32 " (0x%x)",
|
||||||
cookie, cookie);
|
cookie, cookie);
|
||||||
@ -1037,15 +1059,18 @@ int dm_udev_wait(uint32_t cookie)
|
|||||||
if (!_get_cookie_sem(cookie, &semid))
|
if (!_get_cookie_sem(cookie, &semid))
|
||||||
return_0;
|
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 "
|
log_error("Failed to set a proper state for notification "
|
||||||
"semaphore identified by cookie value %" PRIu32 " (0x%x) "
|
"semaphore identified by cookie value %" PRIu32 " (0x%x) "
|
||||||
"to initialize waiting for incoming notifications.",
|
"to initialize waiting for incoming notifications.",
|
||||||
cookie, cookie);
|
cookie, cookie);
|
||||||
(void) _udev_notify_sem_destroy(semid, cookie);
|
(void) _udev_notify_sem_destroy(cookie, semid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("Udev cookie 0x%" PRIx32 " (semid %d): Waiting for zero",
|
||||||
|
cookie, semid);
|
||||||
|
|
||||||
repeat_wait:
|
repeat_wait:
|
||||||
if (semop(semid, &sb, 1) < 0) {
|
if (semop(semid, &sb, 1) < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@ -1053,11 +1078,11 @@ repeat_wait:
|
|||||||
log_error("Could not set wait state for notification semaphore "
|
log_error("Could not set wait state for notification semaphore "
|
||||||
"identified by cookie value %" PRIu32 " (0x%x): %s",
|
"identified by cookie value %" PRIu32 " (0x%x): %s",
|
||||||
cookie, cookie, strerror(errno));
|
cookie, cookie, strerror(errno));
|
||||||
(void) _udev_notify_sem_destroy(semid, cookie);
|
(void) _udev_notify_sem_destroy(cookie, semid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _udev_notify_sem_destroy(semid, cookie);
|
return _udev_notify_sem_destroy(cookie, semid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* UDEV_SYNC_SUPPORT */
|
#endif /* UDEV_SYNC_SUPPORT */
|
||||||
|
Loading…
Reference in New Issue
Block a user