Re: Possible io_uring related race leads to btrfs data csum mismatch

Matthew Wilcox
2023-08-20T18:22:19Z

On Sun, Aug 20, 2023 at 08:11:04AM -0600, Jens Axboe wrote:
> +static int io_get_single_event(struct io_event *event)
> +{
> + int ret;
> +
> + do {
> + /*
> + * We can get -EINTR if competing with io_uring using signal
> + * based notifications. For that case, just retry the wait.
> + */
> + ret = io_getevents(io_ctx, 1, 1, event, NULL);
> + if (ret != -EINTR)
> + break;
> + } while (1);
> +
> + return ret;
> +}

Is there a reason to prefer this style over:

do {
ret = io_getevents(io_ctx, 1, 1, event, NULL);
} while (ret == -1 && errno == EINTR);

(we need to check errno, here, right? Or is io_getevents() special
somehow?)