Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp540873rdh; Tue, 19 Dec 2023 06:36:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbaB6Mz/BNXiHXEkLGZ7dfDuW1W/llarOUEN0foaxCICjWtX+4wwrCgVmdnhd30P7+z48x X-Received: by 2002:a05:620a:2705:b0:77f:53d6:af34 with SMTP id b5-20020a05620a270500b0077f53d6af34mr21445323qkp.141.1702996612311; Tue, 19 Dec 2023 06:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702996612; cv=none; d=google.com; s=arc-20160816; b=DFmtXlFHLXv9wni4PHQxZ1T9WfitLcOM2GET2xTSRfS90aue3ONfFSKyde3oUudoQQ tte01qAD9S1IWt4OYYY4q3naDs/+jNa2XUHAhypXFhGFtOKRmI9NI+LDsAp9QgY2HS6n 9AmGefNXOhI9yPJXYHSoO52p7slJdMEL+8fOTzzdzjhiyi0lPkWuGNg1EmMuf6EAyHl2 RqIUZWRZbVjUp651U1DeJTvj1UHGv065qU4r6PI2mhTb2QZNV4hEoIuarLKneL3Kb8JZ 7ZK7sBCCS0iMISGUN8yPudslqVaLUBZM0WqU6VDRCsnCnMvCL5fN8GgXb7a2Ro7N7qT/ Jq4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :references:in-reply-to:from:organization:dkim-signature; bh=fcH5mhNCfy4Npx8m9bnDGoyerhb2vmsJtBvMFIY3PE4=; fh=oTSheoojIQWE85h15wIbFV5tdQ792s9VwZPsELvSY7c=; b=ycpt+XefNVlWEbJ7ewwC7sL2L/6cSLHq9fsW1CTXwLth25VNg6YfF7w/nVaRjmvmqm kwFcQAQRAo5n4ozgCSqQzdBosZqum8fKnKHEh7+dA3G9mMpkUobgBiFq5AS9mrYPmotu VZqWWdGVIFHfHw7oOMgtB/FNF+au9t1/tCwZkxgTbbP/ML4Tz099luJskVNr3PHWXttI usSN/yKSLgF2alktiBASxZb6gdmXB4e0XXqVVJY9xc0kt+G8dUJPPEpMwnMZAdcpBh9K 0Gy2j/GsihUQ3RaZwjPiN/psHB+MXBzEsRl8gKek3DpKSPA2NgrIliM5opOgwSUb/x7t 1LaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZACObj+l; spf=pass (google.com: domain of linux-kernel+bounces-5387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5387-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id de13-20020a05620a370d00b0077d95f62af3si10103902qkb.544.2023.12.19.06.36.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:36:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-5387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZACObj+l; spf=pass (google.com: domain of linux-kernel+bounces-5387-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-5387-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0033D1C24254 for ; Tue, 19 Dec 2023 14:36:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D033C374E7; Tue, 19 Dec 2023 14:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZACObj+l" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2398D2E3E4 for ; Tue, 19 Dec 2023 14:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702996322; 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=ZACObj+l4w7skWKmFjJ3e5SzDrq0EGk0kfsjaxEXQEJXxM390+ahrlC3d8T+QfJSVo7vT2 B2g20LvVIZ2ZEvzghRi/Tco6g36jPgFFucfzddBSKqQMpjyU1h6syyQKsiLhiRPuegovvh p7y0SIY3+RccdI+AXtTge7PQcPvnlqo= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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