From mboxrd@z Thu Jan 1 00:00:00 1970 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 94205C41535 for ; Tue, 19 Dec 2023 14:32:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BA818D0002; Tue, 19 Dec 2023 09:32:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 241FD8D0001; Tue, 19 Dec 2023 09:32:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BB6B8D0002; Tue, 19 Dec 2023 09:32:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EA02D8D0001 for ; Tue, 19 Dec 2023 09:32:07 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6527C09F9 for ; Tue, 19 Dec 2023 14:32:07 +0000 (UTC) X-FDA: 81583807494.16.2447914 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id D7C3F160022 for ; Tue, 19 Dec 2023 14:32:04 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tq4h+o2K; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1702996325; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fcH5mhNCfy4Npx8m9bnDGoyerhb2vmsJtBvMFIY3PE4=; b=OjBh5ujHHO3LYuwQwxV/RxmfG1NWvy8zEioI6z/mzpdjT6poPUIryP9+C5KsgmnlR/oZrl bWWHbOH10BUZq88JJrfkPaCuWJ2tsll/srd4hettOnGOCw9EfsS7AqoqwbUZewGoCdcLiW Ebu7UQhxLNSKqVJ77BcVGnAqYLcvaGI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Tq4h+o2K; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf08.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702996325; a=rsa-sha256; cv=none; b=zvInwZDiUAKU1VtRsfSaDZJplCX4DQU2g4MbxBatnpE//WjuSx3Hma7krWOHnKU5H/ILre Uou6xOD+NPUTo3u4Ha5ONG83p6h/+qbpPBbXz7TBzWCamkY5gjcotaTWlrdtKclyWtTccd yoljAXMhF1R8bI5k93hnCNIUGcJmYAk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702996324; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fcH5mhNCfy4Npx8m9bnDGoyerhb2vmsJtBvMFIY3PE4=; b=Tq4h+o2KzZ9K0hU0PdqHh7oMAZWGAifZEqvlAcFvG2pJ+TGWiR9VNeVLeNtsSf4DBI4/xw gorEXOiVKXOgYK+cg4AOizUBoT3aHIwVn6uJtY5LjPyxScQMldN/rsvgG0LhNvu0jUs6D+ jBI7rpNj1uBYLRIsX6ZulihLypabIcs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-E3lE2-3DM7eN9FhE4GCjsQ-1; Tue, 19 Dec 2023 09:31:58 -0500 X-MC-Unique: E3lE2-3DM7eN9FhE4GCjsQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A58A6101AA4D; Tue, 19 Dec 2023 14:31:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id A72882166B31; Tue, 19 Dec 2023 14:31:53 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <367107fa03540f7ddd2e8de51c751348bd7eb42c.camel@kernel.org> References: <367107fa03540f7ddd2e8de51c751348bd7eb42c.camel@kernel.org> <20231213152350.431591-1-dhowells@redhat.com> <20231213152350.431591-13-dhowells@redhat.com> To: Jeff Layton Cc: dhowells@redhat.com, Steve French , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Eric Van Hensbergen , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 12/39] netfs: Add iov_iters to (sub)requests to describe various buffers MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <488522.1702996313.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 19 Dec 2023 14:31:53 +0000 Message-ID: <488523.1702996313@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspamd-Queue-Id: D7C3F160022 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ajtz7n7x43t6dbj1os67f6mdwjht3ffc X-HE-Tag: 1702996324-165887 X-HE-Meta: U2FsdGVkX1/EHXrXPN1AcetJIHOWaGBZdts0CP0H1eMW5C+Wme0Y7s9YXMqhbujDEXQIyt7EY1r5h0xHt/M12JjOPxJfogtG21EMntFsuBs6Jvg5Vi6Ue4bglQO/LP16uPpL5iUaR7t6nLTZDuGoi+QfEjQBySEB2NxNBySMtj1ujxia8Zy4DsWgZ4b9zuB4c5BIEtJ0rc9SCtLgYjizz/qnXpABioIKLpXkY0yW0lZYMnCq4tHtrJFjDqOQJOwv2NTTAifH7N6Fhrjed/N1QD4gW8chU1r08p9M2xM5Iz+o4lWcOsToUF246BwFy1IQy+yhQcO2E9/oT7BeFWmg5iii13R1PtvPk80OHdXR+mZzBFdDVX+JNJgNGEr9Vqei2V5R0NFpiqVVBABbHC+t8hahn9L/cEaz8w3B6Tp5+D3+gr7qfoGD7DED5w1eSn6jFpVW9RmKBQrnVBLWWa5VN5DS7UvCdKzndt3YVRWxHpo33/OP5x4ogn6lNHVv9DMEZhTslHHsWnGineQf+mw6K2ueXkD9x4+1aR/4uya3XkSuLW+HnQd/beW/+6Qy90RiM+JfWp14DStS1HP28XnEffYhAuhWvmC5UeqTnLPA8xZs+Gx5HuanDTO471FngvDUTFL6YkYlFMtUpxvLfYwjGoeWdRqyItVjCH26uWCFdRjf8nt0dkjh5+RAw0GeLgGtccvS68BwNmOASJTGyYvQjO0/IeQHIUEkGvRBv476hzDqY9xaPGVAuzfPkqSvSvEVLtwE81FW9IjEqzTbIqyOjehltumchSFkzChpo/IYU5D0cZlax0I3Bd0tzMJ0QFWEbpUnMHJ115u0uZzZJcx9fPut1CwVnPF1nDV61QpExo6FSQOHp/WN34Y4ugvh+EN/WesVxPP2TIHZMdT2xzBkMQIPWMvCISWsNOoLoHiiGPkC17iPqLGvRsJ+BfAVOzSgUB7S5NdyOB0RQTnWP4R Kn8XLm+b I2B7ahJ3X8yvZTklDiEuyVP+NWiLq3OX3mdOA5PfVvwK2tFSU22OfOWa7rVsjw7U9ZhN1QmMYoBy/rkpzWsScqNOZCfEh6//Px13mn0Jf9q1rtytShVsJTXuz9pKyt627x9hBkxSyqznb901MeM4hO1M9VsuUo9RZBTkuieU0a3ZNvUjcU1JC6O9n+l6M6WijCYasHeDUWgZdknqmQwe84kaJ+fLPqwsQX1kz5+t0Ut2NDu+VEF+xkCFE1BDTdXQum11JhHoYzLSodcY= 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: Jeff Layton wrote: > > @@ -408,6 +417,10 @@ int netfs_write_begin(struct netfs_inode *ctx, > > ractl._nr_pages =3D folio_nr_pages(folio); > > netfs_rreq_expand(rreq, &ractl); > > = > > + /* Set up the output buffer */ > > + iov_iter_xarray(&rreq->iter, ITER_DEST, &mapping->i_pages, > > + rreq->start, rreq->len); > = > Should the above be ITER_SOURCE ? No - we're in ->write_begin() and are prefetching. If you look in the cod= e, there's a netfs_begin_read() call a few lines below. The output buffer fo= r the read is the page we're going to write into. Note that netfs_write_begin() should be considered deprecated as the whole perform_write thing will get replaced. > > @@ -88,6 +78,11 @@ static void netfs_read_from_server(struct netfs_io_= request *rreq, > > struct netfs_io_subrequest *subreq) > > { > > netfs_stat(&netfs_n_rh_download); > > + if (iov_iter_count(&subreq->io_iter) !=3D subreq->len - subreq->tran= sferred) > > + pr_warn("R=3D%08x[%u] ITER PRE-MISMATCH %zx !=3D %zx-%zx %lx\n", > > + rreq->debug_id, subreq->debug_index, > > + iov_iter_count(&subreq->io_iter), subreq->len, > > + subreq->transferred, subreq->flags); > = > pr_warn is a bit alarmist, esp given the cryptic message. Maybe demote > this to INFO or DEBUG? > = > Does this indicate a bug in the client or that the server is sending us > malformed frames? Good question. The network filesystem updated subreq->transferred to indi= cate it had transferred X amount of data, but the iterator had been updated to indicate Y amount of data was transferred. They really ought to match as = it may otherwise indicate an underrun (and potential leakage of old data). Overruns are less of a problem since the iterator would have to 'go negati= ve' as it were. However, it might be better just to leave io_iter unchecked since we end u= p resetting it anyway each time we reinvoke the ->issue_read() op. It's alw= ays possible that it will get copied and a different iterator get passed to th= e network layer or cache fs - and so the change to the iterator then has to = be manually propagated just to avoid the warning. David