From patchwork Wed Jan 3 14:59:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 184777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5069593dyb; Wed, 3 Jan 2024 07:01:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGt0oT8DwP9XxN4+a7QfBypgLu75xdd+U+ruWaeoMtlQ9KRUzUzc4j0ylGq2EOZaGNsc3An X-Received: by 2002:aca:1708:0:b0:3bc:1a73:2945 with SMTP id j8-20020aca1708000000b003bc1a732945mr2024397oii.59.1704294088142; Wed, 03 Jan 2024 07:01:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704294088; cv=none; d=google.com; s=arc-20160816; b=qPgg5r/XSvIyenMDllljCKWF8fiH/z4WAbnmhHZgbq9O94Te6P6PjDjhvuAncfGxL/ 5ULb4B4xC4shzVfGQtIxlf24OlThFsqy9c71l2A1hesH9tGABo3jkfdroS6Oz9YAIBWW PLhdVmQNssFfPDte8285d5WZe+nJ1qZV7n8O3vMw3A0jO/DSdycDFjWuOdFeC8G3An7j TqMRBv5lpDcwv5NIdj8g0xDEyCheXSJ3DP6rSIqagmDp6tsONiuGpVq3QMP1JygLv0XR 0P9P2zErgfD/4NCBC5rgtsLRcTLpCcxJBsIYffMkvRGY3aDqmTKaX9xRzx4xzlCfIJC2 0icw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=MeAO0oSTBeeKS0vYZcWZAv5QaziKwPxfd8eozSQVml8=; fh=z2lFNIQm1BYTiGQWz0rp4lP3BVSA1n5g+uZ/88gyKRg=; b=CqKDTIk9H5t+6ZpuA3krZnYx3UvFep3kPOXUHvzZ4tYpxMHCt3yEVaR8kY3psBz0zY 6L5yrBtIRXPTOM8t/BK+XNoqvtBx9aW9MYMpVOYaCA8Luu4/stG9CvBamp49WNjJlP07 MOMoXb0Ntt5jkj530/6WnNTlBf5/nWXLvP2YdzpwRKxtcX0fpHWb2bRnphdnwdNuTt4U z9KNwxILh9xCH4cvS9MXwv6G2GaYw8JbO9dZbmKFpZogk0JvaULGgVSFFbket0kR78NR BZlKmv3O+a3038w879D8pCcy5e9+aQ8SPl4yn98b/fQ7z5tWBvWo4VRzhKaQV2E+jn3g tv3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Z/r905Ed"; spf=pass (google.com: domain of linux-kernel+bounces-15675-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15675-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y20-20020a0cf154000000b0067f692cf830si26145886qvl.128.2024.01.03.07.01.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 07:01:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15675-ouuuleilei=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="Z/r905Ed"; spf=pass (google.com: domain of linux-kernel+bounces-15675-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15675-ouuuleilei=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 E5A3F1C237BC for ; Wed, 3 Jan 2024 15:01:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 708BB1C6A4; Wed, 3 Jan 2024 15:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z/r905Ed" X-Original-To: linux-kernel@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 721B41BDE3 for ; Wed, 3 Jan 2024 15:00:06 +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=1704294005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MeAO0oSTBeeKS0vYZcWZAv5QaziKwPxfd8eozSQVml8=; b=Z/r905EdIOlGjWxXvb/PkAebcmdvD4nfY6zQdPxR7azq9KOlc9hdMNwJbAxM0lTMYd6puG sO/fJ2gnV2dWPC0XuaC6yJzRj77mqEKEmIAKpYwPzdLe7LdiKKXUt87mWb9lXjW0PBqAu2 ZJGqPnggMgrhUJcjpZN4LPSbnxYkmQs= 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-463-cI1hlP01MuqdOORVRFc1ug-1; Wed, 03 Jan 2024 09:59:59 -0500 X-MC-Unique: cI1hlP01MuqdOORVRFc1ug-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 355D6185A793; Wed, 3 Jan 2024 14:59:58 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03EE83C30; Wed, 3 Jan 2024 14:59:53 +0000 (UTC) From: David Howells To: Christian Brauner , Jeff Layton , Gao Xiang , Dominique Martinet Cc: David Howells , Steve French , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , 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-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Latchesar Ionkov , Christian Schoenebeck Subject: [PATCH 2/5] 9p: Fix initialisation of netfs_inode for 9p Date: Wed, 3 Jan 2024 14:59:26 +0000 Message-ID: <20240103145935.384404-3-dhowells@redhat.com> In-Reply-To: <20240103145935.384404-1-dhowells@redhat.com> References: <20240103145935.384404-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787081877285833677 X-GMAIL-MSGID: 1787081877285833677 The 9p filesystem is calling netfs_inode_init() in v9fs_init_inode() - before the struct inode fields have been initialised from the obtained file stats (ie. after v9fs_stat2inode*() has been called), but netfslib wants to set a couple of its fields from i_size. Reported-by: Marc Dionne Signed-off-by: David Howells Tested-by: Marc Dionne Tested-by: Dominique Martinet Acked-by: Dominique Martinet cc: Eric Van Hensbergen cc: Latchesar Ionkov cc: Dominique Martinet cc: Christian Schoenebeck cc: v9fs@lists.linux.dev cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org --- fs/9p/v9fs_vfs.h | 1 + fs/9p/vfs_inode.c | 6 +++--- fs/9p/vfs_inode_dotl.c | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 731e3d14b67d..0e8418066a48 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -42,6 +42,7 @@ struct inode *v9fs_alloc_inode(struct super_block *sb); void v9fs_free_inode(struct inode *inode); struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev); +void v9fs_set_netfs_context(struct inode *inode); int v9fs_init_inode(struct v9fs_session_info *v9ses, struct inode *inode, umode_t mode, dev_t rdev); void v9fs_evict_inode(struct inode *inode); diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index b66466e97459..32572982f72e 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -246,7 +246,7 @@ void v9fs_free_inode(struct inode *inode) /* * Set parameters for the netfs library */ -static void v9fs_set_netfs_context(struct inode *inode) +void v9fs_set_netfs_context(struct inode *inode) { struct v9fs_inode *v9inode = V9FS_I(inode); netfs_inode_init(&v9inode->netfs, &v9fs_req_ops, true); @@ -326,8 +326,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, err = -EINVAL; goto error; } - - v9fs_set_netfs_context(inode); error: return err; @@ -359,6 +357,7 @@ struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev) iput(inode); return ERR_PTR(err); } + v9fs_set_netfs_context(inode); return inode; } @@ -461,6 +460,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, goto error; v9fs_stat2inode(st, inode, sb, 0); + v9fs_set_netfs_context(inode); v9fs_cache_inode_get_cookie(inode); unlock_new_inode(inode); return inode; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index e25fbc988f09..3505227e1704 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -128,6 +128,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, goto error; v9fs_stat2inode_dotl(st, inode, 0); + v9fs_set_netfs_context(inode); v9fs_cache_inode_get_cookie(inode); retval = v9fs_get_acl(inode, fid); if (retval)