Re: [PATCH 01/17] io_uring/net: switch io_send() and io_send_zc() to using io_async_msghdr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/6/24 2:58 PM, Pavel Begunkov wrote:
> On 3/20/24 22:55, Jens Axboe wrote:
>> No functional changes in this patch, just in preparation for carrying
>> more state then we have now, if necessary. While unifying some of this
>> code, add a generic send setup prep handler that they can both use.
>>
>> This gets rid of some manual msghdr and sockaddr on the stack, and makes
>> it look a bit more like the sendmsg/recvmsg variants. We can probably
>> unify a bit more on top of this going forward.
>>
>> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
>> ---
>>   io_uring/net.c   | 196 ++++++++++++++++++++++++-----------------------
>>   io_uring/opdef.c |   1 +
>>   2 files changed, 103 insertions(+), 94 deletions(-)
>>
>> diff --git a/io_uring/net.c b/io_uring/net.c
>> index ed798e185bbf..a16838c0c837 100644
>> --- a/io_uring/net.c
>> +++ b/io_uring/net.c
>> @@ -322,36 +322,25 @@ static int io_sendmsg_copy_hdr(struct io_kiocb *req,
>>  
> ...
>> -int io_send(struct io_kiocb *req, unsigned int issue_flags)
>> +static struct io_async_msghdr *io_send_setup(struct io_kiocb *req,
>> +                         struct io_async_msghdr *stack_msg,
>> +                         unsigned int issue_flags)
>>   {
>> -    struct sockaddr_storage __address;
>>       struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
>> -    struct msghdr msg;
>> -    struct socket *sock;
>> -    unsigned flags;
>> -    int min_ret = 0;
>> +    struct io_async_msghdr *kmsg;
>>       int ret;
>>   -    msg.msg_name = NULL;
>> -    msg.msg_control = NULL;
>> -    msg.msg_controllen = 0;
>> -    msg.msg_namelen = 0;
>> -    msg.msg_ubuf = NULL;
>> -
>> -    if (sr->addr) {
>> -        if (req_has_async_data(req)) {
>> -            struct io_async_msghdr *io = req->async_data;
>> -
>> -            msg.msg_name = &io->addr;
>> -        } else {
>> -            ret = move_addr_to_kernel(sr->addr, sr->addr_len, &__address);
>> +    if (req_has_async_data(req)) {
>> +        kmsg = req->async_data;
>> +    } else {
>> +        kmsg = stack_msg;
>> +        kmsg->free_iov = NULL;
>> +        kmsg->msg.msg_name = NULL;
>> +        kmsg->msg.msg_namelen = 0;
>> +        kmsg->msg.msg_control = NULL;
>> +        kmsg->msg.msg_controllen = 0;
>> +        kmsg->msg.msg_ubuf = NULL;
>> +
>> +        if (sr->addr) {
>> +            ret = move_addr_to_kernel(sr->addr, sr->addr_len,
>> +                          &kmsg->addr);
>>               if (unlikely(ret < 0))
>> -                return ret;
>> -            msg.msg_name = (struct sockaddr *)&__address;
>> +                return ERR_PTR(ret);
>> +            kmsg->msg.msg_name = &kmsg->addr;
>> +            kmsg->msg.msg_namelen = sr->addr_len;
>> +        }
>> +
>> +        if (!io_do_buffer_select(req)) {
> 
> it seems, this chunk leaked from another series as well. fwiw,
> it was moved in a later commit
> "io_uring/net: get rid of ->prep_async() for send side"

Thanks, yeah I think so too. Will fix, thanks!

-- 
Jens Axboe





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux