* [PATCH] bcache: use uuid_parse() library function
@ 2026-11-18 7:09 Dmitry Antipov
2026-11-26 15:01 ` Coly Li
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2026-11-18 7:09 UTC (permalink / raw)
To: Jens Axboe, Coly Li, Kent Overstreet; +Cc: linux-bcache, Dmitry Antipov
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] bcache: use uuid_parse() library function
2026-11-18 7:09 [PATCH] bcache: use uuid_parse() library function Dmitry Antipov
@ 2026-11-26 15:01 ` Coly Li
0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2026-11-26 15:01 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Jens Axboe, Kent Overstreet, linux-bcache
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 15:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 7:09 [PATCH] bcache: use uuid_parse() library function Dmitry Antipov
2026-11-26 15:01 ` Coly Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox