From patchwork Wed Feb 24 20:01:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12102469 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 8EC0EC4332B for ; Wed, 24 Feb 2021 20:01:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3AB1864EC4 for ; Wed, 24 Feb 2021 20:01:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AB1864EC4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 955906B008C; Wed, 24 Feb 2021 15:01:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EF9F8D0001; Wed, 24 Feb 2021 15:01:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FB656B0093; Wed, 24 Feb 2021 15:01:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 46B596B008C for ; Wed, 24 Feb 2021 15:01:48 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 06A33185044AA for ; Wed, 24 Feb 2021 20:01:48 +0000 (UTC) X-FDA: 77854231896.15.73C1604 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf05.hostedemail.com (Postfix) with ESMTP id 89869E000106 for ; Wed, 24 Feb 2021 20:01:46 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4132D64E7A; Wed, 24 Feb 2021 20:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1614196906; bh=G/hO3Rnc1ew2BsKhMRd+zRTTHSdeEe5zj0NmD4Ixw64=; h=Date:From:To:Subject:In-Reply-To:From; b=EQYjTzH+iKQGk53pf7Zsh36awevfIq5t1FcXGf6MmQMD0ybpgBHfLFwtRl2LU4Tv0 cad4VzJnxt+ALywiAqXycpdT92itcCh7z0nBpuTS4kcXYsPNKCTfoCyPcwM/8NJ1+Z sa2p3yiTIIaoOF9G16lRd3JYtCwvfiesDWdGSdUU= Date: Wed, 24 Feb 2021 12:01:45 -0800 From: Andrew Morton To: akpm@linux-foundation.org, asml.silence@gmail.com, axboe@kernel.dk, hch@lst.de, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk Subject: [patch 029/173] mm/filemap: don't revert iter on -EIOCBQUEUED Message-ID: <20210224200145.tzDYWtTYF%akpm@linux-foundation.org> In-Reply-To: <20210224115824.1e289a6895087f10c41dd8d6@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Stat-Signature: oszq579cdm86qpbu8a1znctx7dwcnihi X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 89869E000106 Received-SPF: none (linux-foundation.org>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614196906-960447 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: From: Pavel Begunkov Subject: mm/filemap: don't revert iter on -EIOCBQUEUED 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. Link: https://lkml.kernel.org/r/f5247b60e7abbd2ff850cd108491f53a2e0c501a.1610207781.git.asml.silence@gmail.com Signed-off-by: Pavel Begunkov Reviewed-by: Christoph Hellwig Cc: Al Viro Cc: Jens Axboe Signed-off-by: Andrew Morton --- mm/filemap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/mm/filemap.c~mm-filemap-dont-revert-iter-on-eiocbqueued +++ a/mm/filemap.c @@ -2615,7 +2615,8 @@ generic_file_read_iter(struct kiocb *ioc 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 @@ -3426,7 +3427,8 @@ generic_file_direct_write(struct kiocb * } 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; }