From: Richard Weinberger <richard@nod.at>
To: Per Forlin <per.forlin@axis.com>, linux-block@vger.kernel.org
Cc: linux-mtd@lists.infradead.org,
Artem Bityutskiy <dedekind1@gmail.com>,
derosier@gmail.com, Per Forlin <perfn@axis.com>
Subject: Re: [PATCH v2] UBI: Add volume read and write statistics
Date: Tue, 24 Jul 2018 10:19:07 +0200 [thread overview]
Message-ID: <1633152.d3eLNIHx7g@blindfold> (raw)
In-Reply-To: <1532360342-52055-1-git-send-email-perfn@axis.com>
[Adding linux-block]
Am Montag, 23. Juli 2018, 17:39:02 CEST schrieb Per Forlin:
> Simple read and write statistics.
> * Number of reads
> * Number of writes
> * Bytes read
> * Bytes written
>
> This is useful to find out how the storage is being utilized.
> For block devices this already exists here:
> /sys/class/block/<device>/stat
>
> For UBI it now exists here:
> /sys/class/ubi/<volume>/stat
Please document it also in Documentation/ABI/stable/sysfs-class-ubi.
> Example:
> /sys/class/ubi/ubi0_21/stat
> 864 0 3106756 0 1057 0 2144256 0 0 0 0
>
> The output format is same as for block devices
> except that not all metrics are supported yet.
> Unsupported values are set to 0.
Let's ask block folks what they think about.
Per, did you check, which tools use the stats file in /sys?
I checked iostat, it seems to consume only /proc/diskstats.
To give more context, UBI and MTD devices offer access to raw flash
storage. So, we have filesystems on top of it.
Since these devices are not block devices, almost no tool know
about these.
With this patch we'd like to offer a interface to userspace such that
tools will also discover UBI devices.
Maybe MTD devices later too.
> ---
> Changelog:
>
> v2
> * Question: Translate bytes to sectors? iostats format expects sector unit.
Not sure. I'd wait for input from userspace and block folks.
> * Align with iostats format
> * Only count successful reads and writes
>
> drivers/mtd/ubi/eba.c | 11 ++++++++++-
> drivers/mtd/ubi/ubi.h | 19 +++++++++++++++++++
> drivers/mtd/ubi/vmt.c | 8 ++++++++
> 3 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
> index b98481b..c9a88b2 100644
> --- a/drivers/mtd/ubi/eba.c
> +++ b/drivers/mtd/ubi/eba.c
> @@ -731,6 +731,11 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
> }
> }
>
> + if (!err) {
> + vol->stat.rcount++;
> + vol->stat.rbytes += len;
Can we please have a helper function for that?
> + }
> +
> if (scrub)
> err = ubi_wl_scrub_peb(ubi, pnum);
>
> @@ -1091,8 +1096,12 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
> ubi_free_vid_buf(vidb);
>
> out:
> - if (err)
> + if (err) {
> ubi_ro_mode(ubi);
> + } else {
> + vol->stat.wcount++;
> + vol->stat.wbytes += len;
Same.
> + }
>
> leb_write_unlock(ubi, vol_id, lnum);
>
> diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
> index f5ba97c..0cb00f0 100644
> --- a/drivers/mtd/ubi/ubi.h
> +++ b/drivers/mtd/ubi/ubi.h
> @@ -293,6 +293,23 @@ struct ubi_eba_leb_desc {
> };
>
> /**
> + * struct ubi_volume_stat - Volume statistics
> + * @rbytes: the number of bytes read
> + * @wbytes: the number of bytes written
> + * @rcount: the number of read requests
> + * @wcount: the number of write requests
> + *
> + * This structure contains read and write statistics.
> + *
> + */
> +struct ubi_volume_stat {
> + u64 rbytes;
> + u64 wbytes;
> + u32 rcount;
> + u32 wcount;
Does the wide of these integers also match with block devices?
Thanks,
//richard
prev parent reply other threads:[~2018-07-24 8:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 15:39 [PATCH v2] UBI: Add volume read and write statistics Per Forlin
2018-07-24 8:19 ` Richard Weinberger [this message]
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=1633152.d3eLNIHx7g@blindfold \
--to=richard@nod.at \
--cc=dedekind1@gmail.com \
--cc=derosier@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=per.forlin@axis.com \
--cc=perfn@axis.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