Re: [PATCH] fio_sem, diskutil: introduce fio_shared_sem and use it for diskutil lock
Jens Axboe <[email protected]>
| Newsgroups | org.kernel.vger.fio |
|---|---|
| Message-ID | <[email protected]> |
On 5/11/25 7:30 PM, Shin'ichiro Kawasaki wrote:
> diff --git a/fio_shared_sem.c b/fio_shared_sem.c
> new file mode 100644
> index 00000000..95e07400
> --- /dev/null
> +++ b/fio_shared_sem.c
> @@ -0,0 +1,44 @@
> +/*
> + * Separate out the two helper functions for fio_sem from "fio_sem.c".
> + * These two functions depend on fio shared memory. Other fio_sem
> + * functions in "fio_sem.c" are used for fio shared memory. This file
> + * separation is required to avoid build failures caused by circular
> + * dependency.
> + */
> +
> +#include <stdio.h>
> +
> +#include "fio_sem.h"
> +#include "smalloc.h"
> +
> +/*
> + * Allocate and initialize fio_sem lock object in the same manner as
> + * fio_sem_init(), except the lock object is allocated from the fio
> + * shared memory. This allows the parent process to free the lock
> + * allocated by child processes.
> + */
> +struct fio_sem *fio_shared_sem_init(int value)
> +{
> + struct fio_sem *sem = NULL;
Pointless initialization, you overwrite it right after.
> + sem = smalloc(sizeof(struct fio_sem));
> + if (!sem) {
> + perror("fio: smalloc for semaphore failed");
> + return NULL;
> + }
smalloc() doesn't set errno, and logs an error separately.
--
Jens Axboe