From patchwork Sat Jan 9 16:00:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Begunkov X-Patchwork-Id: 12008435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A26BCC433E0 for ; Sat, 9 Jan 2021 16:04:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A55A23A58 for ; Sat, 9 Jan 2021 16:04:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A55A23A58 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C9B58D0007; Sat, 9 Jan 2021 11:04:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 379E98D0002; Sat, 9 Jan 2021 11:04:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21B258D0007; Sat, 9 Jan 2021 11:04:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0177.hostedemail.com [216.40.44.177]) by kanga.kvack.org (Postfix) with ESMTP id 0D4298D0002 for ; Sat, 9 Jan 2021 11:04:15 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C67ED4405 for ; Sat, 9 Jan 2021 16:04:14 +0000 (UTC) X-FDA: 77686708428.07.note98_5212244274fc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id AE7B01803F9B8 for ; Sat, 9 Jan 2021 16:04:14 +0000 (UTC) X-HE-Tag: note98_5212244274fc X-Filterd-Recvd-Size: 3952 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 Jan 2021 16:04:14 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id q75so11030629wme.2 for ; Sat, 09 Jan 2021 08:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4nXYxX9dbuWurmEc3HolnGHKsTnFoJzI5tkjJRNoql4=; b=QJ7SpezQUEwTiGipFEoNbCI2yi0aUPB+zDKB21I11Chcdr+lDmxoAYU4V4bAN0mWUv BVo89nY8B65l97+4OtJUpZQaNj4tnE+nLqWOI/Ndgxpev+XT6UklG97DEunraVHCbLg0 yNmd0Fj1VkkitF0FuBAoSsvGkkRkJxObh4LKmuzBBpbtsAm0Af0gdY63nRJ2IDqZDUg1 pVkDoiqKTe5mfDkgZdVIgcOXsEN+HgqYSbv0CsVz0auRnBlN/L7WwFmKJa6ATwIusLU0 M96hVz7Wa9RXpxTOMWQvdlepLTjlTSgdZnA5OBVRy/WiebLYLgPFaa8mxz+8Y4m4HF0u /t1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4nXYxX9dbuWurmEc3HolnGHKsTnFoJzI5tkjJRNoql4=; b=Vp67gZcsuwU+kCVe1QCJf8yVFdvVlNLDfoOkwrLNZKjvq+6X2N1kEiZasg0fV1MVHS J9n7l17FsTKtsxFf7GJxg5fkQbvAdyjn1oyMwSyIhQ3mvK8nSu8s3bgjhkH5gmVn0Q6I RImreG5tena0E6FXKcrEkf+pMV5otcKWQf5i7G4qI+pIlAxAtp6uYDCUV1C55UyyVHf9 g++DCja13I6/PnskOflSLWboHcOAzScVQcvrLwgjvy3hP4rLlvcHkpd/js5PQWKHJmLX Q+mSR/uQS8KnSNIjHHhYQIizeMAtwE9ejl/QqxRXGxf6lmpew/z1jz+izv+qF0h/zG2S 7luw== X-Gm-Message-State: AOAM532H9YbrBvxAoxOr5Lj8liewVjggd18FPyD2E3C9nLouqcqxd1h3 eZIYwEc2iFCKCwFLCZ3q6bY= X-Google-Smtp-Source: ABdhPJwfIMXxMAe3BSP/M2ADL9lwDIXmQZa4+CHcS1FIt4LSKjy9Aveek7QmF0zZTW3SsdT6SkqsMw== X-Received: by 2002:a1c:7f8c:: with SMTP id a134mr7810978wmd.184.1610208253005; Sat, 09 Jan 2021 08:04:13 -0800 (PST) Received: from localhost.localdomain ([185.69.144.125]) by smtp.gmail.com with ESMTPSA id k1sm17766623wrn.46.2021.01.09.08.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Jan 2021 08:04:12 -0800 (PST) From: Pavel Begunkov To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] mm/filemap: don't revert iter on -EIOCBQUEUED Date: Sat, 9 Jan 2021 16:00:32 +0000 Message-Id: X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently, if I/O is enqueued for async execution direct paths of generic_file_{read,write}_iter() will always revert the iter. There are no users expecting that, and that is also costly. Leave iterators as is on -EIOCBQUEUED. Signed-off-by: Pavel Begunkov Reviewed-by: Christoph Hellwig --- mm/filemap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 5bc672d30143..2e1686e09425 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2633,7 +2633,8 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) iocb->ki_pos += retval; count -= retval; } - iov_iter_revert(iter, count - iov_iter_count(iter)); + if (retval != -EIOCBQUEUED) + iov_iter_revert(iter, count - iov_iter_count(iter)); /* * Btrfs can have a short DIO read if we encounter @@ -3458,7 +3459,8 @@ generic_file_direct_write(struct kiocb *iocb, struct iov_iter *from) } iocb->ki_pos = pos; } - iov_iter_revert(from, write_len - iov_iter_count(from)); + if (written != -EIOCBQUEUED) + iov_iter_revert(from, write_len - iov_iter_count(from)); out: return written; }