From patchwork Wed Oct 19 08:21:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp201976wrs; Wed, 19 Oct 2022 01:39:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GCGtGUw5Hdm3VkLYOfb9wg+PLeIiDh0noIx+UaddxKKPES8jzlIStQcClstpPmP4QhiqV X-Received: by 2002:a05:6402:b35:b0:45c:9c9d:2531 with SMTP id bo21-20020a0564020b3500b0045c9c9d2531mr6301814edb.410.1666168773008; Wed, 19 Oct 2022 01:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168773; cv=none; d=google.com; s=arc-20160816; b=IJYHYjFrn5NGoLjjUX77HjN0WQTLQh9Ja8Wx1zA5ll3GB+wLOY3NaQmnOCIUagHPLu aunZsGqBLL8LZAxuxC2esD97LBMs8YanY1Nh8OvBKx2KocWErZSIsl6fX1ZZsqBxmUCz LYjAh3lfaoQfy6eox7apSEmkTTD+QHyyp7RvN3YCQf47pEPMDq7qD0sBV2vQK5Q3MqMs 3zxZeMPZx/TQebYrt8gm8qar0juhQa3Y4G1lIGJg/XYNe/UlD5pJt86Gg5mfeKQuHBG7 NZkKtW2UY/l2h4hN4TxgqMs+vI6crPuL05urnrMlPVwGdcHf636XJTxEIJoE3kzfdwmJ Gn1g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yepoTGFW+of18CPBRdBJWn4GprzW71TYTbduBxG80sY=; b=U/t3Gz1w0mTrSp0DDNowOmYPTnv87+Vnj+N3ydZKAHoFV1L/68wuoJ8fhb3mLk99I6 JRVjcw3MkSQI4nRuCYR5iIiI8kMbTC7S7Kei9jAugqYt1yV3i5wBdkW8rQTC2oO1h1HJ lyy++nYiHKqr3i03DutFVknMBCwobJ7O6oQyB8FgJA15ElsOfKrG81O+UrdtArCMn2FL sMJQmntAHzcwD3tEawF02c6dOD1jCfj0zi0gyrLgVVox0SoPn51MVj6/8FSjJ9istNe1 7wWEICmHMLYIbeH2G6mVO1wiWuYJTXikp8Ygv9PdTjEyckQpQNJIvssaonl/jd07fEix W5FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wev42oRa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh37-20020a1709076ea500b0078d9d69ae0dsi14174687ejc.877.2022.10.19.01.39.07; Wed, 19 Oct 2022 01:39:32 -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=@linuxfoundation.org header.s=korg header.b=Wev42oRa; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiJSIil (ORCPT + 99 others); Wed, 19 Oct 2022 04:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbiJSIi3 (ORCPT ); Wed, 19 Oct 2022 04:38:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E052804A7; Wed, 19 Oct 2022 01:37:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 00B0DB822BC; Wed, 19 Oct 2022 08:37:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55B53C433D6; Wed, 19 Oct 2022 08:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168663; bh=xKUNb8xzWoGBdw3o8dM2lLi+Z8ucdUJntJX38Phs4e0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wev42oRaZV10GbsOZSM6QT7fG6QBfdEjQ6miniL0m8YX4AWXXn6H44anv/eRAMhp+ oSfAgTXPytgi2edYRy+3NgWImG8WrMAE40KNgD562iFr/RpHh8ywX6zGjwT5POyOqs rASW2N/zRoVUMHOiCZVq6RVj9Pp6fB57DGZQ5dyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.0 014/862] io_uring/rw: dont lose short results on io_setup_async_rw() Date: Wed, 19 Oct 2022 10:21:41 +0200 Message-Id: <20221019083250.634664654@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104587435749124?= X-GMAIL-MSGID: =?utf-8?q?1747104587435749124?= From: Pavel Begunkov commit c278d9f8ac0db5590909e6d9e85b5ca2b786704f upstream. If a retry io_setup_async_rw() fails we lose result from the first io_iter_do_read(), which is a problem mostly for streams/sockets. Cc: stable@vger.kernel.org Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/0e8d20cebe5fc9c96ed268463c394237daabc384.1664235732.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/rw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -794,10 +794,12 @@ int io_read(struct io_kiocb *req, unsign iov_iter_restore(&s->iter, &s->iter_state); ret2 = io_setup_async_rw(req, iovec, s, true); - if (ret2) - return ret2; - iovec = NULL; + if (ret2) { + ret = ret > 0 ? ret : ret2; + goto done; + } + io = req->async_data; s = &io->s; /*