From: Dave Chinner <david@fromorbit.com>
To: Bill O'Donnell <billodo@redhat.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/3] xfs: create global stats and stats_clear in sysfs
Date: Sat, 5 Sep 2015 13:31:21 +1000 [thread overview]
Message-ID: <20150905033121.GN26895@dastard> (raw)
In-Reply-To: <1441400050-8455-2-git-send-email-billodo@redhat.com>
On Fri, Sep 04, 2015 at 03:54:08PM -0500, Bill O'Donnell wrote:
> Currently, xfs global stats are in procfs. This patch introduces
> (replicates) the global stats in sysfs. Additionally a stats_clear file
> is introduced in sysfs.
>
....
>
> +int xfs_stats_format(char *buf)
> +{
> + int i, j;
> + int len = 0;
> + __uint64_t xs_xstrat_bytes = 0;
> + __uint64_t xs_write_bytes = 0;
> + __uint64_t xs_read_bytes = 0;
....
> + len += snprintf(buf+len, PATH_MAX-len, "xpc %Lu %Lu %Lu\n",
> + xs_xstrat_bytes, xs_write_bytes, xs_read_bytes);
> + len += snprintf(buf+len, PATH_MAX-len, "debug %u\n",
> +#if defined(DEBUG)
> + 1);
> +#else
> + 0);
> +#endif
> +
> +return len;
> +}
missing tab on return.
....
> +STATIC ssize_t
> +xfs_stats_show(
> + struct kobject *kobject,
> + struct attribute *attr,
> + char *buf)
> +{
> + struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> +
> + return xfs_attr->show ? xfs_attr->show(buf, NULL) : 0;
> +}
> +
> +STATIC ssize_t
> +xfs_stats_store(
> + struct kobject *kobject,
> + struct attribute *attr,
> + const char *buf,
> + size_t count)
> +{
> + struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> +
> + return xfs_attr->store ? xfs_attr->store(buf, count, NULL) : 0;
> +}
> +
> +static struct sysfs_ops xfs_stats_ops = {
> + .show = xfs_stats_show,
> + .store = xfs_stats_store,
> +};
Hmmm, I'm wondering if we can reduce this boiler plate code here.
It's basically indentical to xfs_log_show/store and
xfs_dbg_show/store. TO make them indentical, all we need to do is
pass the kobject through as the data object, and have the show/store
function decode it if necessary (i.e. call to_xlog() for the xfs log
attributes). This them means that all the sysfs entries
attributes use the same sysfs_ops structure.
That can be done as a patch on top of this, though (i.e. patch #4).
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-09-05 3:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 20:54 [PATCH 0/3 V3] xfs: new global stats in sysfs Bill O'Donnell
2015-09-04 20:54 ` [PATCH 1/3] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-05 3:31 ` Dave Chinner [this message]
2015-09-04 20:54 ` [PATCH 2/3] xfs: create symlink proc/fs/xfs/stat to sys/fs/xfs/stats Bill O'Donnell
2015-09-04 20:54 ` [PATCH 3/3] xfs: remove unused procfs code Bill O'Donnell
2015-09-04 21:34 ` [PATCH 0/3 V3] xfs: new global stats in sysfs Eric Sandeen
-- strict thread matches above, loose matches on Subject: below --
2015-09-04 12:55 [PATCH 0/3 V2] " Bill O'Donnell
2015-09-04 12:55 ` [PATCH 1/3] xfs: create global stats and stats_clear " Bill O'Donnell
2015-09-04 20:13 ` Eric Sandeen
2015-09-04 20:15 ` Bill O'Donnell
2015-09-03 16:36 [PATCH 0/3] xfs: new global stats " billodo
2015-09-03 16:36 ` [PATCH 1/3] xfs: create global stats and stats_clear " billodo
2015-09-03 19:56 ` Eric Sandeen
2015-09-03 20:11 ` Eric Sandeen
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=20150905033121.GN26895@dastard \
--to=david@fromorbit.com \
--cc=billodo@redhat.com \
--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