From: "Coly Li" <colyli@fygo.io>
To: "Dmitry Antipov" <dmantipov@yandex.ru>
Cc: "Jens Axboe" <axboe@kernel.dk>,
"Kent Overstreet" <kent.overstreet@linux.dev>,
<linux-bcache@vger.kernel.org>
Subject: Re: [PATCH] bcache: use uuid_parse() library function
Date: Thu, 26 Nov 2026 23:01:21 +0800 [thread overview]
Message-ID: <awhJIgk3StNx84vj@studio.local> (raw)
In-Reply-To: <20261118070929.773487-1-dmantipov@yandex.ru>
Hi Dmitry,
NACK.
The way bcache treats uuid is different from uuid_parse().
Your change may require more restricted UUID string format for the
sysfs interface, which may break exisitng user space applications.
Bcache UUID format is not only the one uuid_parse() accepted, if
you do more testing you will find out.
Thanks.
Coly Li
On Wed, Nov 18, 2026 at 10:09:29AM +0800, Dmitry Antipov wrote:
> Prefer uuid_parse() library function over custom bch_parse_uuid(),
> drop the latter and adjust __cached_dev_store() accordingly.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> drivers/md/bcache/sysfs.c | 10 ++++++----
> drivers/md/bcache/util.c | 29 -----------------------------
> drivers/md/bcache/util.h | 1 -
> 3 files changed, 6 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index cfac56caa804..562a761553ce 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -15,6 +15,7 @@
>
> #include <linux/blkdev.h>
> #include <linux/sort.h>
> +#include <linux/uuid.h>
> #include <linux/sched/clock.h>
>
> extern bool bcache_is_reboot;
> @@ -428,14 +429,15 @@ STORE(__cached_dev)
> }
>
> if (attr == &sysfs_attach) {
> - uint8_t set_uuid[16];
> + uuid_t set_uuid;
>
> - if (bch_parse_uuid(buf, set_uuid) < 16)
> - return -EINVAL;
> + v = uuid_parse(buf, &set_uuid);
> + if (v)
> + return v;
>
> v = -ENOENT;
> list_for_each_entry(c, &bch_cache_sets, list) {
> - v = bch_cached_dev_attach(dc, c, set_uuid);
> + v = bch_cached_dev_attach(dc, c, set_uuid.b);
> if (!v)
> return size;
> }
> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
> index 410d8cb49e50..f7b4b325e6c7 100644
> --- a/drivers/md/bcache/util.c
> +++ b/drivers/md/bcache/util.c
> @@ -131,35 +131,6 @@ bool bch_is_zero(const char *p, size_t n)
> return true;
> }
>
> -int bch_parse_uuid(const char *s, char *uuid)
> -{
> - size_t i, j, x;
> -
> - memset(uuid, 0, 16);
> -
> - for (i = 0, j = 0;
> - i < strspn(s, "-0123456789:ABCDEFabcdef") && j < 32;
> - i++) {
> - x = s[i] | 32;
> -
> - switch (x) {
> - case '0'...'9':
> - x -= '0';
> - break;
> - case 'a'...'f':
> - x -= 'a' - 10;
> - break;
> - default:
> - continue;
> - }
> -
> - if (!(j & 1))
> - x <<= 4;
> - uuid[j++ >> 1] |= x;
> - }
> - return i;
> -}
> -
> void bch_time_stats_update(struct time_stats *stats, uint64_t start_time)
> {
> uint64_t now, duration, last;
> diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
> index f61ab1bada6c..50d7eac9da48 100644
> --- a/drivers/md/bcache/util.h
> +++ b/drivers/md/bcache/util.h
> @@ -342,7 +342,6 @@ static inline int bch_strtoul_h(const char *cp, long *res)
> ssize_t bch_hprint(char *buf, int64_t v);
>
> bool bch_is_zero(const char *p, size_t n);
> -int bch_parse_uuid(const char *s, char *uuid);
>
> struct time_stats {
> spinlock_t lock;
> --
> 2.56.1
prev parent reply other threads:[~2026-11-26 15:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 7:09 [PATCH] bcache: use uuid_parse() library function Dmitry Antipov
2026-11-26 15:01 ` 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=awhJIgk3StNx84vj@studio.local \
--to=colyli@fygo.io \
--cc=axboe@kernel.dk \
--cc=dmantipov@yandex.ru \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
/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