Re: [RFC v3 12/13] vfs: add debugfs support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 10, 2012 at 06:07:34PM +0800, zwu.kernel@xxxxxxxxx wrote:
> From: Zhi Yong Wu <wuzhy@xxxxxxxxxxxxxxxxxx>
> 
>   Add a /sys/kernel/debug/hot_track/<device_name>/ 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 <wuzhy@xxxxxxxxxxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux