On 9/24/21 9:19 PM, Jens Axboe wrote: > On 9/24/21 2:11 PM, Pavel Begunkov wrote: >> On 9/24/21 9:06 PM, Jens Axboe wrote: >>> On 9/24/21 1:57 PM, Jens Axboe wrote: >>>> On 9/24/21 1:04 PM, Pavel Begunkov wrote: >>>>> From recently open/accept are now able to manipulate fixed file table, >>>>> but it's inconsistent that close can't. Close the gap, keep API same as >>>>> with open/accept, i.e. via sqe->file_slot. >>>> >>>> I really think we should do this for 5.15 to make the API a bit more >>>> sane from the user point of view, folks definitely expect being able >>>> to use IORING_OP_CLOSE with a fixed file that they got with IORING_OP_OPEN, >>>> for example. >>>> >>>> How about this small tweak, basically making it follow the same rules >>>> as other commands that do fixed files: >>>> >>>> 1) Require IOSQE_FIXED_FILE to be set for a direct close. sqe->file_index >>>> will be the descriptor to close in that case. If sqe->fd is set, we >>>> -EINVAL the request. >>>> >>>> 2) If IOSQE_FIXED_FILE isn't set, it's a normal close. As before, if >>>> sqe->file_index is set and IOSQE_FIXED_FILE isn't, then we -EINVAL >>>> the request. >>>> >>>> Basically this incremental on top of yours. >>> >>> Hmm, we don't require that for open or accept. Why not? Seems a bit >>> counter intuitive. But maybe it's better we do this one as-is, and then >> >> Accept takes a fd as an argument and so IOSQE_FIXED_FILE already applies >> to it and can't be used as described. Close is just made consistent with >> the rest. > > What I'm saying is why don't we make IOSQE_FIXED_FILE for open/accept > consistent as well? The flag is already used for accept but for a different purpose [IORING_OP_ACCEPT] = { .needs_file = 1, if (io_op_defs[req->opcode].needs_file) { req->file = io_file_get(ctx, req, READ_ONCE(sqe->fd), (sqe_flags & IOSQE_FIXED_FILE)); -- Pavel Begunkov