Message ID | 20240204011830.644439410@goodmis.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp149088dyb; Sat, 3 Feb 2024 17:26:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJvaNreuxsT+iGYysABjbEMTiK0S1TI8FsqRTFw3gU0PpEpSxOimkzbz72nqK7nvR9Az1y X-Received: by 2002:a05:6a20:da85:b0:19e:4f07:16c3 with SMTP id iy5-20020a056a20da8500b0019e4f0716c3mr6324431pzb.55.1707009973013; Sat, 03 Feb 2024 17:26:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707009973; cv=pass; d=google.com; s=arc-20160816; b=ZdyKFCD/Ei4CFzMT1t6OkEjrlGKgl7uP1dWHQ8oGL2ZZIZJ3BUdK++Nv58+aJ2sWqP u+UkpmIVmYoOddlJwqZH1fS3DaKBZ05yWRD9imJ+yP6RD/fwr3//QaAXAO0y4veUuKQg ryBeEU2wZQ3c+bfVYB5uzxe0pw0bXFAoGWPzGzXS/8KkwdqR62FdY2PRU+MDr+BtrQ7V DhfPPJ5mGJFTtD0QDJNRAvwC3oBrcD366Kgmk/ii3BarFvxymF1w91FSJDCeB1kFKJKU hqf8L9RR+Sm4Zc7jDYfcZKx4oZ292p3AnloOYDqXOHDpMhQHzLbdYi7w1LGDH0wIKxPY Xpeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=4GpbK88Sjv3E086VZC2iFw20VfSgG6CnwKNDusGLVJA=; fh=CR1xVXqqYuEBi23csitwDmJ0qTuToErM+URwkAIfYeg=; b=dkDp1XDILT9KPl50xVIOXmwCFslAyMGXSKqlSqqegS+DZrdelYYnpiw3LkpQacdCAw BGtLBVCW02jqiEYlCNvHaRlYuMR3aZcMeIl37sq5wF1MOXge93cRTzPwHu2/Q+wWuyzI QlFEA1vmiugumbN1Kfph/0lUj9EH7U7Yth1IjRG4f25xCSIsNp5G0Z/qNr5XDC/U/0MZ Arq8JJiOAg+igHE4yzrbIS3UkbtRgAlyF5UVn2pmftVPNbwYBwW2TLSSlAoZau6WejnB EuD1vSasuTQ3G7X0WmkeYNZId7DifWpOjegtKj/gwyopTiNEdLO3FcyhdWWdZZZCceOF g6Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXKlmzQ0hNYbe8ODQLCLd6yTvgO2We65YoafWVFUNamBpBlt8vbgsf9PokRBFF5kS5umwob8/QdJlsAYe+pzC97X+EHhw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n15-20020aa7984f000000b006de3b4d5865si3756254pfq.157.2024.02.03.17.26.12 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 17:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51359-ouuuleilei=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BE3E7B258C5 for <ouuuleilei@gmail.com>; Sun, 4 Feb 2024 01:23:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E5AD18C3A; Sun, 4 Feb 2024 01:18:13 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6245910A35; Sun, 4 Feb 2024 01:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707009488; cv=none; b=TnelbHwJLYvabgAKCE2RUzoYslItwg/Kwpwgeqi6obD6Oy40aGqmPcObqGBBMRi9iC3yN2Q1vf4NZJGl9FsDaf0hQNFdkz5qGsiNmZ+6+NLmuB2P2Vi5ElzQHEIbHUcGHPaTy2CU5SrOku4m0Kydc/+F6Ojl63nI51KHHLwFdTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707009488; c=relaxed/simple; bh=Dq6x99Zk/Vun27CnDuFYUGrU4i510huChkfoAHC46Jo=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=XIYOrdg7xT403U3vVMIvH/0XfsItB+o7SLlhLp2AMzeC13xBtRe5g7J2lAOALrwGwmIofd/LRdZ18o6/IewfVZca4SUymDcaSjq7DANeB8h3URmkLRo+gxJDl/zcqETQ0gtPUb8srilvZ6MfYEkVu2mJIzphw5+D3gaJUlZDRF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E319C43601; Sun, 4 Feb 2024 01:18:08 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from <rostedt@goodmis.org>) id 1rWR9S-00000006Ovr-3Hf2; Sat, 03 Feb 2024 20:18:30 -0500 Message-ID: <20240204011830.644439410@goodmis.org> User-Agent: quilt/0.67 Date: Sat, 03 Feb 2024 20:16:38 -0500 From: Steven Rostedt <rostedt@goodmis.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Torvalds <torvalds@linux-foundation.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Sasha Levin <sashal@kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Andrew Morton <akpm@linux-foundation.org>, Christian Brauner <brauner@kernel.org>, Al Viro <viro@ZenIV.linux.org.uk>, Ajay Kaher <ajay.kaher@broadcom.com>, Al Viro <viro@zeniv.linux.org.uk> Subject: [v6.7][PATCH 23/23] eventfs: Keep all directory links at 1 References: <20240204011615.703023949@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789929689639206829 X-GMAIL-MSGID: 1789929689639206829 |
Series |
eventfs: Linus's updates for 6.7
|
|
Commit Message
Steven Rostedt
Feb. 4, 2024, 1:16 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org> The directory link count in eventfs was somewhat bogus. It was only being updated when a directory child was being looked up and not on creation. One solution would be to update in get_attr() the link count by iterating the ei->children list and then adding 2. But that could slow down simple stat() calls, especially if it's done on all directories in eventfs. Another solution would be to add a parent pointer to the eventfs_inode and keep track of the number of sub directories it has on creation. But this adds overhead for something not really worthwhile. The solution decided upon is to keep all directory links in eventfs as 1. This tells user space not to rely on the hard links of directories. Which in this case it shouldn't. Link: https://lore.kernel.org/linux-trace-kernel/20240201002719.GS2087318@ZenIV/ Link: https://lore.kernel.org/linux-trace-kernel/20240201161617.339968298@goodmis.org Cc: stable@vger.kernel.org Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Christian Brauner <brauner@kernel.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Ajay Kaher <ajay.kaher@broadcom.com> Fixes: c1504e510238 ("eventfs: Implement eventfs dir creation functions") Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> --- fs/tracefs/event_inode.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 9e031e5a2713..110e8a272189 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -404,9 +404,7 @@ static struct dentry *lookup_dir_entry(struct dentry *dentry, dentry->d_fsdata = get_ei(ei); - inc_nlink(inode); d_add(dentry, inode); - inc_nlink(dentry->d_parent->d_inode); return NULL; } @@ -769,9 +767,17 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry dentry->d_fsdata = get_ei(ei); - /* directory inodes start off with i_nlink == 2 (for "." entry) */ - inc_nlink(inode); + /* + * Keep all eventfs directories with i_nlink == 1. + * Due to the dynamic nature of the dentry creations and not + * wanting to add a pointer to the parent eventfs_inode in the + * eventfs_inode structure, keeping the i_nlink in sync with the + * number of directories would cause too much complexity for + * something not worth much. Keeping directory links at 1 + * tells userspace not to trust the link number. + */ d_instantiate(dentry, inode); + /* The dentry of the "events" parent does keep track though */ inc_nlink(dentry->d_parent->d_inode); fsnotify_mkdir(dentry->d_parent->d_inode, dentry); tracefs_end_creating(dentry);