From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760775AbbBIPE6 (ORCPT ); Mon, 9 Feb 2015 10:04:58 -0500 Received: from smtprelay0246.hostedemail.com ([216.40.44.246]:45279 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759408AbbBIPE4 (ORCPT ); Mon, 9 Feb 2015 10:04:56 -0500 X-Session-Marker: 6E657665747340676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1544:1593:1594:1605:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2693:2731:2901:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4362:4605:4641:5007:6261:7576:7875:8604:8660:9163:9393:10004:10848:10967:11026:11232:11658:11914:12043:12296:12438:12517:12519:12740:13148:13230:14096:14097:21060:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: camp07_2ae470f491956 X-Filterd-Recvd-Size: 5860 Date: Mon, 9 Feb 2015 10:04:53 -0500 From: Steven Rostedt To: Namhyung Kim Cc: linux-kernel@vger.kernel.org, Al Viro , Greg Kroah-Hartman , Ingo Molnar , Andrew Morton Subject: Re: [for-next][PATCH 3/7] tracefs: Add new tracefs file system Message-ID: <20150209100453.06e89152@gandalf.local.home> In-Reply-To: <20150209055619.GA30788@sejong> References: <20150204143420.290584004@goodmis.org> <20150204143755.373406887@goodmis.org> <20150209055619.GA30788@sejong> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 9 Feb 2015 14:56:19 +0900 Namhyung Kim wrote: > Hi Steve, > > On Wed, Feb 04, 2015 at 09:34:23AM -0500, Steven Rostedt wrote: > > From: "Steven Rostedt (Red Hat)" > > > > Add a separate file system to handle the tracing directory. Currently it > > is part of debugfs, but that is starting to show its limits. > > > > One thing is that in order to access the tracing infrastructure, you need > > to mount debugfs. As that includes debugging from all sorts of sub systems > > in the kernel, it is not considered advisable to mount such an all > > encompassing debugging system. > > > > Having the tracing system in its own file systems gives access to the > > tracing sub system without needing to include all other systems. > > > > Another problem with tracing using the debugfs system is that the > > instances use mkdir to create sub buffers. debugfs does not support mkdir > > from userspace so to implement it, special hacks were used. By controlling > > the file system that the tracing infrastructure uses, this can be properly > > done without hacks. > > > > Signed-off-by: Steven Rostedt > > --- > > [SNIP] > > +/** > > + * tracefs_create_file - create a file in the tracefs filesystem > > + * @name: a pointer to a string containing the name of the file to create. > > + * @mode: the permission that the file should have. > > + * @parent: a pointer to the parent dentry for this file. This should be a > > + * directory dentry if set. If this parameter is NULL, then the > > + * file will be created in the root of the tracefs filesystem. > > + * @data: a pointer to something that the caller will want to get to later > > + * on. The inode.i_private pointer will point to this value on > > + * the open() call. > > + * @fops: a pointer to a struct file_operations that should be used for > > + * this file. > > + * > > + * This is the basic "create a file" function for tracefs. It allows for a > > + * wide range of flexibility in creating a file, or a directory (if you want > > + * to create a directory, the tracefs_create_dir() function is > > + * recommended to be used instead.) > > + * > > + * This function will return a pointer to a dentry if it succeeds. This > > + * pointer must be passed to the tracefs_remove() function when the file is > > + * to be removed (no automatic cleanup happens if your module is unloaded, > > + * you are responsible here.) If an error occurs, %NULL will be returned. > > + * > > + * If tracefs is not enabled in the kernel, the value -%ENODEV will be > > + * returned. > > I cannot find where it returns -ENODEV. AFAICS we cannot call tracefs > functions if tracing was not enabled. Ah, originally I had it like debugfs, where these functions were stubs that would return ENODEV when TRACING was not configured. But then, I decided that nothing should be calling these functions when tracing is not configured. I'll nuke that comment. > > > > + */ > > +struct dentry *tracefs_create_file(const char *name, umode_t mode, > > + struct dentry *parent, void *data, > > + const struct file_operations *fops) > > +{ > > + struct dentry *dentry; > > + struct inode *inode; > > + > > + if (!(mode & S_IFMT)) > > + mode |= S_IFREG; > > + BUG_ON(!S_ISREG(mode)); > > + dentry = start_creating(name, parent); > > + > > + if (IS_ERR(dentry)) > > + return NULL; > > + > > + inode = tracefs_get_inode(dentry->d_sb); > > + if (unlikely(!inode)) > > + return failed_creating(dentry); > > + > > + inode->i_mode = mode; > > + inode->i_fop = fops ? fops : &tracefs_file_operations; > > + inode->i_private = data; > > + d_instantiate(dentry, inode); > > + fsnotify_create(dentry->d_parent->d_inode, dentry); > > + return end_creating(dentry); > > +} > > + > > +/** > > + * tracefs_create_dir - create a directory in the tracefs filesystem > > + * @name: a pointer to a string containing the name of the directory to > > + * create. > > + * @parent: a pointer to the parent dentry for this file. This should be a > > + * directory dentry if set. If this parameter is NULL, then the > > + * directory will be created in the root of the tracefs filesystem. > > + * > > + * This function creates a directory in tracefs with the given name. > > + * > > + * This function will return a pointer to a dentry if it succeeds. This > > + * pointer must be passed to the tracefs_remove() function when the file is > > + * to be removed. If an error occurs, %NULL will be returned. > > + * > > + * If tracing is not enabled in the kernel, the value -%ENODEV will be > > + * returned. > > Ditto. And that one too. Thanks, -- Steve