From patchwork Mon Jul 29 16:19:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13745299 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3279C3DA61 for ; Mon, 29 Jul 2024 16:22:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8340E6B00AE; Mon, 29 Jul 2024 12:22:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E3F66B00B0; Mon, 29 Jul 2024 12:22:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65EA26B00B1; Mon, 29 Jul 2024 12:22:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 45FB16B00AE for ; Mon, 29 Jul 2024 12:22:18 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0ADE41603EF for ; Mon, 29 Jul 2024 16:22:18 +0000 (UTC) X-FDA: 82393307556.21.D8C321D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 42B70140023 for ; Mon, 29 Jul 2024 16:22:16 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LXuEayF5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722270096; a=rsa-sha256; cv=none; b=nsa9S7Kb7C6t8TjGYxiSqd4h2kg42Gc0ift611Shkc0eDK9cxeV6eQzWYCPPKBltL1fdMB uJuR7hhJoyI4xtFrcUloocRlBnT4LICUThVRrSyLOq2Bi2jTMJx5poAomLzhnxRZ7LsQG7 c+ZC4mY7yizTdALUuI8ZFBsFsPSJdxQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LXuEayF5; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722270096; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BEg00OpRQajVHUnNP+IlkJUc9WaKog3YPTamcSjZGjQ=; b=edIVDpYdna3rs96tLgsk45+tpoRYOIISJgKoxWo9QH61kajvTX67isNm8bTO1x2NUX4vCX IsUlNHrwzBwigrOe6iZYV3KnZJpGJ8Uxny31+zdUU6iz2PbyGpbgA4qkHI2hXLFUqblnnj pc+jF3krGi/e0olGh4CfZBlb8uso+ys= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722270135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BEg00OpRQajVHUnNP+IlkJUc9WaKog3YPTamcSjZGjQ=; b=LXuEayF5pnc3L/93rQ3b/l32/chOSfFdsM45egI6+q+sR15fIL6+brKl7XcBn8GveLnbgN 3P6J0COoM001mESaFgYIZZ7X7L0aVpmoUFraklLfP15IIKeMWTPgaV4WWNk2yZBaVavznM n7P2TItGPlIHFXDrMRTk5xu9cunDcsc= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-ds710c1LMjSgj0Ce6FlwDA-1; Mon, 29 Jul 2024 12:22:09 -0400 X-MC-Unique: ds710c1LMjSgj0Ce6FlwDA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 48C2B1955BFE; Mon, 29 Jul 2024 16:22:06 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.216]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B55D7300018D; Mon, 29 Jul 2024 16:22:00 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/24] netfs: Provide an iterator-reset function Date: Mon, 29 Jul 2024 17:19:44 +0100 Message-ID: <20240729162002.3436763-16-dhowells@redhat.com> In-Reply-To: <20240729162002.3436763-1-dhowells@redhat.com> References: <20240729162002.3436763-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Queue-Id: 42B70140023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kw3zheqtdqgc5c6oxzrenoujq36rzo5r X-HE-Tag: 1722270136-914013 X-HE-Meta: U2FsdGVkX18te7Lf4O2qVSZ81mHnYsNnP7YFqpj+6I4GUemUa+dok5i3NnaGVCDpJK0OT5pieXWs1mTwmX0ZUbwCKeHV9YzGzISCakTHUhW/+6aJ4JSdqoOOkU4cK2tZLH+L0bAuadEKBA0bpkAui7eXL5Kkne76n4JnRM1zK/awZDcWRe3ezHDJPWWwXE96r3/rCSQcIpHfyGe3NAvZF+SPtDKGQ6kWHbOobRtieGA8PVuhQnNhKbNauwSR0ftD+wOkb5N2PBB4RlD2MOC8/QzswUn99SZC0FY0BrJctVssR32gyiH4H8KlZZy7DGNEpR2lnVfsNRkdsFjt8xk1iYgub7MmjDIGSUXjbm1w/zB0nESLXohiX3fVfsHuIPoDe6UQrNfNjxyEB6OI1Y9QcGkZ9ZvrObboB7mKB7vCE2Us7wq95B2zNhcqMZ+qfjPjntLKD40W6iUfRxgBQ2dhB4vpjoYGvSp8C9Hjipvg9bwr9ejM3+honqRuzzjomY8ksjP6XRKBVRgqr4KhZ4IXA8av1gYIbuTylUwKkYa1g03nkgiLxh9TbqKgkwNovSBOUB6lNYGZqqf3Lu/fxdFQEcaYAQfrWWgrIFCb2bq/E9PE9ljCiC8c0Tcdi6duVSZ4flUqcK8OyYssGqW1O8qxPO1UGZ7+eYi5OO7XNES8ZzjHvV1PTPDQh5SVi/JmGPI49YHfzfGZ1UXSFDsWNygwfDOJyIEZ8J1sn1J/+D3CbKd/pZObAiW2IlaPtYLyP1JwYVcJDmy7KX788wCTvA3fumY4tE1SIj6qqQFY7+fZ+ZDRDLJnM3r/wVP6LS+6c/xuQffTIIDN/sXNb8F5LmwZ2rnxYUMQIPsEu7P+QkGVwojF+AfFj3+H90cEPF+2X/dO/0m0iYdg792p7ZPtP4Wl1jQZ5m3SPrhyd9ixh9WbAtp4zKJ/24eWfR2MFgKKl88F/2XQg6/rbrffmj71Yq5 TIGHJzr7 SaPC/z3P0A06t6/wZ8KNj3wZsSrH5T0LeZUO5vTP8WTi01xF1SO0MX5SyYvi3F9u7K608PkLcRdta2VoLd5tUKnwEWbC4GgRWZBNQkDGUZZvpz88RIkCDggHRzIt1kYD+B5v4u6G+fDVuyuMt99s9QXPf2WkPgWvbky5K9bpiC7j7zRbfO55ScG0+ZfPK7WGqkddlEWrvCK4UAPpxcqAozlxV5ATF2DE+SfgdWlk08X8vdTqhEZUSEYvdRhNtV5uvf4oZhYdhS/k9xPaDnKWR3Us6jw== 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: List-Subscribe: List-Unsubscribe: --- fs/netfs/internal.h | 4 +--- fs/netfs/misc.c | 18 ++++++++++++++++++ fs/netfs/write_collect.c | 3 +-- fs/netfs/write_issue.c | 6 +++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index e1149e05a5c8..21a3c7d13585 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -69,6 +69,7 @@ int netfs_buffer_append_folio(struct netfs_io_request *rreq, struct folio *folio bool needs_put); struct folio_queue *netfs_delete_buffer_head(struct netfs_io_request *wreq); void netfs_clear_buffer(struct netfs_io_request *rreq); +void netfs_reset_iter(struct netfs_io_subrequest *subreq); /* * objects.c @@ -161,9 +162,6 @@ struct netfs_io_request *netfs_create_write_req(struct address_space *mapping, void netfs_reissue_write(struct netfs_io_stream *stream, struct netfs_io_subrequest *subreq, struct iov_iter *source); -int netfs_advance_write(struct netfs_io_request *wreq, - struct netfs_io_stream *stream, - loff_t start, size_t len, bool to_eof); struct netfs_io_request *netfs_begin_writethrough(struct kiocb *iocb, size_t len); int netfs_advance_writethrough(struct netfs_io_request *wreq, struct writeback_control *wbc, struct folio *folio, size_t copied, bool to_page_end, diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c index 1700849491a0..a9baa46a17ff 100644 --- a/fs/netfs/misc.c +++ b/fs/netfs/misc.c @@ -84,6 +84,24 @@ void netfs_clear_buffer(struct netfs_io_request *rreq) } } +/* + * Reset the subrequest iterator to refer just to the region remaining to be + * read. The iterator may or may not have been advanced by socket ops or + * extraction ops to an extent that may or may not match the amount actually + * read. + */ +void netfs_reset_iter(struct netfs_io_subrequest *subreq) +{ + struct iov_iter *io_iter = &subreq->io_iter; + size_t remain = subreq->len - subreq->transferred; + + if (io_iter->count > remain) + iov_iter_advance(io_iter, io_iter->count - remain); + else if (io_iter->count < remain) + iov_iter_revert(io_iter, remain - io_iter->count); + iov_iter_truncate(&subreq->io_iter, remain); +} + /** * netfs_dirty_folio - Mark folio dirty and pin a cache object for writeback * @mapping: The mapping the folio belongs to. diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 1521a23077c3..801a130a0ce1 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -219,9 +219,8 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq, /* Determine the set of buffers we're going to use. Each * subreq gets a subset of a single overall contiguous buffer. */ + netfs_reset_iter(from); source = from->io_iter; - iov_iter_revert(&source, subreq->len - source.count); - iov_iter_advance(&source, from->transferred); source.count = len; /* Work through the sublist. */ diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index d581fd8a568b..520be44d132e 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -259,9 +259,9 @@ static void netfs_issue_write(struct netfs_io_request *wreq, * we can avoid overrunning the credits obtained (cifs) and try to parallelise * content-crypto preparation with network writes. */ -int netfs_advance_write(struct netfs_io_request *wreq, - struct netfs_io_stream *stream, - loff_t start, size_t len, bool to_eof) +static int netfs_advance_write(struct netfs_io_request *wreq, + struct netfs_io_stream *stream, + loff_t start, size_t len, bool to_eof) { struct netfs_io_subrequest *subreq = stream->construct; size_t part;