Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The return value of tgt_ops->handle_io_async is never checked #81

Closed
mattysweeps opened this issue Jan 22, 2025 · 2 comments · Fixed by #85
Closed

The return value of tgt_ops->handle_io_async is never checked #81

mattysweeps opened this issue Jan 22, 2025 · 2 comments · Fixed by #85

Comments

@mattysweeps
Copy link
Contributor

lib/ublksrv.c invokes q->tgt_ops->handle_io_async(local_to_tq(q), &io->data); but never checks the return value of handle_io_async. Looking at the code, this is the only place where handle_io_async is invoked.

The function returns an int, which could be used as a signal that target failed to submit the IO asynchronously. I'm not sure what the library should do in this case, but I think the library should do something.

@ming1
Copy link
Collaborator

ming1 commented Jan 23, 2025

Good catch.

I think it should be fine/enough to define its return value as 'void', and the similar one could be submit_bio() in linux kernel. The benefit is one simpler
interface. Then we can just add one warn or assert() in case of non-zero return
value of ->handle_io_async()?

What do you think of this way?

Another way is to fail the current command in case of non-zero return value,
but looks it is not flexible as the above style.

@mattysweeps
Copy link
Contributor Author

mattysweeps commented Jan 24, 2025

I think returning void is acceptable and the option I prefer.

At first I thought the return code could be used by libublksrv to automatically call ->ublksrv_complete_io with an error result, but why not make this the responsibility of ->handle_io_async? (which is the case today). Besides, a buggy ->handle_io_async implementation could still return 0 when it shouldn't and drop an IO request. Better to document the contract that the target MUST call ->ublksrv_complete_io, even if an error occurs, for each invocation of ->handle_io_async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants