mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
deal with error-related FIXMEs
This commit is contained in:
parent
b42929dca7
commit
b59c9854e8
@ -818,7 +818,13 @@ int dm_udev_get_sync_support(void)
|
|||||||
|
|
||||||
static int _get_cookie_sem(uint32_t cookie, int *semid)
|
static int _get_cookie_sem(uint32_t cookie, int *semid)
|
||||||
{
|
{
|
||||||
/* FIXME Ensure cookie has COOKIE_MAGIC prefix */
|
if (!(cookie >> 16 & COOKIE_MAGIC)) {
|
||||||
|
log_error("Could not continue to access notification "
|
||||||
|
"semaphore identified by cookie value %"
|
||||||
|
PRIu32 " (0x%x). Incorrect cookie prefix.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((*semid = semget((key_t) cookie, 1, 0)) >= 0)
|
if ((*semid = semget((key_t) cookie, 1, 0)) >= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -836,11 +842,10 @@ static int _get_cookie_sem(uint32_t cookie, int *semid)
|
|||||||
cookie, cookie);
|
cookie, cookie);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* FIXME errno use missing */
|
|
||||||
log_error("Failed to access notification "
|
log_error("Failed to access notification "
|
||||||
"semaphore identified by cookie "
|
"semaphore identified by cookie "
|
||||||
"value %" PRIu32 " (0x%x)",
|
"value %" PRIu32 " (0x%x): %s",
|
||||||
cookie, cookie);
|
cookie, cookie, strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,26 +856,42 @@ static int _udev_notify_sem_inc(int semid)
|
|||||||
{
|
{
|
||||||
struct sembuf sb = {0, 1, 0};
|
struct sembuf sb = {0, 1, 0};
|
||||||
|
|
||||||
/* FIXME errno use missing */
|
if (semop(semid, &sb, 1) < 0) {
|
||||||
return semop(semid, &sb, 1) == 0;
|
log_error("semid %d: semop failed: %s", semid, strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _udev_notify_sem_dec(int semid)
|
static int _udev_notify_sem_dec(int semid)
|
||||||
{
|
{
|
||||||
/* FIXME Think we should have IPC_NOWAIT here in case something went wrong and it's already 0 */
|
struct sembuf sb = {0, -1, IPC_NOWAIT};
|
||||||
struct sembuf sb = {0, -1, 0};
|
|
||||||
|
|
||||||
/* FIXME errno use missing */
|
if (semop(semid, &sb, 1) < 0) {
|
||||||
return semop(semid, &sb, 1) == 0;
|
switch (errno) {
|
||||||
|
case EAGAIN:
|
||||||
|
log_error("semid %d: semop failed: "
|
||||||
|
"incorrect semaphore state",
|
||||||
|
semid);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_error("semid %d: semop failed: %s",
|
||||||
|
semid, strerror(errno));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
|
static int _udev_notify_sem_destroy(int semid, uint32_t cookie)
|
||||||
{
|
{
|
||||||
/* FIXME errno use missing */
|
|
||||||
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 "
|
||||||
"identified by cookie value %" PRIu32 " (0x%x)",
|
"identified by cookie value %" PRIu32 " (0x%x): %s",
|
||||||
cookie, cookie);
|
cookie, cookie, strerror(errno));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,22 +935,21 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
|
|||||||
"notification semaphore");
|
"notification semaphore");
|
||||||
goto bad;
|
goto bad;
|
||||||
case ENOSPC:
|
case ENOSPC:
|
||||||
/* FIXME Suggest what to check & do */
|
|
||||||
log_error("Limit for the maximum number "
|
log_error("Limit for the maximum number "
|
||||||
"of semaphores reached");
|
"of semaphores reached. You can "
|
||||||
|
"check and set the limits in "
|
||||||
|
"/proc/sys/kernel/sem.");
|
||||||
goto bad;
|
goto bad;
|
||||||
default:
|
default:
|
||||||
/* FIXME Use errno */
|
log_error("Failed to create notification "
|
||||||
log_error("Failed to create "
|
"semaphore: %s", strerror(errno));
|
||||||
"notification semaphore");
|
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!base_cookie);
|
} while (!base_cookie);
|
||||||
|
|
||||||
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
|
if (semctl(gen_semid, 0, SETVAL, 1) < 0) {
|
||||||
/* FIXME Use errno and give gen_semid */
|
log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
|
||||||
log_error("Failed to initialize notification semaphore");
|
|
||||||
/* 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. */
|
||||||
_udev_notify_sem_destroy(gen_semid, gen_cookie);
|
_udev_notify_sem_destroy(gen_semid, gen_cookie);
|
||||||
@ -1027,10 +1047,9 @@ repeat_wait:
|
|||||||
if (semop(semid, &sb, 1) < 0) {
|
if (semop(semid, &sb, 1) < 0) {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
goto repeat_wait;
|
goto repeat_wait;
|
||||||
/* FIXME missing errno use */
|
|
||||||
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)",
|
"identified by cookie value %" PRIu32 " (0x%x): %s",
|
||||||
cookie, cookie);
|
cookie, cookie, strerror(errno));
|
||||||
_udev_notify_sem_destroy(semid, cookie);
|
_udev_notify_sem_destroy(semid, cookie);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user