Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp745293rdb; Fri, 22 Dec 2023 04:01:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdFH6KbenLnAdPW4TPQDMHIACCcq9OPBPrr35JLek4XiHvhH8AcKI5jaMBH92SPPsll24i X-Received: by 2002:a05:6a20:7f8c:b0:18f:f3f4:e61 with SMTP id d12-20020a056a207f8c00b0018ff3f40e61mr1065615pzj.3.1703246475633; Fri, 22 Dec 2023 04:01:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703246475; cv=none; d=google.com; s=arc-20160816; b=uONdsJPyoMwwtUfTnTLbtNOVQmnVX8r+fCz/zo6hd339ho1FrtoT5c9fVOTfaThrse 8M4BK26gxLBz9F9/IqgYQOJnabWXBHlFuwhGATGIsxcjRh6j+GLkZttW3J/AWPJSrQqQ ZvxFEkgkJg+wzaYbovTJnOzMI5002P1xc6PMqUwu/SEn9lQA7oDX6VJn5HQHxQKvdYIo O3XH+WDeDdGCjbMihIS2fLLQIHaBX9yg8uNfO59k1mYJ0I9Nbb1YnQB1iIKCoj2E0b9J /6jha/ZSdtCv+nKt4CtG4FssZRg/CquLpC22R+sD7oW33aGtIxSwajLqClgkBVJOyTeL 3wyg== 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 :references:in-reply-to:from:organization:dkim-signature; bh=BJQmrSBfBKkF1FEAH3EILbfyiDOBLbXiZySEe1rSlv0=; fh=9v08xJNacvNjOm9W8hw7chYArnZsmswKd9C7OT6P4OA=; b=PlQisW9bgFi+kUH53ltMnHVsKUnirPFwsj8/plw7SZ/P+QDftkxNfKjoieD9h8Fb4z elSnYsncCTsNPfNUuiypoXZfgWE9vb8f4HxGqhy7Vz3jKdphhqjIR6b7E8ROLEdzjlvP lPz5LMxGXUmuHECEMjfLY5/VbPn4uVZSpXm/5Dbx4WkoLKMUQaZKjlJqdU4DBpWJDZ73 buha4qnZvjPX4qf0sNoYZpW1SULMI6IahWhvtDnKGx/2TBJkvY3tIV8IDVjwt+F0JmVO RcYqOT69tPB3PnqhYLXzplSw10CXI2BfoOJw20DIiLA/9yfgQjVBuDKXgz5g/XCa72gC wPDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVV3ulNs; spf=pass (google.com: domain of linux-nfs+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e18-20020a62aa12000000b006ce45456a0esi3156848pff.46.2023.12.22.04.01.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 04:01:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVV3ulNs; spf=pass (google.com: domain of linux-nfs+bounces-775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-775-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4AFA3281F9C for ; Fri, 22 Dec 2023 12:01:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE9561803C; Fri, 22 Dec 2023 12:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PVV3ulNs" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 5343817993 for ; Fri, 22 Dec 2023 12:01: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=1703246461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: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=BJQmrSBfBKkF1FEAH3EILbfyiDOBLbXiZySEe1rSlv0=; b=PVV3ulNs8WXTgAHZSENULp4kD00duOqe/rKzO0f6sHqUZATiS/FR2DKxIH9uxuISFywqvS 4HaoEXf8oPhYQQMWOyaXJ+CAXU6+0dY3G5LiUotg4TAAtx8PqajyP/6wIhqP/tZaKGFdYX kbl5oCyUjDu7OT82niKcWLM6+DkOtas= 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-433-6IC2kF7KOuGC0hQW2X7v9g-1; Fri, 22 Dec 2023 07:00:56 -0500 X-MC-Unique: 6IC2kF7KOuGC0hQW2X7v9g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 CD5373C2A1D2; Fri, 22 Dec 2023 12:00:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 776331C060AF; Fri, 22 Dec 2023 12:00:52 +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: <2202548.1703245791@warthog.procyon.org.uk> References: <2202548.1703245791@warthog.procyon.org.uk> <20231221230153.GA1607352@dev-arch.thelio-3990X> <20231221132400.1601991-1-dhowells@redhat.com> <20231221132400.1601991-38-dhowells@redhat.com> Cc: dhowells@redhat.com, Nathan Chancellor , Anna Schumaker , Trond Myklebust , Jeff Layton , 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: [PATCH] Fix oops in NFS Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2229135.1703246451.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Fri, 22 Dec 2023 12:00:51 +0000 Message-ID: <2229136.1703246451@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 David Howells wrote: > A better way, though, is to move the call to nfs_netfs_inode_init() > and give it a flag to say whether or not we want the facility. Okay, I think I'll fold in the attached change. David --- diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 55345753ae8d..b66466e97459 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -249,7 +249,7 @@ void v9fs_free_inode(struct inode *inode) static void v9fs_set_netfs_context(struct inode *inode) { struct v9fs_inode *v9inode =3D V9FS_I(inode); - netfs_inode_init(&v9inode->netfs, &v9fs_req_ops); + netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true); } = int v9fs_init_inode(struct v9fs_session_info *v9ses, diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c index 1f656005018e..9c517269ff95 100644 --- a/fs/afs/dynroot.c +++ b/fs/afs/dynroot.c @@ -76,7 +76,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb= , bool root) /* there shouldn't be an existing inode */ BUG_ON(!(inode->i_state & I_NEW)); = - netfs_inode_init(&vnode->netfs, NULL); + netfs_inode_init(&vnode->netfs, NULL, false); inode->i_size =3D 0; inode->i_mode =3D S_IFDIR | S_IRUGO | S_IXUGO; if (root) { diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 2b44a342b4a1..381521e9e118 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -58,7 +58,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode,= struct afs_vnode *paren */ static void afs_set_netfs_context(struct afs_vnode *vnode) { - netfs_inode_init(&vnode->netfs, &afs_req_ops); + netfs_inode_init(&vnode->netfs, &afs_req_ops, true); } = /* diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 3149d79a9dbe..0c25d326afc4 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -574,7 +574,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) doutc(fsc->client, "%p\n", &ci->netfs.inode); = /* Set parameters for the netfs library */ - netfs_inode_init(&ci->netfs, &ceph_netfs_ops); + netfs_inode_init(&ci->netfs, &ceph_netfs_ops, false); = spin_lock_init(&ci->i_ceph_lock); = diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h index 5407ab8c8783..e3cb4923316b 100644 --- a/fs/nfs/fscache.h +++ b/fs/nfs/fscache.h @@ -80,7 +80,7 @@ static inline void nfs_netfs_put(struct nfs_netfs_io_dat= a *netfs) } static inline void nfs_netfs_inode_init(struct nfs_inode *nfsi) { - netfs_inode_init(&nfsi->netfs, &nfs_netfs_ops); + netfs_inode_init(&nfsi->netfs, &nfs_netfs_ops, false); } extern void nfs_netfs_initiate_read(struct nfs_pgio_header *hdr); extern void nfs_netfs_read_completion(struct nfs_pgio_header *hdr); diff --git a/include/linux/netfs.h b/include/linux/netfs.h index a5374218efe4..06a03dd1aff1 100644 --- a/include/linux/netfs.h +++ b/include/linux/netfs.h @@ -456,22 +456,27 @@ static inline struct netfs_inode *netfs_inode(struct= inode *inode) * netfs_inode_init - Initialise a netfslib inode context * @ctx: The netfs inode to initialise * @ops: The netfs's operations list + * @use_zero_point: True to use the zero_point read optimisation * * Initialise the netfs library context struct. This is expected to foll= ow on * directly from the VFS inode struct. */ static inline void netfs_inode_init(struct netfs_inode *ctx, - const struct netfs_request_ops *ops) + const struct netfs_request_ops *ops, + bool use_zero_point) { ctx->ops =3D ops; ctx->remote_i_size =3D i_size_read(&ctx->inode); - ctx->zero_point =3D ctx->remote_i_size; + ctx->zero_point =3D LLONG_MAX; ctx->flags =3D 0; #if IS_ENABLED(CONFIG_FSCACHE) ctx->cache =3D NULL; #endif /* ->releasepage() drives zero_point */ - mapping_set_release_always(ctx->inode.i_mapping); + if (use_zero_point) { + ctx->zero_point =3D ctx->remote_i_size; + mapping_set_release_always(ctx->inode.i_mapping); + } } = /**