From patchwork Thu Jul 21 13:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dylan Yudaken X-Patchwork-Id: 12925113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3F78C43334 for ; Thu, 21 Jul 2022 13:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbiGUNOG (ORCPT ); Thu, 21 Jul 2022 09:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233617AbiGUNOF (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 9B8BC117F 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 26LDBwJ2007075 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-4 (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:208::f) 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 X-FB-Internal: Safe X-Proofpoint-GUID: fdlO0m517F7EawuenZ9DlZqC7T_GIMvP X-Proofpoint-ORIG-GUID: fdlO0m517F7EawuenZ9DlZqC7T_GIMvP 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 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org READV cannot recycle buffers as it would lose some of the data required to reimport that buffer. Reported-by: Ammar Faizi Fixes: b66e65f41426 ("io_uring: never call io_buffer_select() for a buffer re-select") Signed-off-by: Dylan Yudaken --- I think going forward we can probably re-enable recycling for READV, or perhaps stick it in the opdef to make it a bit more general. However since it is late in the merge cycle I thought the simplest approach is best. Worth noting the initial discussed approach of stashing the data in `struct io_rw` would not have worked as that struct is full already apparently. Dylan fs/io_uring.c | 8 ++++++++ 1 file changed, 8 insertions(+) base-commit: ff6992735ade75aae3e35d16b17da1008d753d28 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; + /* + * 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 == 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.