Linux-bcache Archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: ye.xingchen@zte.com.cn
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bcache: Convert to use sysfs_emit()/sysfs_emit_at() APIs
Date: Wed, 7 Dec 2022 21:04:50 +0800	[thread overview]
Message-ID: <0DC3481B-747E-4874-BDD5-47016A0C4916@suse.de> (raw)
In-Reply-To: <202212071702359325169@zte.com.cn>



> 2022年12月7日 17:02,<ye.xingchen@zte.com.cn> <ye.xingchen@zte.com.cn> 写道:
> 
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Added to my for-next queue for Linux v6.3 merge window.

Thanks.

Coly Li


> ---
> drivers/md/bcache/sysfs.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index c6f677059214..0e2c1880f60b 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -1111,26 +1111,25 @@ SHOW(__bch_cache)
> 
> vfree(p);
> 
> - ret = scnprintf(buf, PAGE_SIZE,
> - "Unused: %zu%%\n"
> - "Clean: %zu%%\n"
> - "Dirty: %zu%%\n"
> - "Metadata: %zu%%\n"
> - "Average: %llu\n"
> - "Sectors per Q: %zu\n"
> - "Quantiles: [",
> - unused * 100 / (size_t) ca->sb.nbuckets,
> - available * 100 / (size_t) ca->sb.nbuckets,
> - dirty * 100 / (size_t) ca->sb.nbuckets,
> - meta * 100 / (size_t) ca->sb.nbuckets, sum,
> - n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
> + ret = sysfs_emit(buf,
> + "Unused: %zu%%\n"
> + "Clean: %zu%%\n"
> + "Dirty: %zu%%\n"
> + "Metadata: %zu%%\n"
> + "Average: %llu\n"
> + "Sectors per Q: %zu\n"
> + "Quantiles: [",
> + unused * 100 / (size_t) ca->sb.nbuckets,
> + available * 100 / (size_t) ca->sb.nbuckets,
> + dirty * 100 / (size_t) ca->sb.nbuckets,
> + meta * 100 / (size_t) ca->sb.nbuckets, sum,
> + n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
> 
> for (i = 0; i < ARRAY_SIZE(q); i++)
> - ret += scnprintf(buf + ret, PAGE_SIZE - ret,
> - "%u ", q[i]);
> + ret += sysfs_emit_at(buf, ret, "%u ", q[i]);
> ret--;
> 
> - ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
> + ret += sysfs_emit_at(buf, ret, "]\n");
> 
> return ret;
> }
> -- 
> 2.25.1


      reply	other threads:[~2022-12-07 13:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  9:02 [PATCH] bcache: Convert to use sysfs_emit()/sysfs_emit_at() APIs ye.xingchen
2022-12-07 13:04 ` Coly Li [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=0DC3481B-747E-4874-BDD5-47016A0C4916@suse.de \
    --to=colyli@suse.de \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ye.xingchen@zte.com.cn \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).