Re: [PATCH 4/8 v2] xfs: use common code for quota statistics

Ben Myers
2012-03-12T17:55:12Z

On Mon, Feb 20, 2012 at 08:48:09PM -0500, Christoph Hellwig wrote:
> Switch the quota code over to use the generic XFS statistics infrastructure.
> While the legacy /proc/fs/xfs/xqm and /proc/fs/xfs/xqmstats interfaces are
> preserved for now the statistics that still have a meaning with the current
> code are now also available from /proc/fs/xfs/stats.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

...

> +/* legacy quota interfaces */
> +#ifdef CONFIG_XFS_QUOTA
> +static int xqm_proc_show(struct seq_file *m, void *v)
> +{
> + /* maximum; incore; ratio free to inuse; freelist */
> + seq_printf(m, "%d\t%d\t%d\t%u\n",
> + 0,
> + counter_val(XFSSTAT_END_XQMSTAT),

That's xfs_qm_dquot

> + 0,
> + counter_val(XFSSTAT_END_XQMSTAT + 1));

and xfs_qm_dquot_unused? A comment would make your intent clear.

> + return 0;
> +}
> +
> +static int xqm_proc_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, xqm_proc_show, NULL);
> +}
> +
> +static const struct file_operations xqm_proc_fops = {
> + .owner = THIS_MODULE,
> + .open = xqm_proc_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +/* legacy quota stats interface no 2 */
> +static int xqmstat_proc_show(struct seq_file *m, void *v)
> +{
> + int j;
> +
> + seq_printf(m, "qm");
> + for (j = XFSSTAT_END_IBT_V2; j < XFSSTAT_END_XQMSTAT; j++)
> + seq_printf(m, " %u", counter_val(j));

And a comment here with all of the stuff you're printing out would be
total overkill. Nevermind. ;)

...

> int
> xfs_init_procfs(void)
> {
> @@ -105,10 +162,24 @@ xfs_init_procfs(void)
>
> if (!proc_create("fs/xfs/stat", 0, NULL,
> &xfs_stat_proc_fops))
> - goto out_remove_entry;
> + goto out_remove_xfs_dir;
> +#ifdef CONFIG_XFS_QUOTA
> + if (!proc_create("fs/xfs/xqmstat", 0, NULL,
> + &xqmstat_proc_fops))
> + goto out_remove_stat_file;
> + if (!proc_create("fs/xfs/xqm", 0, NULL,
> + &xqm_proc_fops))
> + goto out_remove_xqmstat_file;
> +#endif
> return 0;
>
> - out_remove_entry:
> +#ifdef CONFIG_XFS_QUOTA
> + out_remove_xqmstat_file:
> + remove_proc_entry("fs/xfs/xqmstat", NULL);
> + out_remove_stat_file:
> + remove_proc_entry("fs/xfs/stat", NULL);
> +#endif
> + out_remove_xfs_dir:

I'm glad to see that you added error handling here. There wasn't any in
the xfs_qm_init_procfs before.

This patch looks great. It might break some PCP scripts, I'm not sure.

Reviewed-by: Ben Myers <bpm@sgi.com>