linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dominique Martinet via B4 Relay <devnull+asmadeus.codewreck.org@kernel.org>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	 Christian Brauner <brauner@kernel.org>,
	David Howells <dhowells@redhat.com>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	 Andrew Morton <akpm@linux-foundation.org>
Cc: Maximilian Bosch <maximilian@mbosch.me>,
	Ryan Lahfa <ryan@lahfa.xyz>,
	 Christian Theune <ct@flyingcircus.io>,
	Arnout Engelen <arnout@bzzt.net>,
	 linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	 linux-fsdevel@vger.kernel.org,
	Dominique Martinet <asmadeus@codewreck.org>
Subject: [PATCH v2 2/2] iov_iter: iov_folioq_get_pages: don't leave empty slot behind
Date: Tue, 12 Aug 2025 06:28:02 +0900	[thread overview]
Message-ID: <20250812-iot_iter_folio-v2-2-f99423309478@codewreck.org> (raw)
In-Reply-To: <20250812-iot_iter_folio-v2-0-f99423309478@codewreck.org>

From: Dominique Martinet <asmadeus@codewreck.org>

After advancing into a folioq it makes more sense to point to the next
slot than at the end of the current slot.
This should not be needed for correctness, but this also happens to
"fix" the 9p bug with iterate_folioq() not copying properly.

Acked-by: David Howells <dhowells@redhat.com>
Tested-by: Arnout Engelen <arnout@bzzt.net>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
 lib/iov_iter.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index f9193f952f49945297479483755d68a34c6d4ffe..65c05134ab934e1e0bf5d010fff22983bfe9c680 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -1032,9 +1032,6 @@ static ssize_t iter_folioq_get_pages(struct iov_iter *iter,
 			maxpages--;
 		}
 
-		if (maxpages == 0 || extracted >= maxsize)
-			break;
-
 		if (iov_offset >= fsize) {
 			iov_offset = 0;
 			slot++;
@@ -1043,6 +1040,9 @@ static ssize_t iter_folioq_get_pages(struct iov_iter *iter,
 				slot = 0;
 			}
 		}
+
+		if (maxpages == 0 || extracted >= maxsize)
+			break;
 	}
 
 	iter->count = count;

-- 
2.50.1



      parent reply	other threads:[~2025-08-11 21:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-11 21:28 [PATCH v2 0/2] iterate_folioq bug when offset==size (Was: [REGRESSION] 9pfs issues on 6.12-rc1) Dominique Martinet via B4 Relay
2025-08-11 21:28 ` [PATCH v2 1/2] iov_iter: iterate_folioq: fix handling of offset >= folio size Dominique Martinet via B4 Relay
2025-08-11 21:28 ` Dominique Martinet via B4 Relay [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250812-iot_iter_folio-v2-2-f99423309478@codewreck.org \
    --to=devnull+asmadeus.codewreck.org@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnout@bzzt.net \
    --cc=asmadeus@codewreck.org \
    --cc=brauner@kernel.org \
    --cc=ct@flyingcircus.io \
    --cc=dhowells@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maximilian@mbosch.me \
    --cc=ryan@lahfa.xyz \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).