public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: Re: [PATCH 6/7] xfs: per-filesystem stats in sysfs.
Date: Mon, 28 Sep 2015 10:37:41 -0500	[thread overview]
Message-ID: <56095EC5.102@sandeen.net> (raw)
In-Reply-To: <1443223380-18870-7-git-send-email-billodo@redhat.com>

On 9/25/15 6:22 PM, Bill O'Donnell wrote:
> This patch implements per-filesystem stats objects in sysfs. It
> depends on the application of the previous patch series that
> develops the infrastructure to support both xfs global stats and
> xfs per-fs stats in sysfs.
> 
> Stats objects are instantiated when an xfs filesystem is mounted
> and deleted on unmount. With this patch, the stats directory is
> created and populated with the familiar stats and stats_clear files.
> Example:
>         /sys/fs/xfs/sda9/stats/stats
>         /sys/fs/xfs/sda9/stats/stats_clear
> 
> With this patch, the individual counts within the new per-fs
> stats file(s) remain at zero. Functions that use the the macros
> to increment, decrement, and add-to the per-fs stats counts will
> be covered in a separate new patch to follow this one. Note that
> the counts within the global stats file (/sys/fs/xfs/stats/stats)
> advance normally and can be cleared as it was prior to this patch.
> 
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>
> ---
>  fs/xfs/xfs_linux.h |  4 ++--
>  fs/xfs/xfs_mount.c | 24 +++++++++++++++++++++++-
>  fs/xfs/xfs_mount.h |  1 +
>  fs/xfs/xfs_stats.c | 34 +++++++++++++++++++---------------
>  fs/xfs/xfs_stats.h |  5 ++++-
>  fs/xfs/xfs_super.c | 21 ++++++++++++++++-----
>  fs/xfs/xfs_sysfs.c |  6 +++---
>  7 files changed, 68 insertions(+), 27 deletions(-)

> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index bf92e0c..5921d18 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -791,11 +791,25 @@ xfs_mountfs(
>  		goto out_free_dir;
>  	}
>  
> +	/*
> +	 * Allocate stats memory and create stats sysfs object.
> +	 */
> +	mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
> +	if (IS_ERR(mp->m_stats.xs_stats)) {
> +		error = PTR_ERR(mp->m_stats.xs_stats);
> +		goto out_free_perag;
> +	}

alloc_percpu simply returns NULL on failure AFAIK, so looking for IS_ERR
doesn't seem right.

Also, I think the placement of this in the routine is a little odd;
I'd move it up right under where we create the per-fs sysfs entry, i.e.:

        error = xfs_sysfs_init(&mp->m_kobj, &xfs_mp_ktype, NULL, mp->m_fsname);
        if (error)
                goto out;

+	/*
+	 * Allocate stats memory and create stats sysfs object.
+	 */
+	mp->m_stats.xs_stats = alloc_percpu(struct xfsstats);
+	if (!mp->m_stats.xs_stats) {
+		error = -ENOMEM;
+		goto out_free_perag;
+	}

... etc ...

so that all the sysfs gunk is in the same area.


> +	error = xfs_sysfs_init(&mp->m_stats.xs_kobj, &xfs_stats_ktype,
> +				&mp->m_kobj,
> +				"stats");
> +	if (error)
> +		goto out_free_stats;
> +
>  	if (!sbp->sb_logblocks) {
>  		xfs_warn(mp, "no log defined");
>  		XFS_ERROR_REPORT("xfs_mountfs", XFS_ERRLEVEL_LOW, mp);
>  		error = -EFSCORRUPTED;
> -		goto out_free_perag;
> +		goto out_del_stats;
>  	}
>  
>  	/*
> @@ -965,6 +979,10 @@ xfs_mountfs(
>  	if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp)
>  		xfs_wait_buftarg(mp->m_logdev_targp);
>  	xfs_wait_buftarg(mp->m_ddev_targp);
> + out_del_stats:
> +	xfs_sysfs_del(&mp->m_stats.xs_kobj);
> + out_free_stats:
> +	free_percpu(mp->m_stats.xs_stats);
>   out_free_perag:
>  	xfs_free_perag(mp);
>   out_free_dir:
> @@ -1047,6 +1065,10 @@ xfs_unmountfs(
>  		xfs_warn(mp, "Unable to update superblock counters. "
>  				"Freespace may not be correct on next mount.");
>  
> +	/* remove the stats kobject and free stats memory */
> +	xfs_sysfs_del(&mp->m_stats.xs_kobj);
> +	free_percpu(mp->m_stats.xs_stats);
> +
>  	xfs_log_unmount(mp);
>  	xfs_da_unmount(mp);
>  	xfs_uuid_unmount(mp);
> diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> index 7999e91..8795272 100644
> --- a/fs/xfs/xfs_mount.h
> +++ b/fs/xfs/xfs_mount.h
> @@ -127,6 +127,7 @@ typedef struct xfs_mount {
>  	int64_t			m_low_space[XFS_LOWSP_MAX];
>  						/* low free space thresholds */
>  	struct xfs_kobj		m_kobj;
> +	struct xstats		m_stats;	/* per-fs stats */
>  
>  	struct workqueue_struct *m_buf_workqueue;
>  	struct workqueue_struct	*m_data_workqueue;
> diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
> index ab79973..d5b3704 100644
> --- a/fs/xfs/xfs_stats.c
> +++ b/fs/xfs/xfs_stats.c
> @@ -18,6 +18,11 @@
>  #include "xfs.h"
>  #include <linux/proc_fs.h>
>  
> +#include "xfs_format.h"
> +#include "xfs_trans_resv.h"
> +#include "xfs_mount.h"
> +#include "xfs_sysfs.h"

AFAICT, none of these includes are needed

...

> @@ -1843,17 +1842,26 @@ init_xfs_fs(void)
>  	}
>  
>  	xfsstats.xs_stats = alloc_percpu(struct xfsstats);
> +	if (!xfsstats.xs_stats) {
> +		error = -ENOMEM;
> +		goto out_kset_unregister;
> +	}

This error checking should be added when xs_stats is introduced
in patch 5.

>  	xfsstats.xs_kobj.kobject.kset = xfs_kset;
> +	if (!xfsstats.xs_kobj.kobject.kset) {
> +		error = -ENOMEM;
> +		goto out_free_stats;
> +	}
> +

this can't fail, you're just assigning one thing to another, no need
for this test.  We already tested for failure to allocate xfs_kset.

>  	error = xfs_sysfs_init(&xfsstats.xs_kobj, &xfs_stats_ktype, NULL,
> -			       "stats");
> +				"stats");

if this is the alignment you want, do it in the patch that introduced it...

>  	if (error)
> -		goto out_kset_unregister;
> +		goto out_free_stats;
>  
>  #ifdef DEBUG
>  	xfs_dbg_kobj.kobject.kset = xfs_kset;
>  	error = xfs_sysfs_init(&xfs_dbg_kobj, &xfs_dbg_ktype, NULL, "debug");
>  	if (error)
> -		goto out_remove_stats;
> +		goto out_del_stats;
>  #endif
>  
>  	error = xfs_qm_init();
> @@ -1870,8 +1878,10 @@ init_xfs_fs(void)
>   out_remove_dbg_kobj:
>  #ifdef DEBUG
>  	xfs_sysfs_del(&xfs_dbg_kobj);
> - out_remove_stats:
> + out_del_stats:

hm, why that name?  If we have:

 out_remove_dbg_kobj:
 	xfs_sysfs_del(&xfs_dbg_kobj);

then we should have:

 out_remove_stats_kobj:
	xfs_sysfs_del(&xfsstats.xs_kobj);

for consistency, I think.


> diff --git a/fs/xfs/xfs_stats.h b/fs/xfs/xfs_stats.h
> index 672fe83..00afc13 100644
> --- a/fs/xfs/xfs_stats.h
> +++ b/fs/xfs/xfs_stats.h
> @@ -218,13 +218,16 @@ int xfs_stats_format(struct xfsstats __percpu *stats, char *buf);
>  void xfs_stats_clearall(struct xfsstats __percpu *stats);
>  extern struct xstats xfsstats;
>  
> +struct xfs_mount;

I don't think that's needed.

-Eric

> +
>  /*
>   * We don't disable preempt, not too worried about poking the
>   * wrong CPU's stat for now (also aggregated before reporting).
>   */



_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-09-28 15:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 23:22 [PATCH 0/7 v8] xfs: stats in sysfs Bill O'Donnell
2015-09-25 23:22 ` [PATCH 1/7] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-25 23:22 ` [PATCH 2/7] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
2015-09-25 23:22 ` [PATCH 3/7] xfs: remove unused procfs code Bill O'Donnell
2015-09-25 23:22 ` [PATCH 4/7] xfs: consolidate sysfs ops (dbg, stats, log) Bill O'Donnell
2015-09-25 23:22 ` [PATCH 5/7] xfs: incorporate sysfs/kobject in xfsstats: handlers take kobjects Bill O'Donnell
2015-09-28 15:40   ` Eric Sandeen
2015-09-25 23:22 ` [PATCH 6/7] xfs: per-filesystem stats in sysfs Bill O'Donnell
2015-09-28 15:37   ` Eric Sandeen [this message]
2015-09-25 23:23 ` [PATCH 7/7] xfs: per-filesystem stats counter implementation Bill O'Donnell
2015-09-28 15:30   ` Eric Sandeen
2015-09-28 15:00 ` [PATCH 0/7 v8] xfs: stats in sysfs Eric Sandeen
2015-09-28 15:01   ` Eric Sandeen
2015-09-28 15:06   ` Bill O'Donnell
  -- strict thread matches above, loose matches on Subject: below --
2015-09-28 21:33 [PATCH 0/7 v9] " Bill O'Donnell
2015-09-28 21:33 ` [PATCH 6/7] xfs: per-filesystem " Bill O'Donnell
2015-09-29 12:43 Bill O'Donnell
2015-10-02 16:22 [PATCH 0/7 v10] xfs: per-fs " Bill O'Donnell
2015-10-02 16:22 ` [PATCH 6/7] xfs: per-filesystem " Bill O'Donnell
2015-10-07  6:29   ` Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56095EC5.102@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox