Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp555974imi; Thu, 21 Jul 2022 06:36:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ta574vr/prz9Vyxk56CYu4QQmUEyd5SBPKZHT61lz21NuvZR54JawB8ESOcPA+dESxHO0q X-Received: by 2002:a05:6402:50d4:b0:43a:d2a9:29ad with SMTP id h20-20020a05640250d400b0043ad2a929admr58600339edb.336.1658410562633; Thu, 21 Jul 2022 06:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658410562; cv=none; d=google.com; s=arc-20160816; b=xRWFSenVJm2fLLDMryC0/33yfjeAmJ8pekYJ7y3oiPldai7gbnZwXrIbpCGBga5XZj Pk8uCeLcE0uurwDz1A6gUd2DjESBoS1eRCM3Dg5pfRicKWbkDxy0LM0l1PZDCaIu9tBR nY9jQ0HzlXmqof1b5LmUghEFgH873akVlcEWBEC70wSIQvbu+o3U2pv2458tZxokw9iw eRUpz2/s/Hf2v4N16yVKIFthT+7sxsrZgBAh3uKt3izhlQ6TWhrtHAVDUVZF2oY5AjhL DLXG761FWITBWuhDQpl5xow7SfG339zuwvhnZzU33b4Fe4AJUVVnTn+vCTv/BmN31ebH LGBA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=1UTwILVniiw7ynXES8Bhzxf+egvso18YKqvJaTMOLow=; b=kgKn516r2KkfywCXFfrtM6z4j/ZxSJfv5MxuqfTrQ14ssGH3AY2FYu7spRRQW5FGc8 oOrYe7NCvTmp7RTUkQlZ3EiDcy9t5hHK2s+Yzd4PtF1Cb01I+3OXWLMpAa9605ESidFj 8jE/IoH5d5Z6EWkEfeSW8fYFuScDkFQ8f7aPu8NFU4UYYvT7zIMb8wAlqw3o1KuIR9pE iwnpn1ab7CBT1QeoIoAujZ6TGOSfiqkVpXTMfeUQPurJ7yZRO0I6qvs6V0zujJvHnq30 OyOyJnbdIxjk2iGpz2kudVUMu9qKEjpflk8S7ldVZsdaJodQu+QyTjq4dRDZ4qzcSwA+ 1j+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=dMLjrMg2; 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 dx15-20020a170906a84f00b0072b53b3f4c5si2133828ejb.217.2022.07.21.06.35.36; Thu, 21 Jul 2022 06:36:02 -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=dMLjrMg2; 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 S234085AbiGUNOG (ORCPT + 99 others); Thu, 21 Jul 2022 09:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233615AbiGUNOF (ORCPT ); Thu, 21 Jul 2022 09:14:05 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B63308 for ; Thu, 21 Jul 2022 06:14:04 -0700 (PDT) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26LDBwJ1007075 for ; Thu, 21 Jul 2022 06:14:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=facebook; bh=1UTwILVniiw7ynXES8Bhzxf+egvso18YKqvJaTMOLow=; b=dMLjrMg2GDYAfjlv6i8dJmT13peB2U9OIJDx/wgs2PcgAhsZ+600V6aFv8pr+gtmzOEB B2dWz2DdNm5xpoxpPajAKhaJ0IEsEinqlLcl4pmXj7S79OsQzjtIivPn8iPRoWm26Qj2 12/cHUsnfKj2t3iENpuoM0LhXto/18IJSqA= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hf7fbr0eq-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 21 Jul 2022 06:14:03 -0700 Received: from twshared5640.09.ash9.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 21 Jul 2022 06:13:33 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 6F7E63586F52; Thu, 21 Jul 2022 06:13:30 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken , Ammar Faizi Subject: [PATCH] io_uring: do not recycle buffer in READV Date: Thu, 21 Jul 2022 06:13:25 -0700 Message-ID: <20220721131325.624788-1-dylany@fb.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: T0j2jBWSky_LeKj2wwC76yio5WwFADNn X-Proofpoint-ORIG-GUID: T0j2jBWSky_LeKj2wwC76yio5WwFADNn 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-07-21_17,2022-07-20_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 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 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 READV cannot recycle buffers as it would lose some of the data required t= o reimport that buffer. Reported-by: Ammar Faizi Fixes: b66e65f41426 ("io_uring: never call io_buffer_select() for a buffe= r re-select") Signed-off-by: Dylan Yudaken --- I think going forward we can probably re-enable recycling for READV, or p= erhaps stick it in the opdef to make it a bit more general. However since it is late i= n the merge cycle I thought the simplest approach is best. Worth noting the initial discussed approach of stashing the data in `stru= ct io_rw` would not have worked as that struct is full already apparently. Dylan fs/io_uring.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index a01ea49f3017..b0180679584f 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1737,6 +1737,14 @@ static void io_kbuf_recycle(struct io_kiocb *req, = unsigned issue_flags) (req->flags & REQ_F_PARTIAL_IO)) return; =20 + /* + * READV uses fields in `struct io_rw` (len/addr) to stash the selected + * buffer data. However if that buffer is recycled the original request + * data stored in addr is lost. Therefore forbid recycling for now. + */ + if (req->opcode =3D=3D IORING_OP_READV) + return; + /* * We don't need to recycle for REQ_F_BUFFER_RING, we can just clear * the flag and hence ensure that bl->head doesn't get incremented. base-commit: ff6992735ade75aae3e35d16b17da1008d753d28 --=20 2.30.2