From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: [PATCH 1/2] vfs: make fcheck_files() an exported functions Date: Wed, 9 Jan 2013 09:01:05 -0800 Message-ID: <20130109170105.GM3926@htj.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, Steven Rostedt , chavey@google.com To: Alexander Viro Return-path: Received: from mail-pb0-f46.google.com ([209.85.160.46]:33757 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932285Ab3AIRBK (ORCPT ); Wed, 9 Jan 2013 12:01:10 -0500 Received: by mail-pb0-f46.google.com with SMTP id wy7so1060038pbc.19 for ; Wed, 09 Jan 2013 09:01:09 -0800 (PST) Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: We want to add a trace point to fcheck_files() but macros and inline functions defined in header files can't have tracing points. Move fcheck_files() to fs/file.c and make it a proper function. A lot of high-frequency fcheck*() users are inside fs/file.c, and, to reduce the effect of this change, the new exported function is also declared inline. Signed-off-by: Tejun Heo Cc: Steven Rostedt Cc: Al Viro --- These two patches add vfs_fcheck tracepoint. Making fcheck_files() a function isn't optimal but given the tracepoint restriction I can't think of a better way. The TP is currently in use in google to allow ioblame to track who's accessing which file which in turn is used to approximately associate IOs with files. I'm working to upstream the rest of ioblame. Thanks. fs/file.c | 11 +++++++++++ include/linux/fdtable.h | 11 +---------- 2 files changed, 12 insertions(+), 10 deletions(-) --- a/fs/file.c +++ b/fs/file.c @@ -709,6 +709,17 @@ void do_close_on_exec(struct files_struc spin_unlock(&files->file_lock); } +inline struct file *fcheck_files(struct files_struct *files, unsigned int fd) +{ + struct file * file = NULL; + struct fdtable *fdt = files_fdtable(files); + + if (fd < fdt->max_fds) + file = rcu_dereference_check_fdtable(files, fdt->fd[fd]); + return file; +} +EXPORT_SYMBOL(fcheck_files); + struct file *fget(unsigned int fd) { struct file *file; --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -75,16 +75,6 @@ struct dentry; extern void __init files_defer_init(void); -static inline struct file * fcheck_files(struct files_struct *files, unsigned int fd) -{ - struct file * file = NULL; - struct fdtable *fdt = files_fdtable(files); - - if (fd < fdt->max_fds) - file = rcu_dereference_check_fdtable(files, fdt->fd[fd]); - return file; -} - /* * Check whether the specified fd has an open file. */ @@ -92,6 +82,7 @@ static inline struct file * fcheck_files struct task_struct; +struct file *fcheck_files(struct files_struct *files, unsigned int fd); struct files_struct *get_files_struct(struct task_struct *); void put_files_struct(struct files_struct *fs); void reset_files_struct(struct files_struct *);