From patchwork Fri Dec 22 12:00:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13503260 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 0274AC41535 for ; Fri, 22 Dec 2023 12:01:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7F0B26B007D; Fri, 22 Dec 2023 07:01:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 79F5C6B007E; Fri, 22 Dec 2023 07:01:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 666C76B0080; Fri, 22 Dec 2023 07:01:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 55D646B007D for ; Fri, 22 Dec 2023 07:01:01 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 324C1160DBC for ; Fri, 22 Dec 2023 12:01:01 +0000 (UTC) X-FDA: 81594313122.11.522E8F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 4133C120017 for ; Fri, 22 Dec 2023 12:00:59 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nyus3hJS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1703246459; h=from:from:sender: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:dkim-signature; bh=BJQmrSBfBKkF1FEAH3EILbfyiDOBLbXiZySEe1rSlv0=; b=rjT+MEoHeHam095BPLc+RuCL5TZfRrosAinF8wb8sgqPKcPfK544TqkfoE47u9ovBTyINO M1HV/UNBB9lmzAhtBqjPj8unisZtv6QxCX9PDSXcEDtIYM4cXfDn5bXypTc1L94DqF7ppP SlehFcOXaODVI3kqXCfeBdfuAgtSZpU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nyus3hJS; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703246459; a=rsa-sha256; cv=none; b=FHwG4u5KDuFCDCZMFTMq08UTuc8sI9EYGdGzGv/7cBfDJgB/3cm+WJCyEn7Ho3K0gnn11/ GxUmEf0Zxp3/ZDc5Cm231C1aFhrzejF2+B/goVhO854kpGCDvttTr22/+UtFjPIoOMn/T0 dkXtsFdJHHPuaE1FlKiQaUBVWgAg5MU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703246458; 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=Nyus3hJSy/BYeRgwj0yqI7Zdr8mkkPxNQ5TN27qkK7orkCO2VZ4z2onu0v4anmf/nroEkq eS3d09+z8e4WwGRBy/8HUcaa96HcNryJLV3V2vUEdqGwfc5bsK8wSPCjB/YXUEJe/8DrtR 2z6s6fwnr10cFUGtUpwZLOKP0JLdYeE= 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 MIME-Version: 1.0 Content-ID: <2229135.1703246451.1@warthog.procyon.org.uk> 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 X-Rspamd-Queue-Id: 4133C120017 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tznc5s5pphiif7jptttgaeo6obfs7bdg X-HE-Tag: 1703246459-128004 X-HE-Meta: U2FsdGVkX18hX6teh1kbbEpgVp5oLUfufM5HDXmG29t+HTrlAvLsUQfVsa2Ws0+sAr503flwo9ewlJ+MI/BbnuWc+2ITrQTykiC/VYm047bBh9OzvINdBKVEU3XMi6LYZf5qbgmqOf+vfJNwhKve5AjYnn3pWhkXSVxrQPnICUCqgBwjjqhjJx60gqDZcH62tr3fWMPwcFGbha1iV5ls8MKeVaUPJuCb6oHVpoGSltVMW/hdbYtjFWD2g2IXCXSl3DGgq0lFdwv/VO8HJwtoPHPmmA5BbYc8Gkl147DRZ31HFdQbJ0L2uLryXbzvSqXCOZGMqGppGVh/GxWRLOThhlljHEAPI/cNEcRzT8XrRVVEEN8NItanz/SX8dz9wtr1fClBH8SCKz6M2SpxyXnfONxfIjIl+7GyaNTDE4px7M2LJWFFHmsjbDUCgUDGQj7CWwXAroMQ0C4rW1WbYUlar8xJNV8hoO58Mk5BIbgwPcFL5bJOMF0Nrs4jI8jB8fVrnNVN56NvznMouyhxJsNtuWofAz/gDO/PWgmH6JyoR2lVbr+qZ5xyRgCqZy+qK800esHGJ6POXcMkvbsM88ihH6YM2CrUbtm2ePzXoCqskBFvfYcgiRAEN3a9PeC9GzB2dXfwmQ2q7xtOuFzhdOKR5mZ/cx0uawChIFX7XGnydiWPz5JWm3KNp/rDjDey3NT0+Zv8fTbBH3wU/Y7CPMFLA8YBKfDqQSKWD6ykv+yqTe8iPNQ9Xt+AhdO+qmNppUxvvYXusyzER5MrGnmMUioHItB0i5nYLiu4gGSTZPNYew27JFNaRRb982jz28mRVRIjzFpLDDskNZAi76TByjXeT1LulgdPQdfCD31n9SjD6w3p9UljO3LgkjRaDrpXr7piYkmRRyiG5upf4B9b69SDazo7ftWodZnTtLwY4OFvFuHcyrEKd1t/45u31xFlX+Wqulom18JaqzEtJx4EwKs kzo8A4O8 acId0wl4sS9F+sBpPEJz94/XfJ5cHR6PlDlL62a5QiK4YZZPXJXoxvHPvbeAoJ0bpS6unKcMUJ0W9CGEviA5lZigY9EKJBwnNk7ndzR3s+IGslK+vuyU5835H5rbj6e3sqDWkfK6TH5u1xnz6B3d8SULKseEuBRmupxuBscmz7hr/VgwNt58+V5u8wKxxmDczGfBaaG87MEVlf0Vn3L9PvnASzhKnFMWkuDa83yBvHqji20s= 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: 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 = 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 = 0; inode->i_mode = 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_data *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 follow 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 = ops; ctx->remote_i_size = i_size_read(&ctx->inode); - ctx->zero_point = ctx->remote_i_size; + ctx->zero_point = LLONG_MAX; ctx->flags = 0; #if IS_ENABLED(CONFIG_FSCACHE) ctx->cache = NULL; #endif /* ->releasepage() drives zero_point */ - mapping_set_release_always(ctx->inode.i_mapping); + if (use_zero_point) { + ctx->zero_point = ctx->remote_i_size; + mapping_set_release_always(ctx->inode.i_mapping); + } } /**