Factor in IORING_FILE_INDEX_ALLOC for direct fd instantiations

We document that various helpers can use this specific direct fd offset
to get a direct descriptor allocated, but a few of the helpers then don't
factor that in and will add one to the offset as we need to do for setting
a specific index. This obviously makes these fail, most notably it can
make the kernel thing that we're not using a direct descriptor at all.

Fix this up, so that any _direct() helper does check for this specific
magic offset and decrement it by one upfront so that
__io_uring_set_target_fixed_file() does the right thing.

Link: https://github.com/axboe/liburing/issues/840
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2 files changed