Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515Ab2JOIEq (ORCPT ); Mon, 15 Oct 2012 04:04:46 -0400 Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]:18314 "EHLO ipmail04.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750925Ab2JOIEo (ORCPT ); Mon, 15 Oct 2012 04:04:44 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvQoAFjDe1B5LH33/2dsb2JhbABFhSm0X4RnAoEEgQmCIAEBBScTHCMQCAMVAy4UDRgDNIdyAw6zFw2JVBSKX2aBZ4E1gkFgA5QXgVSLJIUNgwE Date: Mon, 15 Oct 2012 19:04:27 +1100 From: Dave Chinner To: zwu.kernel@gmail.com Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, linuxram@linux.vnet.ibm.com, viro@zeniv.linux.org.uk, dave@jikos.cz, tytso@mit.edu, cmm@us.ibm.com, Zhi Yong Wu Subject: Re: [RFC v3 12/13] vfs: add debugfs support Message-ID: <20121015080427.GA2739@dastard> References: <1349863655-29320-1-git-send-email-zwu.kernel@gmail.com> <1349863655-29320-13-git-send-email-zwu.kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1349863655-29320-13-git-send-email-zwu.kernel@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2343 Lines: 75 On Wed, Oct 10, 2012 at 06:07:34PM +0800, zwu.kernel@gmail.com wrote: > From: Zhi Yong Wu > > Add a /sys/kernel/debug/hot_track// directory for each > volume that contains two files. The first, `inode_data', contains the > heat information for inodes that have been brought into the hot data map > structures. The second, `range_data', contains similar information for > subfile ranges. > > Signed-off-by: Zhi Yong Wu > --- > fs/hot_tracking.c | 462 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > fs/hot_tracking.h | 43 +++++ > 2 files changed, 505 insertions(+), 0 deletions(-) ..... > +static int hot_debugfs_copy(struct debugfs_vol_data *data, char *msg, int len) > +{ > + struct lstring *debugfs_log = data->debugfs_log; > + uint new_log_alloc_size; > + char *new_log; > + static char err_msg[] = "No more memory!\n"; > + > + if (len >= data->log_alloc_size - debugfs_log->len) { ...... > + } > + > + memcpy(debugfs_log->str + debugfs_log->len, data->log_work_buff, len); > + debugfs_log->len += (unsigned long) len; > + > + return len; > +} > + > +/* Returns the number of bytes written to the log. */ > +static int hot_debugfs_log(struct debugfs_vol_data *data, const char *fmt, ...) > +{ > + struct lstring *debugfs_log = data->debugfs_log; > + va_list args; > + int len; > + static char trunc_msg[] = > + "The next message has been truncated.\n"; > + > + if (debugfs_log->str == NULL) > + return -1; > + > + spin_lock(&data->log_lock); > + > + va_start(args, fmt); > + len = vsnprintf(data->log_work_buff, > + sizeof(data->log_work_buff), fmt, args); > + va_end(args); > + > + if (len >= sizeof(data->log_work_buff)) { > + hot_debugfs_copy(data, trunc_msg, sizeof(trunc_msg)); > + } > + > + len = hot_debugfs_copy(data, data->log_work_buff, len); > + spin_unlock(&data->log_lock); > + > + return len; > +} Aren't you just recreating seq_printf() here? i.e. can't you replace all this complexity with generic seq_file/seq_operations constructs? Cheers, Dave. -- Dave Chinner david@fromorbit.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/