Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7463309rdb; Wed, 3 Jan 2024 17:59:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3uHm6cjYU1Q+H6FLxlLLwPUHFR+MNpKvym+O67uvQ7T7NkS8+hpYMa/F2Ma8ptTLz+mu4 X-Received: by 2002:a05:600c:4e4f:b0:40d:942a:9dc6 with SMTP id e15-20020a05600c4e4f00b0040d942a9dc6mr265114wmq.74.1704333570538; Wed, 03 Jan 2024 17:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704333570; cv=none; d=google.com; s=arc-20160816; b=KHvWaP1E5U6fUvPHlFiQrv+cwvLgw4dyz7sZcHp5w5ZRBqpzVGFPWgsLPJSPvx2dal +grV7/wsudy3p+oc1uKF//nxX01XDREMWaCx8sZyjEa3MP+v/6dabPXhJgPON3JDCgwk z1cFIVs/R/2qGt5VWbRSFHl3U/P1TsGuuQRJYpFYK9aGCC1+N8MYlOTrNDdE34AuI5+X VNe1Bs42Qev/bCdAVzQF1yeZkyOiEDJ212l8lIpHlxQrPUmAW8NGleAZ2Y7os3KkSQ53 3ODiwLR4x8+nCz0E0rBn4KzEofRJ4INXxnjqdhVTiRtYi6gdMuJpfbWMTYhd//T+nJaz txyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=50vnkKqSI2ElofoXuNRHthO0fhpyNkEcJnzn+Vbbcqw=; fh=LVijBhQIFqKzwXXSERkvN96JucKU5xZhL1iTTTVYrKA=; b=g5IP7EJGdULj4NPWKryF36FZuyz7V/st6HHfxTb/0RXfRBuMDrycYrb2B7TfX1oujf 2TzQo5XrNJ9xLhb69knPRGLpjpK8xjd446GGla5OO7DBZ3ElvPdR39YrL44myeW0bZYV Mu6GUrUpaehnQiHcV7lqIla/+liSFpymmGKFOrymkzHeIIweQnSXDhqQHbkQmJEzcezT Ug2YZTD6ip2BXnZWTo9bwbCD/3nLF10MAQRwcm4R+lst1eUXOctyGCo/GxNhcF4pGZmB ZomH7idcXe/8fmyIVygYr9svfGVmE+bkWSnETbneqIPK8DOIj3nmXNLSnW/y/w/8Vuc0 AciQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=J8l+VDcL; spf=pass (google.com: domain of linux-kernel+bounces-16192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gk7-20020a17090790c700b00a26e2577923si8554203ejb.912.2024.01.03.17.59.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 17:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=J8l+VDcL; spf=pass (google.com: domain of linux-kernel+bounces-16192-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16192-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4936B1F26299 for ; Thu, 4 Jan 2024 01:59:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E726E1FB4; Thu, 4 Jan 2024 01:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="J8l+VDcL" X-Original-To: linux-kernel@vger.kernel.org Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 F0B66184F; Thu, 4 Jan 2024 01:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=50vnkKqSI2ElofoXuNRHthO0fhpyNkEcJnzn+Vbbcqw=; b=J8l+VDcLQvSxw0Q3MJiAc8inTQ 761LSOKKg5XjajP92QGlxT5f7n+nFoxCPNG3i0F4MDluSFy6WI757sNzY7Ud1fHFlTs7SAm9LjMbd dNwCUOhDvakGnnXJbxrDhNyf22tJOS96Li48c0YZAnDwL6CosLkeS9b+bl3tHQES3O1bwy70zjyAt G7Q6M2Ys4L54CFIK5C6UsydMpCAIzn1yNE1kXZdcSOuiHPs83eM+5zsSSHf9tuWz4lUJqfmEaBHT8 evNYVPABm/iKjnBIBZPlul/tpU9JYaAvGmnEVnXKvqHYmOB94DHZumTDnMCDbNnvHAApzwR9uFqBZ gSl9xHqg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rLD0o-0013z7-0o; Thu, 04 Jan 2024 01:59:10 +0000 Date: Thu, 4 Jan 2024 01:59:10 +0000 From: Al Viro To: Steven Rostedt 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: <20240104015910.GP1674809@ZenIV> References: <20240103203246.115732ec@gandalf.local.home> 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-Disposition: inline In-Reply-To: <20240103203246.115732ec@gandalf.local.home> Sender: Al Viro 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); ->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;