Skip to contentSkip to conversation

btrfs-progs: fix 64-bit mips and powerpc types

PATCH In review Rosen Penev 3 participants 10 messages Jan 30, 2022 – Feb 4, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: fix 64-bit mips and powerpc types

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
 cmds/receive-dump.c | 1 -
 kerncompat.h        | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <time.h>
 #include <ctype.h>
-#include <asm/types.h>
 #include <uuid/uuid.h>
 #include "common/utils.h"
 #include "cmds/commands.h"
kerncompat.h +4 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
 #ifndef __KERNCOMPAT_H__
 #define __KERNCOMPAT_H__
 
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__	/* For PPC64, to get LL64 types */
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
Signature · 1 line
2.34.1
#1 lore raw
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

Quoted 27 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
 cmds/receive-dump.c | 1 -
 kerncompat.h        | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <time.h>
 #include <ctype.h>
-#include <asm/types.h>
 #include <uuid/uuid.h>
 #include "common/utils.h"
 #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644

kerncompat.h line 24

Quoted 6 lines
kerncompat.h +3 -0
@@ -19,6 +19,10 @@
 #ifndef __KERNCOMPAT_H__
 #define __KERNCOMPAT_H__
 
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__	/* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

Quoted 6 lines
kerncompat.h +1 -0
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
Signature · 1 line
2.34.1
#2 lore raw
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
 cmds/receive-dump.c | 1 -
 kerncompat.h        | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
 #include <stdlib.h>
 #include <time.h>
 #include <ctype.h>
-#include <asm/types.h>
 #include <uuid/uuid.h>
 #include "common/utils.h"
 #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
 #ifndef __KERNCOMPAT_H__
 #define __KERNCOMPAT_H__
 
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Quoted 7 lines
Quoted 7 lines
kerncompat.h +1 -1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
--

2.34.1

#3 lore raw
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
  cmds/receive-dump.c | 1 -
  kerncompat.h        | 4 ++++
  2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
  #include <stdlib.h>
  #include <time.h>
  #include <ctype.h>
-#include <asm/types.h>
  #include <uuid/uuid.h>
  #include "common/utils.h"
  #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
  #ifndef __KERNCOMPAT_H__
  #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

See this issue:

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Thanks,
Qu

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
kerncompat.h +1 -1
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <errno.h>
--

2.34.1

#4 lore raw
Quoted 51 lines · Qu Wenruo
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
  cmds/receive-dump.c | 1 -
  kerncompat.h        | 4 ++++
  2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
  #include <stdlib.h>
  #include <time.h>
  #include <ctype.h>
-#include <asm/types.h>
  #include <uuid/uuid.h>
  #include "common/utils.h"
  #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
  #ifndef __KERNCOMPAT_H__
  #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

Quoted 8 lines

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

See this issue:

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Rosen, could you please verify that this is sufficient (without the extra macro)?

#5 lore raw
Quoted 56 lines · David Sterba
Quoted 54 lines · Qu Wenruo
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
  cmds/receive-dump.c | 1 -
  kerncompat.h        | 4 ++++
  2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
  #include <stdlib.h>
  #include <time.h>
  #include <ctype.h>
-#include <asm/types.h>
  #include <uuid/uuid.h>
  #include "common/utils.h"
  #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
  #ifndef __KERNCOMPAT_H__
  #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

Quoted 8 lines
Quoted 5 lines

See this issue:

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Qu is referring to a different issue. I am referring to bad printf formats.

Quoted 3 lines

Rosen, could you please verify that this is sufficient (without the extra macro)?

It is not.

Also note that this is specific to ppc64 and mips64. and alpha (whatever that is).

a git grep of the linux tree for that macro shows that it's used in tools/

#6 lore raw
Quoted 59 lines · Rosen Penev
Quoted 58 lines · David Sterba
Quoted 56 lines · Qu Wenruo
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
   cmds/receive-dump.c | 1 -
   kerncompat.h        | 4 ++++
   2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
   #include <stdlib.h>
   #include <time.h>
   #include <ctype.h>
-#include <asm/types.h>
   #include <uuid/uuid.h>
   #include "common/utils.h"
   #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
   #ifndef __KERNCOMPAT_H__
   #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

See this issue:

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Qu is referring to a different issue. I am referring to bad printf formats.

Weird, as the report includes format '%llu' warning for printf formats.

Quoted 9 lines
Quoted 3 lines

Rosen, could you please verify that this is sufficient (without the extra macro)?

It is not.

Also note that this is specific to ppc64 and mips64. and alpha (whatever that is).

a git grep of the linux tree for that macro shows that it's used in tools/

OK, after checking the latest build log from Fedora36 ppc64le, it indeed still shows the warning:

https://kojipkgs.fedoraproject.org//packages/btrfs-fuse/0/6.20211113git8635fbc.fc36/data/logs/ppc64le/build.log

Although from what I see, that magic is more common set for packaging, not directly into the source code:

https://chromium.googlesource.com/chromium/src.git/+/7d38bae3ef691d5091b6d4d7973a9b4d2cd85eb2/build/config/compiler/BUILD.gn#988

Where chromium choose to add that magic only for mips64

Or this:

https://github.com/LLNL/lustre/blob/2.12.7-llnl/lustre.spec.in#L343

Which is only defined during packaging, not in the source code.

We can put this into our Makefile, and only for affected archtectures then.

Thanks,
Qu

#7 lore raw
Quoted 83 lines · Qu Wenruo
Quoted 59 lines · Rosen Penev
Quoted 58 lines · David Sterba
Quoted 56 lines · Qu Wenruo
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
   cmds/receive-dump.c | 1 -
   kerncompat.h        | 4 ++++
   2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
   #include <stdlib.h>
   #include <time.h>
   #include <ctype.h>
-#include <asm/types.h>
   #include <uuid/uuid.h>
   #include "common/utils.h"
   #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
   #ifndef __KERNCOMPAT_H__
   #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

See this issue:

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Qu is referring to a different issue. I am referring to bad printf formats.

Weird, as the report includes format '%llu' warning for printf formats.

Quoted 9 lines
Quoted 3 lines

Rosen, could you please verify that this is sufficient (without the extra macro)?

It is not.

Also note that this is specific to ppc64 and mips64. and alpha (whatever that is).

a git grep of the linux tree for that macro shows that it's used in tools/

Quoted 8 lines

OK, after checking the latest build log from Fedora36 ppc64le, it indeed still shows the warning:

https://kojipkgs.fedoraproject.org//packages/btrfs-fuse/0/6.20211113git8635fbc.fc36/data/logs/ppc64le/build.log

Although from what I see, that magic is more common set for packaging, not directly into the source code:

OTOH tools/perf and some tests define this macro.

Quoted 16 lines

https://chromium.googlesource.com/chromium/src.git/+/7d38bae3ef691d5091b6d4d7973a9b4d2cd85eb2/build/config/compiler/BUILD.gn#988

Where chromium choose to add that magic only for mips64

Or this:

https://github.com/LLNL/lustre/blob/2.12.7-llnl/lustre.spec.in#L343

Which is only defined during packaging, not in the source code.

We can put this into our Makefile, and only for affected archtectures then.

Thanks,
Qu

#8 lore raw
Quoted 87 lines · Rosen Penev
Quoted 86 lines · Qu Wenruo
Quoted 59 lines · Rosen Penev
Quoted 58 lines · David Sterba
Quoted 56 lines · Qu Wenruo
Quoted 39 lines · Rosen Penev
Quoted 6 lines · David Sterba
Quoted 2 lines · Rosen Penev

The kernel uses unsigned long specifically for ppc64 and mips64. This fixes that.

What do you mean? Uses unsigned long for what?

kernel's u64 is normally unsigned long long, but not for ppc64 and mips64.

Quoted 31 lines
Quoted 31 lines

Removed asm/types.h include as it will get included properly later.

Fixes -Wformat warnings.

---
    cmds/receive-dump.c | 1 -
    kerncompat.h        | 4 ++++
    2 files changed, 4 insertions(+), 1 deletion(-)
cmds/receive-dump.c +0 -1
index 47a0a30e..00ad4fd1 100644
@@ -31,7 +31,6 @@
    #include <stdlib.h>
    #include <time.h>
    #include <ctype.h>
-#include <asm/types.h>
    #include <uuid/uuid.h>
    #include "common/utils.h"
    #include "cmds/commands.h"
kerncompat.h +0 -0
index 6ca1526e..4b36b45a 100644
@@ -19,6 +19,10 @@
    #ifndef __KERNCOMPAT_H__
    #define __KERNCOMPAT_H__
 
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

See this issue:

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Qu is referring to a different issue. I am referring to bad printf formats.

Weird, as the report includes format '%llu' warning for printf formats.

Quoted 9 lines
Quoted 3 lines

Rosen, could you please verify that this is sufficient (without the extra macro)?

It is not.

Also note that this is specific to ppc64 and mips64. and alpha (whatever that is).

a git grep of the linux tree for that macro shows that it's used in tools/

OK, after checking the latest build log from Fedora36 ppc64le, it indeed still shows the warning:

Quoted 6 lines
Quoted 5 lines

https://kojipkgs.fedoraproject.org//packages/btrfs-fuse/0/6.20211113git8635fbc.fc36/data/logs/ppc64le/build.log

Although from what I see, that magic is more common set for packaging, not directly into the source code:

OTOH tools/perf and some tests define this macro.

That's a trade-off between easier to package and easier to read.

Although as mentioned, it seems more common to define it at packaging time.

Personally I'm fine with both way, but a little more towards defined in Makefile.

(Also my time to update btrfs-fuse to handle the build warning)

Thanks,
Qu

Quoted 16 lines
Quoted 16 lines

https://chromium.googlesource.com/chromium/src.git/+/7d38bae3ef691d5091b6d4d7973a9b4d2cd85eb2/build/config/compiler/BUILD.gn#988

Where chromium choose to add that magic only for mips64

Or this:

https://github.com/LLNL/lustre/blob/2.12.7-llnl/lustre.spec.in#L343

Which is only defined during packaging, not in the source code.

We can put this into our Makefile, and only for affected archtectures then.

Thanks,
Qu

#9 lore raw
In reply to Rosen Penev
Quoted 22 lines · Rosen Penev
Quoted 12 lines
Quoted 12 lines
Quoted 6 lines
Quoted 5 lines

kerncompat.h line 24

Quoted 3 lines
kerncompat.h +3 -0
+#ifndef __SANE_USERSPACE_TYPES__
+#define __SANE_USERSPACE_TYPES__     /* For PPC64, to get LL64 types */
+#endif

Is there a cleaner way instead of defining magic macros?

no. https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/types.h#L18

Really?

I have the same issue in btrfs-fuse, but it can be easily solved without using the magic macro.

Quoted 8 lines
Quoted 5 lines

See this issue:

https://github.com/adam900710/btrfs-fuse/issues/2

including <linux/types.h> seems to solve it for btrfs-fuse.

Ok, so it's just the asm/types.h, once it's deleted it should all work with linux/types.h (included via kerncompat.h).

Qu is referring to a different issue. I am referring to bad printf formats.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Rosen, could you please verify that this is sufficient (without the extra macro)?

It is not.

Also note that this is specific to ppc64 and mips64. and alpha (whatever that is).

a git grep of the linux tree for that macro shows that it's used in tools/

Ok, let's use the magic macro.