Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4062693iog; Tue, 28 Jun 2022 08:15:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ugKAJNtNk+iHfOuueroiZhaXOz36pKIxIPJulEZvtVI+JhrUdqXCpIZ0vnjQnaTrYW9OyT X-Received: by 2002:a17:903:300d:b0:16a:b0c:333 with SMTP id o13-20020a170903300d00b0016a0b0c0333mr5215629pla.26.1656429339239; Tue, 28 Jun 2022 08:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656429339; cv=none; d=google.com; s=arc-20160816; b=JJzlcEN4Xzv3UMA91nY0JPDk7/WxjzGh867dNlQ0vA6sIMdL7ZRqFY7QDrYdASI8Bm dd/tHe58iJl3XckN5pm4+8U0rBTLC7pAtr3KI7nx7sr1ACYqw1b2IJe7WhxJDzB6xLYb j7BNtvhUQMUTx0geiNnVSbBFEr+52eHzzpKJ68r3BRc9/m954McSKOEqHH0O7451gr8y CUe7CdpDS8tz2pkNMCK2TaU6outlIGFwbGeUwRkWzEdjx1Fr59p3xhg+jTJ470p9lS/s pFqs3smtSG45dVgYQXD88E1icXflnS/w/LsDVlDyD5pdtWrDjNlJLKjicFLUh9ZzsIEb PUeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=htEEzCcE4766+UwdC1leFCQGb+BeCyqpCEFz/0YnVKE=; b=WSRe/8C/FDr3BT0z5MgEqdVOyO1UTfUBR6/XdRD1cKIDlAg0+XPDRpAJAk8EhGw1LT b1cKI1K6SxU+WC+zs6AdM0Gu9Y8W0nqfkYfJMobsAFs79BRW97WQmiJgi+vDMszMfBQF fSB7UdjZNZkwSAIWBkUc5oL4TaQjr0X4vgyTi7OVFbnwhkbaWnHGbeQ/0X1/RGbBsd+D vg2Fjhpd8l62AcDXB1MuC0He0vfb8+fzVztWJJSrasJwVOlIRyeQw9i+H/ORyNuyiNbe oVjpy9aBQpY91lmVyzPQgJiV3vs950JMNVfcSaTNtHqiL3GtezBlPGiZkpYIua8bODQE 1lig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=CDx4QR6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056a000b4400b00506475da4desi10755238pfo.151.2022.06.28.08.15.21; Tue, 28 Jun 2022 08:15:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=CDx4QR6e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347680AbiF1PCv (ORCPT + 99 others); Tue, 28 Jun 2022 11:02:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347670AbiF1PCr (ORCPT ); Tue, 28 Jun 2022 11:02:47 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7094E33E3C for ; Tue, 28 Jun 2022 08:02:47 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SAE7ZG013208 for ; Tue, 28 Jun 2022 08:02:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=htEEzCcE4766+UwdC1leFCQGb+BeCyqpCEFz/0YnVKE=; b=CDx4QR6emayqwiddP+de7/TmBe6lA0yOj4AW7JjXjypzFlQGOZkBWukq8CeAJfeeSDnV iB4hdJZUxAqklfngOqnBVYpD/FrvUAWgZ7HaBFEghtP63VmUHqhHTWx8nbStHBj7tMNY +SiHDFqyRbMRwnMDXLZokCDJqqcsprMTpT4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3gyxx31y7r-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 28 Jun 2022 08:02:47 -0700 Received: from twshared25107.07.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 28 Jun 2022 08:02:45 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id EF0E8244BBD3; Tue, 28 Jun 2022 08:02:37 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken Subject: [PATCH for-next 4/8] io_uring: recycle buffers on error Date: Tue, 28 Jun 2022 08:02:24 -0700 Message-ID: <20220628150228.1379645-5-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220628150228.1379645-1-dylany@fb.com> References: <20220628150228.1379645-1-dylany@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: HeckgzlDznf4h7Kc37CQmZxyi2t16Ykx X-Proofpoint-ORIG-GUID: HeckgzlDznf4h7Kc37CQmZxyi2t16Ykx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-28_08,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rather than passing an error back to the user with a buffer attached, recycle the buffer immediately. Signed-off-by: Dylan Yudaken --- io_uring/net.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index 5e84f7ab92a3..0268c4603f5d 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -481,10 +481,13 @@ int io_recvmsg(struct io_kiocb *req, unsigned int i= ssue_flags) if (kmsg->free_iov) kfree(kmsg->free_iov); req->flags &=3D ~REQ_F_NEED_CLEANUP; - if (ret >=3D 0) + if (ret > 0) ret +=3D sr->done_io; else if (sr->done_io) ret =3D sr->done_io; + else + io_kbuf_recycle(req, issue_flags); + cflags =3D io_put_kbuf(req, issue_flags); if (kmsg->msg.msg_inq) cflags |=3D IORING_CQE_F_SOCK_NONEMPTY; @@ -557,10 +560,13 @@ int io_recv(struct io_kiocb *req, unsigned int issu= e_flags) req_set_fail(req); } =20 - if (ret >=3D 0) + if (ret > 0) ret +=3D sr->done_io; else if (sr->done_io) ret =3D sr->done_io; + else + io_kbuf_recycle(req, issue_flags); + cflags =3D io_put_kbuf(req, issue_flags); if (msg.msg_inq) cflags |=3D IORING_CQE_F_SOCK_NONEMPTY; --=20 2.30.2