Skip to contentSkip to conversation

bcachefs: rename version -> bversion for big endian builds

PATCH Applied Guenter Roeck 3 participants 8 messages Sep 30, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: rename version -> bversion for big endian builds

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")
Cc Kent Overstreet <[email protected]>
---
 fs/bcachefs/bcachefs_format.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/bcachefs/bcachefs_format.h +1 -1
index 203ee627cab5..84832c2d4df9 100644
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 	struct bpos	p;
 	__u32		size;		/* extent size, in sectors */
-	struct bversion	version;
+	struct bversion	bversion;
 
 	__u8		pad[1];
 #endif
Signature · 1 line
2.45.2
#1 lore raw
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Thanks, applied

#2 lore raw
In reply to Guenter Roeck
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Which is (again) not found on any mailing list, and has never been in linux-next before it hit upstream...

Quoted 6 lines
Cc Kent Overstreet <[email protected]>

fs/bcachefs/bcachefs_format.h struct bkey { · line 229

Quoted 8 lines
fs/bcachefs/bcachefs_format.h +1 -1
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        struct bpos     p;
        __u32           size;           /* extent size, in sectors */
-       struct bversion version;
+       struct bversion bversion;
 
        __u8            pad[1];
 #endif

BTW, how does this work when accessing a non-native file system? Didn't we stop doing bi-endian file systems in v2.1.10, when ext2 was converted from a bi-endian to a little-endian file system?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#3 lore raw
Quoted 27 lines · Geert Uytterhoeven
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Which is (again) not found on any mailing list, and has never been in linux-next before it hit upstream...

Quoted 12 lines
Cc Kent Overstreet <[email protected]>
fs/bcachefs/bcachefs_format.h +1 -1
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        struct bpos     p;
        __u32           size;           /* extent size, in sectors */
-       struct bversion version;
+       struct bversion bversion;
 
Quoted 6 lines

fs/bcachefs/bcachefs_format.h struct bkey { · line 229

Quoted 2 lines
fs/bcachefs/bcachefs_format.h +0 -0
        __u8            pad[1];
 #endif

BTW, how does this work when accessing a non-native file system? Didn't we stop doing bi-endian file systems in v2.1.10, when ext2 was converted from a bi-endian to a little-endian file system?

we byte swab if necessary

#4 lore raw

Hi Kent,

Quoted 28 lines · Kent Overstreet
Quoted 27 lines · Geert Uytterhoeven
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Which is (again) not found on any mailing list, and has never been in linux-next before it hit upstream...

Quoted 12 lines
Cc Kent Overstreet <[email protected]>
fs/bcachefs/bcachefs_format.h +1 -1
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        struct bpos     p;
        __u32           size;           /* extent size, in sectors */
-       struct bversion version;
+       struct bversion bversion;
 
Quoted 8 lines
Quoted 6 lines

fs/bcachefs/bcachefs_format.h struct bkey { · line 229

Quoted 2 lines
fs/bcachefs/bcachefs_format.h +0 -0
        __u8            pad[1];
 #endif

BTW, how does this work when accessing a non-native file system? Didn't we stop doing bi-endian file systems in v2.1.10, when ext2 was converted from a bi-endian to a little-endian file system?

we byte swab if necessary

So you have to test 4 combinations instead of 2 (which you don't do, obviously ;-)

Ext2 was converted from a bi-endian to a little-endian file system because it turned out the conditional byte-swapping was more expensive than unconditional (not) byte-swapping. Given all the bcache structures are already tagged with __packed anyway, I guess this is even more true for bcachefs.

The proper way established +25y ago was to settle on one endianness layout for all on-disk data. That way you do not have to duplicate data and code for little vs. big endian, keep both paths in sync, and you can annotate everything with __[bl]eXX attributes to let sparse help you catch bugs.

Which endianness to pick is up to you. Ext2 settled on little-endian, XFS on big-endian.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#5 lore raw
Quoted 50 lines · Geert Uytterhoeven

Hi Kent,

Quoted 28 lines · Kent Overstreet
Quoted 27 lines · Geert Uytterhoeven
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Which is (again) not found on any mailing list, and has never been in linux-next before it hit upstream...

Quoted 12 lines
Cc Kent Overstreet <[email protected]>
fs/bcachefs/bcachefs_format.h +1 -1
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        struct bpos     p;
        __u32           size;           /* extent size, in sectors */
-       struct bversion version;
+       struct bversion bversion;
 
Quoted 8 lines
Quoted 6 lines

fs/bcachefs/bcachefs_format.h struct bkey { · line 229

Quoted 2 lines
fs/bcachefs/bcachefs_format.h +0 -0
        __u8            pad[1];
 #endif

BTW, how does this work when accessing a non-native file system? Didn't we stop doing bi-endian file systems in v2.1.10, when ext2 was converted from a bi-endian to a little-endian file system?

we byte swab if necessary

So you have to test 4 combinations instead of 2 (which you don't do, obviously ;-)

Ext2 was converted from a bi-endian to a little-endian file system because it turned out the conditional byte-swapping was more expensive than unconditional (not) byte-swapping. Given all the bcache structures are already tagged with __packed anyway, I guess this is even more true for bcachefs.

Quoted 8 lines

The proper way established +25y ago was to settle on one endianness layout for all on-disk data. That way you do not have to duplicate data and code for little vs. big endian, keep both paths in sync, and you can annotate everything with __[bl]eXX attributes to let sparse help you catch bugs.

Which endianness to pick is up to you. Ext2 settled on little-endian, XFS on big-endian.

If you peruse that code even slightly, you'll see that what we're doing is treating the key as a multi word integer, so word order has to match machine byte order in order for various things in the btree lookup code to work.

But sure, try and tell me there's something about filesystems I don't already know...

#6 lore raw

Hi Kent,

Quoted 55 lines · Kent Overstreet
Quoted 54 lines · Geert Uytterhoeven
Quoted 28 lines · Kent Overstreet
Quoted 27 lines · Geert Uytterhoeven
Quoted 10 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")

Which is (again) not found on any mailing list, and has never been in linux-next before it hit upstream...

Quoted 12 lines
Cc Kent Overstreet <[email protected]>
fs/bcachefs/bcachefs_format.h +1 -1
@@ -223,7 +223,7 @@ struct bkey {
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
        struct bpos     p;
        __u32           size;           /* extent size, in sectors */
-       struct bversion version;
+       struct bversion bversion;
 
Quoted 8 lines
Quoted 6 lines

fs/bcachefs/bcachefs_format.h struct bkey { · line 229

Quoted 2 lines
fs/bcachefs/bcachefs_format.h +0 -0
        __u8            pad[1];
 #endif

BTW, how does this work when accessing a non-native file system? Didn't we stop doing bi-endian file systems in v2.1.10, when ext2 was converted from a bi-endian to a little-endian file system?

we byte swab if necessary

So you have to test 4 combinations instead of 2 (which you don't do, obviously ;-)

Ext2 was converted from a bi-endian to a little-endian file system because it turned out the conditional byte-swapping was more expensive than unconditional (not) byte-swapping. Given all the bcache structures are already tagged with __packed anyway, I guess this is even more true for bcachefs.

The proper way established +25y ago was to settle on one endianness layout for all on-disk data. That way you do not have to duplicate data and code for little vs. big endian, keep both paths in sync, and you can annotate everything with __[bl]eXX attributes to let sparse help you catch bugs.

Quoted 7 lines
Quoted 2 lines

Which endianness to pick is up to you. Ext2 settled on little-endian, XFS on big-endian.

If you peruse that code even slightly, you'll see that what we're doing is treating the key as a multi word integer, so word order has to match machine byte order in order for various things in the btree lookup code to work.

I have seen the multi-word integers...

Quoted 2 lines

But sure, try and tell me there's something about filesystems I don't already know...

Okay...

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Tested-by on v1 1/1
#7 lore raw
In reply to Guenter Roeck
Quoted 6 lines · Guenter Roeck

Builds on big endian systems fail as follows.

fs/bcachefs/bkey.h: In function 'bch2_bkey_format_add_key':
fs/bcachefs/bkey.h:557:41: error:
'const struct bkey' has no member named 'bversion'

Quoted 6 lines

The original commit only renamed the variable for little endian builds. Rename it for big endian builds as well to fix the problem.

Fixes cf49f8a8c277 ("bcachefs: rename version -> bversion")
Cc Kent Overstreet <[email protected]>

As this fixes the build for me:

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds