Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7469828rdb; Wed, 3 Jan 2024 18:16:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IGuxUrPhy76Vq4ltenJct4SLjUzqBVT6DPzJ6oTK+6tOG1O9UQFy1+BmfRJTLDLoJbvwkhD X-Received: by 2002:a05:6e02:1c28:b0:35f:ced5:5555 with SMTP id m8-20020a056e021c2800b0035fced55555mr20079888ilh.25.1704334597336; Wed, 03 Jan 2024 18:16:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704334597; cv=none; d=google.com; s=arc-20160816; b=lDhVBOgI0PrMTQdz6tNW/XWJqwllcOZmY6WhOyngo0iYo2RswHuSoqvzbrPYqPbPai X8qxUd4Y82inoGSMhr1n5a6mpTATeDHMwY8Y8VZ1u4lI5lV2zXS4OOyoKzp0ajcdqv73 X714lIo2Ef1bdmUdG5dIfS3wLcc4m7WmLgoDSY8HEUGjeNW1tLx4yrozPPSlbr8MLH7n erdArJw5mBuVDH2t2x5bsWLpbooVGd9/8fhd9wiKWkg4SY/NvUNtOsUjwZN7TidA5T2j /Xg0P9fdHfzts+hqon3Mu6BWQm3nB7tq424+Cs+EXmqT5AP9hyGJ9cFea/7iBtEESktk VWgw== 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 :subject:cc:to:from:date; bh=KIYiNxF0W//P+cwbTSiRM9m0ZEtRUHu2nHYM6CV7Kek=; fh=OxOp+U/dcy5APTeHcSqFAwgsJF8dU3EWCs0HdGVKAPY=; b=mlFs7tYyrcMNe/MXio1ChoMPkujcgQ/QGBPIxJ9hD2DDqap5T/9d2C+NK+Y+SeEBEd 8/tZSvTjIvm0Z4QxEL3QeCux6RhWx0SALOmRAyAWwUqgLPKfQe07921lqwCCCgVXfEqV 7aEoSVNNMuwG+Q1gXMvuLkZVQlXeihu5QBJHOM5jkUkl1HnvP1uys2IY4Wi3DOCWCMwt T/tk3w+tLkejtOpP0sL1m8XbC/mB6NfUDKGm2QPFZdz3sJy0H33d+QC6W6j6p349ci9+ cWweK9LKTTUPnQ62iw5+ynveRwjEVYgjmsAh1rxtyuRdGYNAqD+smJ3YzTXslhcehRf4 IhNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16199-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16199-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s17-20020a656911000000b005cdf992367dsi20312660pgq.730.2024.01.03.18.16.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 18:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16199-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16199-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16199-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 00A4A2880DC for ; Thu, 4 Jan 2024 02:16:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8BC546B3; Thu, 4 Jan 2024 02:16:27 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 3383E4C60; Thu, 4 Jan 2024 02:16:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3E43C433C8; Thu, 4 Jan 2024 02:16:25 +0000 (UTC) Date: Wed, 3 Jan 2024 21:17:29 -0500 From: Steven Rostedt To: Al Viro Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers , Linus Torvalds , Christian Brauner , linux-fsdevel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH] tracefs/eventfs: Use root and instance inodes as default ownership Message-ID: <20240103211729.68283e87@gandalf.local.home> In-Reply-To: <20240104015910.GP1674809@ZenIV> References: <20240103203246.115732ec@gandalf.local.home> <20240104015910.GP1674809@ZenIV> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Thu, 4 Jan 2024 01:59:10 +0000 Al Viro wrote: > On Wed, Jan 03, 2024 at 08:32:46PM -0500, Steven Rostedt wrote: > > > +static struct inode *instance_inode(struct dentry *parent, struct inode *inode) > > +{ > > + struct tracefs_inode *ti; > > + struct inode *root_inode; > > + > > + root_inode = d_inode(inode->i_sb->s_root); > > + > > + /* If parent is NULL then use root inode */ > > + if (!parent) > > + return root_inode; > > + > > + /* Find the inode that is flagged as an instance or the root inode */ > > + do { > > + inode = d_inode(parent); > > + if (inode == root_inode) > > + return root_inode; > > + > > + ti = get_tracefs(inode); > > + > > + if (ti->flags & TRACEFS_INSTANCE_INODE) > > + return inode; > > + } while ((parent = parent->d_parent)); > > *blink* > > This is equivalent to > ... > parent = parent->d_parent; > } while (true); Yeah, that loop went through a few iterations as I first thought that root was a tracefs_inode and the get_tracefs() would work on it. No, it was not, and it caused a cash. But I didn't rewrite the loop well after fixing that. I was also not sure if parent could be NULL, and wanted to protect against it. > > ->d_parent is *never* NULL. And what the hell is that loop supposed to do, > anyway? Find the nearest ancestor tagged with TRACEFS_INSTANCE_INODE? > > If root is not marked that way, I would suggest > if (!parent) > parent = inode->i_sb->s_root; > while (!IS_ROOT(parent)) { > struct tracefs_inode *ti = get_tracefs(parent->d_inode); > if (ti->flags & TRACEFS_INSTANCE_INODE) > break; > parent = parent->d_parent; > } > return parent->d_inode; Sure, I could rewrite it that way too. Thanks, -- Steve