summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-06-22 08:54:31 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-06-22 08:54:31 -0400
commitcea4c02f0fdb5c3b398de5bb33b14cab21dde088 (patch)
tree19cfcd726a9a29c46f4b65fc95d2b4a6a67bda6b
parenteac40840098bfbb5fa1711f6bbce71b27bbccb89 (diff)
bcachefs: Switch to uuid_t instead of uuid_le
uuid_le is being removed, and it wasn't even correct for bcachefs since we weren't printing uuids as little endian. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/bcachefs.h6
-rw-r--r--fs/bcachefs/bcachefs_format.h21
-rw-r--r--fs/bcachefs/bcachefs_ioctl.h2
-rw-r--r--fs/bcachefs/super-io.c12
-rw-r--r--fs/bcachefs/super-io.h4
-rw-r--r--fs/bcachefs/super.c8
-rw-r--r--fs/bcachefs/super.h2
-rw-r--r--fs/bcachefs/util.h5
8 files changed, 31 insertions, 29 deletions
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index 80b97e0f2196..1ae493d1c60c 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -489,7 +489,7 @@ struct bch_dev {
* Committed by bch2_write_super() -> bch_fs_mi_update()
*/
struct bch_member_cpu mi;
- uuid_le uuid;
+ uuid_t uuid;
char name[BDEVNAME_SIZE];
struct bch_sb_handle disk_sb;
@@ -707,8 +707,8 @@ struct bch_fs {
/* Updated by bch2_sb_update():*/
struct {
- uuid_le uuid;
- uuid_le user_uuid;
+ uuid_t uuid;
+ uuid_t user_uuid;
u16 version;
u16 version_min;
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h
index 4d142b2e3bf6..d1c5214fde58 100644
--- a/fs/bcachefs/bcachefs_format.h
+++ b/fs/bcachefs/bcachefs_format.h
@@ -1215,7 +1215,7 @@ struct bch_sb_field_journal_v2 {
#define BCH_MIN_NR_NBUCKETS (1 << 6)
struct bch_member {
- uuid_le uuid;
+ uuid_t uuid;
__le64 nbuckets; /* device size */
__le16 first_bucket; /* index of first bucket used */
__le16 bucket_size; /* sectors */
@@ -1596,7 +1596,7 @@ static const unsigned bcachefs_metadata_required_upgrade_below = bcachefs_metada
#define BCH_SB_MEMBERS_MAX 64 /* XXX kill */
struct bch_sb_layout {
- uuid_le magic; /* bcachefs superblock UUID */
+ uuid_t magic; /* bcachefs superblock UUID */
__u8 layout_type;
__u8 sb_max_size_bits; /* base 2 of 512 byte sectors */
__u8 nr_superblocks;
@@ -1627,9 +1627,9 @@ struct bch_sb {
__le16 version;
__le16 version_min;
__le16 pad[2];
- uuid_le magic;
- uuid_le uuid;
- uuid_le user_uuid;
+ uuid_t magic;
+ uuid_t uuid;
+ uuid_t user_uuid;
__u8 label[BCH_SB_LABEL_SIZE];
__le64 offset;
__le64 seq;
@@ -1925,13 +1925,20 @@ enum bch_compression_opts {
* xored with the first part of the cache set's UUID
*/
-#define BCACHE_MAGIC \
+#define BCACHE_MAGIC_LE \
UUID_LE(0xf67385c6, 0x1a4e, 0xca45, \
0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81)
-#define BCHFS_MAGIC \
+#define BCHFS_MAGIC_LE \
UUID_LE(0xf67385c6, 0xce66, 0xa990, \
0xd9, 0x6a, 0x60, 0xcf, 0x80, 0x3d, 0xf7, 0xef)
+#define BCACHE_MAGIC \
+ UUID_INIT(0xc68573f6, 0x4e1a, 0x45ca, \
+ 0x82, 0x65, 0xf5, 0x7f, 0x48, 0xba, 0x6d, 0x81)
+#define BCHFS_MAGIC \
+ UUID_INIT(0xc68573f6, 0x66ce, 0x90a9, \
+ 0xd9, 0x6a, 0x60, 0xcf, 0x80, 0x3d, 0xf7, 0xef)
+
#define BCACHEFS_STATFS_MAGIC 0xca451a4e
#define JSET_MAGIC __cpu_to_le64(0x245235c1a3625032ULL)
diff --git a/fs/bcachefs/bcachefs_ioctl.h b/fs/bcachefs/bcachefs_ioctl.h
index ad47a506a907..41608186198c 100644
--- a/fs/bcachefs/bcachefs_ioctl.h
+++ b/fs/bcachefs/bcachefs_ioctl.h
@@ -93,7 +93,7 @@ struct bch_ioctl_incremental {
* this UUID.
*/
struct bch_ioctl_query_uuid {
- uuid_le uuid;
+ uuid_t uuid;
};
#if 0
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index 5a15d649d357..a22f423bdb9a 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -209,8 +209,8 @@ static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out
u64 offset, prev_offset, max_sectors;
unsigned i;
- if (uuid_le_cmp(layout->magic, BCACHE_MAGIC) &&
- uuid_le_cmp(layout->magic, BCHFS_MAGIC)) {
+ if (!uuid_equal(&layout->magic, &BCACHE_MAGIC) &&
+ !uuid_equal(&layout->magic, &BCHFS_MAGIC)) {
prt_printf(out, "Not a bcachefs superblock layout");
return -BCH_ERR_invalid_sb_layout;
}
@@ -298,12 +298,12 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out,
return -BCH_ERR_invalid_sb_block_size;
}
- if (bch2_is_zero(sb->user_uuid.b, sizeof(uuid_le))) {
+ if (bch2_is_zero(sb->user_uuid.b, sizeof(uuid_t))) {
prt_printf(out, "Bad user UUID (got zeroes)");
return -BCH_ERR_invalid_sb_uuid;
}
- if (bch2_is_zero(sb->uuid.b, sizeof(uuid_le))) {
+ if (bch2_is_zero(sb->uuid.b, sizeof(uuid_t))) {
prt_printf(out, "Bad intenal UUID (got zeroes)");
return -BCH_ERR_invalid_sb_uuid;
}
@@ -526,8 +526,8 @@ reread:
return ret;
}
- if (uuid_le_cmp(sb->sb->magic, BCACHE_MAGIC) &&
- uuid_le_cmp(sb->sb->magic, BCHFS_MAGIC)) {
+ if (!uuid_equal(&sb->sb->magic, &BCACHE_MAGIC) &&
+ !uuid_equal(&sb->sb->magic, &BCHFS_MAGIC)) {
prt_printf(err, "Not a bcachefs superblock");
return -BCH_ERR_invalid_sb_magic;
}
diff --git a/fs/bcachefs/super-io.h b/fs/bcachefs/super-io.h
index 14a25f6fe29a..6dcc0947c2ec 100644
--- a/fs/bcachefs/super-io.h
+++ b/fs/bcachefs/super-io.h
@@ -79,7 +79,7 @@ static inline void bch2_check_set_feature(struct bch_fs *c, unsigned feat)
static inline bool bch2_member_exists(struct bch_member *m)
{
- return !bch2_is_zero(m->uuid.b, sizeof(uuid_le));
+ return !bch2_is_zero(m->uuid.b, sizeof(uuid_t));
}
static inline bool bch2_dev_exists(struct bch_sb *sb,
@@ -104,7 +104,7 @@ static inline struct bch_member_cpu bch2_mi_to_cpu(struct bch_member *mi)
? BCH_MEMBER_DURABILITY(mi) - 1
: 1,
.freespace_initialized = BCH_MEMBER_FREESPACE_INITIALIZED(mi),
- .valid = !bch2_is_zero(mi->uuid.b, sizeof(uuid_le)),
+ .valid = !bch2_is_zero(mi->uuid.b, sizeof(uuid_t)),
};
}
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 2754f023032c..e31548a3bd00 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -139,20 +139,20 @@ found:
return c;
}
-static struct bch_fs *__bch2_uuid_to_fs(uuid_le uuid)
+static struct bch_fs *__bch2_uuid_to_fs(uuid_t uuid)
{
struct bch_fs *c;
lockdep_assert_held(&bch_fs_list_lock);
list_for_each_entry(c, &bch_fs_list, list)
- if (!memcmp(&c->disk_sb.sb->uuid, &uuid, sizeof(uuid_le)))
+ if (!memcmp(&c->disk_sb.sb->uuid, &uuid, sizeof(uuid_t)))
return c;
return NULL;
}
-struct bch_fs *bch2_uuid_to_fs(uuid_le uuid)
+struct bch_fs *bch2_uuid_to_fs(uuid_t uuid)
{
struct bch_fs *c;
@@ -997,7 +997,7 @@ static int bch2_dev_in_fs(struct bch_sb *fs, struct bch_sb *sb)
le64_to_cpu(fs->seq) > le64_to_cpu(sb->seq) ? fs : sb;
struct bch_sb_field_members *mi = bch2_sb_get_members(newest);
- if (uuid_le_cmp(fs->uuid, sb->uuid))
+ if (!uuid_equal(&fs->uuid, &sb->uuid))
return -BCH_ERR_device_not_a_member_of_filesystem;
if (!bch2_dev_exists(newest, mi, sb->dev_idx))
diff --git a/fs/bcachefs/super.h b/fs/bcachefs/super.h
index d4e939c808fa..1087d88330d1 100644
--- a/fs/bcachefs/super.h
+++ b/fs/bcachefs/super.h
@@ -223,7 +223,7 @@ static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b)
}
struct bch_fs *bch2_dev_to_fs(dev_t);
-struct bch_fs *bch2_uuid_to_fs(uuid_le);
+struct bch_fs *bch2_uuid_to_fs(uuid_t);
bool bch2_dev_state_allowed(struct bch_fs *, struct bch_dev *,
enum bch_member_state, int);
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 9eb86c58e550..70bde2e44792 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -839,9 +839,4 @@ static inline int u8_cmp(u8 l, u8 r)
#include <linux/uuid.h>
-static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
-{
- return memcmp(&u1, &u2, sizeof(uuid_le));
-}
-
#endif /* _BCACHEFS_UTIL_H */