Skip to contentSkip to conversation

xfs_io: Avoid using __kernel_rwf_t for older kernels

PATCH In review Florian Fainelli 3 participants 5 messages Nov 25, 2024 – Jan 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_io: Avoid using __kernel_rwf_t for older kernels

__kernel_rwf_t was defined with upstream Linux commit ddef7ed2b5cbafae692d1d580bb5a07808926a9c ("annotate RWF_... flags") which has been included in Linux v4.14 and newer. When building xfsprogs against older kernel headers, this type is not defined, leading to the following build error:

pwrite.c: In function 'pwrite_f':
../include/xfs/linux.h:236:22: error: '__kernel_rwf_t' undeclared (first use in this function); did you mean '__kernel_off_t'?

 #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040)
                      ^~~~~~~~~~~~~~
pwrite.c:329:22: note: in expansion of macro 'RWF_ATOMIC'
    pwritev2_flags |= RWF_ATOMIC;
Fixes ee6c5941352a ("xfs_io: add RWF_ATOMIC support to pwrite")
---
 include/linux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux.h +1 -1
index e9eb7bfb26a1..68b43393aad7 100644
@@ -233,7 +233,7 @@ struct fsxattr {
 
 /* Atomic Write */
 #ifndef RWF_ATOMIC
-#define RWF_ATOMIC	((__kernel_rwf_t)0x00000040)
+#define RWF_ATOMIC	(0x00000040)
 #endif
 
 /*
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Florian Fainelli

__kernel_rwf_t was defined with upstream Linux commit ddef7ed2b5cbafae692d1d580bb5a07808926a9c ("annotate RWF_... flags") which has been included in Linux v4.14 and newer. When building xfsprogs

/methinks you should upgrade your kernel, 4.14 is quite dead now, and you're not even running something /that/ new.

Quoted 5 lines

against older kernel headers, this type is not defined, leading to the following build error:

pwrite.c: In function 'pwrite_f':
../include/xfs/linux.h:236:22: error: '__kernel_rwf_t' undeclared (first use in this function); did you mean '__kernel_off_t'?

Quoted 7 lines
 #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040)
                      ^~~~~~~~~~~~~~
pwrite.c:329:22: note: in expansion of macro 'RWF_ATOMIC'
    pwritev2_flags |= RWF_ATOMIC;
Fixes ee6c5941352a ("xfs_io: add RWF_ATOMIC support to pwrite")

That said, if this doesn't break anything with a ~2020s distro then I don't have any objections to this, so:

--D

Quoted 21 lines
---
 include/linux.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux.h +1 -1
index e9eb7bfb26a1..68b43393aad7 100644
@@ -233,7 +233,7 @@ struct fsxattr {
 
 /* Atomic Write */
 #ifndef RWF_ATOMIC
-#define RWF_ATOMIC	((__kernel_rwf_t)0x00000040)
+#define RWF_ATOMIC	(0x00000040)
 #endif
 
 /*
Signature · 1 line
2.34.1
#2 lore raw
Quoted 7 lines · Darrick J. Wong
Quoted 3 lines · Florian Fainelli

__kernel_rwf_t was defined with upstream Linux commit ddef7ed2b5cbafae692d1d580bb5a07808926a9c ("annotate RWF_... flags") which has been included in Linux v4.14 and newer. When building xfsprogs

/methinks you should upgrade your kernel, 4.14 is quite dead now, and you're not even running something /that/ new.

For sure, we happen to build a root filesystem against old (4.9) kernel headers and this is how we caught it. It was good to see that thought had been put into defining RWF_ATOMIC is not already defined, not having a type for __kernel_rwf_t was the next thing.

Quoted 11 lines
Quoted 11 lines

against older kernel headers, this type is not defined, leading to the following build error:

pwrite.c: In function 'pwrite_f':
../include/xfs/linux.h:236:22: error: '__kernel_rwf_t' undeclared (first use in this function); did you mean '__kernel_off_t'?

  #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040)
                       ^~~~~~~~~~~~~~
pwrite.c:329:22: note: in expansion of macro 'RWF_ATOMIC'
     pwritev2_flags |= RWF_ATOMIC;
Quoted 7 lines
Quoted 2 lines
Fixes ee6c5941352a ("xfs_io: add RWF_ATOMIC support to pwrite")

That said, if this doesn't break anything with a ~2020s distro then I don't have any objections to this, so:

Thanks!

Signature · 1 line
Florian
#3 lore raw
In reply to Darrick J. Wong
Quoted 7 lines · Darrick J. Wong
Quoted 3 lines · Florian Fainelli

__kernel_rwf_t was defined with upstream Linux commit ddef7ed2b5cbafae692d1d580bb5a07808926a9c ("annotate RWF_... flags") which has been included in Linux v4.14 and newer. When building xfsprogs

/methinks you should upgrade your kernel, 4.14 is quite dead now, and you're not even running something /that/ new.

No disagreement here, we provide a toolchain whose kernel headers are intentional set to 4.9.x to maximize the compatibility with what our customers would be using at the time and that is how we caught that build failure. In general though, we should not be intentionally breaking the build against older kernel headers IMHO, especially when it is possible to do so.

The intent in the commit in the Fixes tag clearly had taken into account that RWF_ATOMIC might not have been defined.

Quoted 11 lines
Quoted 11 lines

against older kernel headers, this type is not defined, leading to the following build error:

pwrite.c: In function 'pwrite_f':
../include/xfs/linux.h:236:22: error: '__kernel_rwf_t' undeclared (first use in this function); did you mean '__kernel_off_t'?

  #define RWF_ATOMIC ((__kernel_rwf_t)0x00000040)
                       ^~~~~~~~~~~~~~
pwrite.c:329:22: note: in expansion of macro 'RWF_ATOMIC'
     pwritev2_flags |= RWF_ATOMIC;
Quoted 7 lines
Quoted 2 lines
Fixes ee6c5941352a ("xfs_io: add RWF_ATOMIC support to pwrite")

That said, if this doesn't break anything with a ~2020s distro then I don't have any objections to this, so:

Thanks, any chance this can be applied?

Signature · 1 line
Florian
Reviewed-by on v1 1/1
#4 lore raw
In reply to Florian Fainelli
Quoted 5 lines · Florian Fainelli

__kernel_rwf_t was defined with upstream Linux commit ddef7ed2b5cbafae692d1d580bb5a07808926a9c ("annotate RWF_... flags") which has been included in Linux v4.14 and newer. When building xfsprogs against older kernel headers, this type is not defined, leading to the following build error:

As notjign else in xfsprogs uses it this looks fine:

Although I wonder about the state of sparse checking in xfsprogs, which to be fair I haven't run for a while. I guss it's time to restart them and sort out the mess..