Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7094791rdb; Wed, 3 Jan 2024 04:39:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtTm9RQcH1FcfrRo4BREEk1Yj3Gq5HXSabWOv82WNTnxVK2CyeRjSeQaDxWkzmr6hyM+T9 X-Received: by 2002:a0d:c883:0:b0:5e7:923a:3f7d with SMTP id k125-20020a0dc883000000b005e7923a3f7dmr14780260ywd.65.1704285596928; Wed, 03 Jan 2024 04:39:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704285596; cv=none; d=google.com; s=arc-20160816; b=r+NXur7YozZevqPp4xHcIBc+DDsXGoIslTUavTPkxt8cieOp5C0qhkFZO9lERG0mKI MQeisKFtbhOSkddfrYliEazwWDoFA//axqnoTuEyYfVToEXfzqyWtLmoPjmrmgknmZxm uk9dsnanLV0odVJ0kOrqvCeVup2t10FCnZ9XaV4CPvEddl6NqEtFWCQt4tLwpi7cTGLS TXBzzksmqIvtfCT+NTut6hbwlXt50IvfP6gxj1I6mGv7zbjYShcv0TN08vhDX2Gzhm0k ieWzZME2NAckk1fOBeZlyJTWVStnLGFmoRWSva0IpOE+W4VaK9vWBGjDItU9PjcF5eSM fAmQ== 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=rZR17Gbrs13ExF6OSOpjmM51Duz7iMNUsTARfX2CwGI=; fh=iO1mnNj3+QcY16QMX2pVt5CjcQ/HcrO90z/0VmpgPXI=; b=FW7XjcIF2+ImQLp3mQFfk97C5ZXzeAEsYPAQ86zoSCcQqmQJgPVm4pyFtWUQQ6zuUD IZvSXTokhWs5JXNpXJA85gMkY4EaA0/YvNfb6NSO6uBYPoiDkrFXoAXBJz+2tDGf8U8x dgNZbWY+0WsVrO/lnSKzcM2rFTycquyQULL0Ux7ldc2fsgcQuFXKabs7m7HioKnMDLqt qOx0Cjlwfjzl3leeNRGYSaBtDFN8vJfepePJDj/jDfQL3Ns7jvp65owk7F6VftfEWUke LWHfuG8IRJNfErFDBRVhdY3kriUzkD/X8lPvL5Qz0bDvBktfi6lD6X9F2Fs4RpOUh5vi BGaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cJYBdCEN; spf=pass (google.com: domain of linux-kernel+bounces-15521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15521-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. [147.75.199.223]) by mx.google.com with ESMTPS id vv17-20020a05620a563100b0078118aba43fsi28257084qkn.747.2024.01.03.04.39.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 04:39:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cJYBdCEN; spf=pass (google.com: domain of linux-kernel+bounces-15521-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15521-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 28FFB1C23419 for ; Wed, 3 Jan 2024 12:39:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C17BD19445; Wed, 3 Jan 2024 12:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cJYBdCEN" 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 7FD7D18ED9 for ; Wed, 3 Jan 2024 12:39:43 +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=1704285582; 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=rZR17Gbrs13ExF6OSOpjmM51Duz7iMNUsTARfX2CwGI=; b=cJYBdCENvivUL272oayGlvQp9IQx7px9K1UHj80/4xsYJR6LNlSZwwfyTNV95RVSnlU6C/ ydLRqsBzNsOCqT2WUCWqsH5b7iOmyNsDjheM640fzdqcyDfJ92dE4V8VXWyoZBUHpkwFc+ RtI3zDiuuZ1+bueuoNzKTxLcf8Q/xf0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-124-cl6KkG5aMue3xdfdLO_cMA-1; Wed, 03 Jan 2024 07:39:39 -0500 X-MC-Unique: cl6KkG5aMue3xdfdLO_cMA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 0C13F3813BD1; Wed, 3 Jan 2024 12:39:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3D15C15A0C; Wed, 3 Jan 2024 12:39:34 +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: References: <20231221132400.1601991-1-dhowells@redhat.com> <20231221132400.1601991-41-dhowells@redhat.com> To: Dominique Martinet Cc: dhowells@redhat.com, Jeff Layton , Steve French , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , 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, Latchesar Ionkov , Christian Schoenebeck Subject: Re: [PATCH v5 40/40] 9p: Use netfslib read/write_iter 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: <355429.1704285574.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 03 Jan 2024 12:39:34 +0000 Message-ID: <355430.1704285574@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Dominique Martinet wrote: > > +static void v9fs_upload_to_server(struct netfs_io_subrequest *subreq) > > +{ > > + struct inode *inode =3D subreq->rreq->inode; > > + struct v9fs_inode __maybe_unused *v9inode =3D V9FS_I(inode); > = > Any reason to have this variable assignment at all? I'll just remove it. The __maybe_unused suppressed the warning, otherwise= I'd have removed it already. > p9_client_write return value should always be subreq->len, but I believe > we should use it unless err is set. > (It's also possible for partial writes to happen, e.g. p9_client_write > looped a few times and then failed, at which point the size returned > would be the amount that actually got through -- we probably should do > something with that?) How about something like: - int err; + int err, len; = trace_netfs_sreq(subreq, netfs_sreq_trace_submit); - p9_client_write(fid, subreq->start, &subreq->io_iter, &err); - netfs_write_subrequest_terminated(subreq, err < 0 ? err : subreq->len, - false); + len =3D p9_client_write(fid, subreq->start, &subreq->io_iter, &err); + netfs_write_subrequest_terminated(subreq, len ?: err, false); > > + total =3D p9_client_read(fid, subreq->start + subreq->transferred, > > + &subreq->io_iter, &err); > = > Just to clarify: subreq->io_iter didn't exist (or some conditions to use > it weren't cleared) before? Correct. It's added in the netfs-lib patches. I've provided a way to separate the user-side iterator from the I/O-side iterator to allow the us= e of a bounce buffer for the purpose of content crypto, compression or just hav= ing to deal with RMW cycles to a larger block size on the server. > > + if (file) { > > + fid =3D file->private_data; > > + BUG_ON(!fid); > = > This probably should be WARN + return EINVAL like find by inode? > It's certainly a huge problem, but we should avoid BUG if possible... Sure. The BUG_ON() was already there, but I can turn it into a WARN+error= . > nit: not sure what's cleaner? > Since there's a message that makes for a bit awkward if... > = > if (WARN_ONCE(!fid, "folio expected an open fid inode->i_private=3D%p\n"= , > rreq->inode->i_private)) > return -EINVAL; > = > (as a side note, I'm not sure what to make of this i_private pointer > here, but if that'll help you figure something out sure..) Um. 9p is using i_private. But perhaps i_ino would be a better choice: if (file) { fid =3D file->private_data; if (!fid) goto no_fid; p9_fid_get(fid); } else { fid =3D v9fs_fid_find_inode(rreq->inode, writing, INVALID_UID, true); if (!fid) goto no_fid; } ... no_fid: WARN_ONCE(1, "folio expected an open fid inode->i_ino=3D%lx\n", rreq->inode->i_ino); return -EINVAL; > This is as follow on your netfs-lib branch: > - WARN_ON(rreq->origin =3D=3D NETFS_READ_FOR_WRITE && > - !(fid->mode & P9_ORDWR)); > - > - p9_fid_get(fid); > + WARN_ON(rreq->origin =3D=3D NETFS_READ_FOR_WRITE && !(fid->mode = & P9_ORDWR)); > = > So the WARN_ON has been reverted back with only indentation changed; > I guess there were patterns that were writing despite the fid not having > been open as RDWR? > Do you still have details about these? The condition in the WARN_ON() here got changed. It was: WARN_ON(writing && ... at one point, but that caused a bunch of incorrect warning to appear becau= se only NETFS_READ_FOR_WRITE requires read-access as well as write-access. A= ll the others: bool writing =3D (rreq->origin =3D=3D NETFS_READ_FOR_WRITE || rreq->origin =3D=3D NETFS_WRITEBACK || rreq->origin =3D=3D NETFS_WRITETHROUGH || rreq->origin =3D=3D NETFS_LAUNDER_WRITE || rreq->origin =3D=3D NETFS_UNBUFFERED_WRITE || rreq->origin =3D=3D NETFS_DIO_WRITE); only require write-access. There will be an additional one if we roll out content crypto to 9p as we = may need to do RMW cycles occasionally - but that's off to one side just for t= he moment. > If a file has been open without the write bit it might not go through, > and it's incredibly difficult to get such users back to userspace in > async cases (e.g. mmap flushes), so would like to understand that. The VFS/VM should prevent writing to files that aren't open O_WRONLY or O_RDWR, so I don't think we should be called in otherwise. Note that I'm intending to change the way fscache is driven when we fetch cacheable data from the server so that I can free up the PG_fscache bit an= d return it to the MM folks. Instead of marking the page PG_fscache, I mark= it PG_dirty and set page->private with a special value to indicate it should = only be written to the cache - then the writepages sees that and just writes th= ese pages to the cache. I have a patch to do this and it seems to work, but I need to make ceph and cifs use netfslib before I can apply it. > > + p9_debug(P9_DEBUG_VFS, "(cached)\n"); > = > (Not a new problem so no need to address here, but having just > "(cached)" on a split line is a bit weird.. We first compute cached or > not as a bool and make it %s + cached ? " (cached)" : "" or > something... I'll send a patch after this gets in to avoid conflicts) Okay. > > + return netfs_page_mkwrite(vmf, NULL); > = > (I guess there's no helper that could be used directly in .page_mkwrite > op?) I could provide a helper that just supplies NULL as the second argument. = I think only 9p will use it, but that's fine. David