All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition
@ 2024-01-26  8:04 Yang Xu
  2024-01-31  4:39 ` Su Yue
  2024-01-31  7:05 ` David Sterba
  0 siblings, 2 replies; 5+ messages in thread
From: Yang Xu @ 2024-01-26  8:04 UTC (permalink / raw)
  To: fstests; +Cc: Yang Xu

On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but the
macros BTRFS_IOC_SNAP_DESTROY_V2, BTRFS_IOC_SNAP_CREATE_V2 and
BTRFS_IOC_SUBVOL_CREATE_V2 are not defined. This will cause compile
error. We should always check these macros and manually define them
if necessary.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 src/t_snapshot_deleted_subvolume.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/t_snapshot_deleted_subvolume.c b/src/t_snapshot_deleted_subvolume.c
index c3adb1c4..d84ba35a 100644
--- a/src/t_snapshot_deleted_subvolume.c
+++ b/src/t_snapshot_deleted_subvolume.c
@@ -20,21 +20,6 @@
 #define BTRFS_IOCTL_MAGIC 0x94
 #endif
 
-#ifndef BTRFS_IOC_SNAP_DESTROY_V2
-#define BTRFS_IOC_SNAP_DESTROY_V2 \
-	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
-#endif
-
-#ifndef BTRFS_IOC_SNAP_CREATE_V2
-#define BTRFS_IOC_SNAP_CREATE_V2 \
-	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
-#endif
-
-#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
-#define BTRFS_IOC_SUBVOL_CREATE_V2 \
-	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
-#endif
-
 #ifndef BTRFS_SUBVOL_NAME_MAX
 #define BTRFS_SUBVOL_NAME_MAX 4039
 #endif
@@ -58,6 +43,21 @@ struct btrfs_ioctl_vol_args_v2 {
 };
 #endif
 
+#ifndef BTRFS_IOC_SNAP_DESTROY_V2
+#define BTRFS_IOC_SNAP_DESTROY_V2 \
+	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
+#endif
+
+#ifndef BTRFS_IOC_SNAP_CREATE_V2
+#define BTRFS_IOC_SNAP_CREATE_V2 \
+	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
+#endif
+
+#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
+#define BTRFS_IOC_SUBVOL_CREATE_V2 \
+	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
+#endif
+
 int main(int argc, char **argv)
 {
 	if (argc != 2) {
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition
  2024-01-26  8:04 [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition Yang Xu
@ 2024-01-31  4:39 ` Su Yue
  2024-01-31  9:54   ` Yang Xu (Fujitsu)
  2024-01-31  7:05 ` David Sterba
  1 sibling, 1 reply; 5+ messages in thread
From: Su Yue @ 2024-01-31  4:39 UTC (permalink / raw)
  To: Yang Xu; +Cc: fstests, linux-btrfs


On Fri 26 Jan 2024 at 03:04, Yang Xu <xuyang2018.jy@fujitsu.com> 
wrote:

Cc linux-btrfs

> On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but 
> the
>
Would you mention what are these platforms?

--
Su
> macros BTRFS_IOC_SNAP_DESTROY_V2, BTRFS_IOC_SNAP_CREATE_V2 and
> BTRFS_IOC_SUBVOL_CREATE_V2 are not defined. This will cause 
> compile
> error. We should always check these macros and manually define 
> them
> if necessary.
>
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>  src/t_snapshot_deleted_subvolume.c | 30 
>  +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/src/t_snapshot_deleted_subvolume.c 
> b/src/t_snapshot_deleted_subvolume.c
> index c3adb1c4..d84ba35a 100644
> --- a/src/t_snapshot_deleted_subvolume.c
> +++ b/src/t_snapshot_deleted_subvolume.c
> @@ -20,21 +20,6 @@
>  #define BTRFS_IOCTL_MAGIC 0x94
>  #endif
>
> -#ifndef BTRFS_IOC_SNAP_DESTROY_V2
> -#define BTRFS_IOC_SNAP_DESTROY_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
> -#ifndef BTRFS_IOC_SNAP_CREATE_V2
> -#define BTRFS_IOC_SNAP_CREATE_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
> -#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
> -#define BTRFS_IOC_SUBVOL_CREATE_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
>  #ifndef BTRFS_SUBVOL_NAME_MAX
>  #define BTRFS_SUBVOL_NAME_MAX 4039
>  #endif
> @@ -58,6 +43,21 @@ struct btrfs_ioctl_vol_args_v2 {
>  };
>  #endif
>
> +#ifndef BTRFS_IOC_SNAP_DESTROY_V2
> +#define BTRFS_IOC_SNAP_DESTROY_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> +#endif
> +
> +#ifndef BTRFS_IOC_SNAP_CREATE_V2
> +#define BTRFS_IOC_SNAP_CREATE_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
> +#endif
> +
> +#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
> +#define BTRFS_IOC_SUBVOL_CREATE_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
> +#endif
> +
>  int main(int argc, char **argv)
>  {
>  	if (argc != 2) {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition
  2024-01-26  8:04 [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition Yang Xu
  2024-01-31  4:39 ` Su Yue
@ 2024-01-31  7:05 ` David Sterba
  2024-01-31  9:58   ` Yang Xu (Fujitsu)
  1 sibling, 1 reply; 5+ messages in thread
From: David Sterba @ 2024-01-31  7:05 UTC (permalink / raw)
  To: Yang Xu; +Cc: fstests

On Fri, Jan 26, 2024 at 03:04:23AM -0500, Yang Xu wrote:
> On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but the
> macros BTRFS_IOC_SNAP_DESTROY_V2, BTRFS_IOC_SNAP_CREATE_V2 and
> BTRFS_IOC_SUBVOL_CREATE_V2 are not defined. This will cause compile
> error. We should always check these macros and manually define them
> if necessary.

The BTRFS_IOC_SNAP_DESTROY_V2 was been added in 5.7 but the other two
have been around since ages. This looks like there are missing
configure-time checks for the macros.

> 
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>  src/t_snapshot_deleted_subvolume.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/src/t_snapshot_deleted_subvolume.c b/src/t_snapshot_deleted_subvolume.c
> index c3adb1c4..d84ba35a 100644
> --- a/src/t_snapshot_deleted_subvolume.c
> +++ b/src/t_snapshot_deleted_subvolume.c
> @@ -20,21 +20,6 @@
>  #define BTRFS_IOCTL_MAGIC 0x94
>  #endif
>  
> -#ifndef BTRFS_IOC_SNAP_DESTROY_V2
> -#define BTRFS_IOC_SNAP_DESTROY_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
> -#ifndef BTRFS_IOC_SNAP_CREATE_V2
> -#define BTRFS_IOC_SNAP_CREATE_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
> -#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
> -#define BTRFS_IOC_SUBVOL_CREATE_V2 \
> -	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
> -#endif
> -
>  #ifndef BTRFS_SUBVOL_NAME_MAX
>  #define BTRFS_SUBVOL_NAME_MAX 4039
>  #endif
> @@ -58,6 +43,21 @@ struct btrfs_ioctl_vol_args_v2 {
>  };
>  #endif
>  
> +#ifndef BTRFS_IOC_SNAP_DESTROY_V2
> +#define BTRFS_IOC_SNAP_DESTROY_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
> +#endif
> +
> +#ifndef BTRFS_IOC_SNAP_CREATE_V2
> +#define BTRFS_IOC_SNAP_CREATE_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
> +#endif
> +
> +#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
> +#define BTRFS_IOC_SUBVOL_CREATE_V2 \
> +	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
> +#endif

So you're moving the conditional definitions out of the ifdef that
includes the header where they're supposedly defined, this should be
really done in configure and ifdef only BTRFS_IOC_SNAP_DESTROY_V2 as
it's the newest one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition
  2024-01-31  4:39 ` Su Yue
@ 2024-01-31  9:54   ` Yang Xu (Fujitsu)
  0 siblings, 0 replies; 5+ messages in thread
From: Yang Xu (Fujitsu) @ 2024-01-31  9:54 UTC (permalink / raw)
  To: Su Yue; +Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org

Hi,Su

> 
> On Fri 26 Jan 2024 at 03:04, Yang Xu <xuyang2018.jy@fujitsu.com> wrote:
> 
> Cc linux-btrfs
> 
>> On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but the
>>
> Would you mention what are these platforms?

I found this phenomenon on RHEL8.9GA.

Best Regards
Yang Xu

> 
> -- 
> Su
>> macros BTRFS_IOC_SNAP_DESTROY_V2, BTRFS_IOC_SNAP_CREATE_V2 and
>> BTRFS_IOC_SUBVOL_CREATE_V2 are not defined. This will cause compile
>> error. We should always check these macros and manually define them
>> if necessary.
>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> ---
>>  src/t_snapshot_deleted_subvolume.c | 30  +++++++++++++++---------------
>>  1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/t_snapshot_deleted_subvolume.c 
>> b/src/t_snapshot_deleted_subvolume.c
>> index c3adb1c4..d84ba35a 100644
>> --- a/src/t_snapshot_deleted_subvolume.c
>> +++ b/src/t_snapshot_deleted_subvolume.c
>> @@ -20,21 +20,6 @@
>>  #define BTRFS_IOCTL_MAGIC 0x94
>>  #endif
>>
>> -#ifndef BTRFS_IOC_SNAP_DESTROY_V2
>> -#define BTRFS_IOC_SNAP_DESTROY_V2 \
>> -    _IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>> -#ifndef BTRFS_IOC_SNAP_CREATE_V2
>> -#define BTRFS_IOC_SNAP_CREATE_V2 \
>> -    _IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>> -#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
>> -#define BTRFS_IOC_SUBVOL_CREATE_V2 \
>> -    _IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>>  #ifndef BTRFS_SUBVOL_NAME_MAX
>>  #define BTRFS_SUBVOL_NAME_MAX 4039
>>  #endif
>> @@ -58,6 +43,21 @@ struct btrfs_ioctl_vol_args_v2 {
>>  };
>>  #endif
>>
>> +#ifndef BTRFS_IOC_SNAP_DESTROY_V2
>> +#define BTRFS_IOC_SNAP_DESTROY_V2 \
>> +    _IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
>> +#endif
>> +
>> +#ifndef BTRFS_IOC_SNAP_CREATE_V2
>> +#define BTRFS_IOC_SNAP_CREATE_V2 \
>> +    _IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
>> +#endif
>> +
>> +#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
>> +#define BTRFS_IOC_SUBVOL_CREATE_V2 \
>> +    _IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
>> +#endif
>> +
>>  int main(int argc, char **argv)
>>  {
>>      if (argc != 2) {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition
  2024-01-31  7:05 ` David Sterba
@ 2024-01-31  9:58   ` Yang Xu (Fujitsu)
  0 siblings, 0 replies; 5+ messages in thread
From: Yang Xu (Fujitsu) @ 2024-01-31  9:58 UTC (permalink / raw)
  To: dsterba@suse.cz; +Cc: fstests@vger.kernel.org

Hi!

> On Fri, Jan 26, 2024 at 03:04:23AM -0500, Yang Xu wrote:
>> On some platform, struct btrfs_ioctl_vol_args_v2 is defined, but the
>> macros BTRFS_IOC_SNAP_DESTROY_V2, BTRFS_IOC_SNAP_CREATE_V2 and
>> BTRFS_IOC_SUBVOL_CREATE_V2 are not defined. This will cause compile
>> error. We should always check these macros and manually define them
>> if necessary.
> 
> The BTRFS_IOC_SNAP_DESTROY_V2 was been added in 5.7 but the other two
> have been around since ages. This looks like there are missing
> configure-time checks for the macros.
> 

Agree, will check BTRFS_IOC_SNAP_DESTROY_V2 in configure.ac.

Best Regards
Yang Xu

>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> ---
>>   src/t_snapshot_deleted_subvolume.c | 30 +++++++++++++++---------------
>>   1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/t_snapshot_deleted_subvolume.c b/src/t_snapshot_deleted_subvolume.c
>> index c3adb1c4..d84ba35a 100644
>> --- a/src/t_snapshot_deleted_subvolume.c
>> +++ b/src/t_snapshot_deleted_subvolume.c
>> @@ -20,21 +20,6 @@
>>   #define BTRFS_IOCTL_MAGIC 0x94
>>   #endif
>>   
>> -#ifndef BTRFS_IOC_SNAP_DESTROY_V2
>> -#define BTRFS_IOC_SNAP_DESTROY_V2 \
>> -	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>> -#ifndef BTRFS_IOC_SNAP_CREATE_V2
>> -#define BTRFS_IOC_SNAP_CREATE_V2 \
>> -	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>> -#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
>> -#define BTRFS_IOC_SUBVOL_CREATE_V2 \
>> -	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
>> -#endif
>> -
>>   #ifndef BTRFS_SUBVOL_NAME_MAX
>>   #define BTRFS_SUBVOL_NAME_MAX 4039
>>   #endif
>> @@ -58,6 +43,21 @@ struct btrfs_ioctl_vol_args_v2 {
>>   };
>>   #endif
>>   
>> +#ifndef BTRFS_IOC_SNAP_DESTROY_V2
>> +#define BTRFS_IOC_SNAP_DESTROY_V2 \
>> +	_IOW(BTRFS_IOCTL_MAGIC, 63, struct btrfs_ioctl_vol_args_v2)
>> +#endif
>> +
>> +#ifndef BTRFS_IOC_SNAP_CREATE_V2
>> +#define BTRFS_IOC_SNAP_CREATE_V2 \
>> +	_IOW(BTRFS_IOCTL_MAGIC, 23, struct btrfs_ioctl_vol_args_v2)
>> +#endif
>> +
>> +#ifndef BTRFS_IOC_SUBVOL_CREATE_V2
>> +#define BTRFS_IOC_SUBVOL_CREATE_V2 \
>> +	_IOW(BTRFS_IOCTL_MAGIC, 24, struct btrfs_ioctl_vol_args_v2)
>> +#endif
> 
> So you're moving the conditional definitions out of the ifdef that
> includes the header where they're supposedly defined, this should be
> really done in configure and ifdef only BTRFS_IOC_SNAP_DESTROY_V2 as
> it's the newest one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-31  9:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-26  8:04 [PATCH] t_snapshot_deleted_subvolume: change the position of macro definition Yang Xu
2024-01-31  4:39 ` Su Yue
2024-01-31  9:54   ` Yang Xu (Fujitsu)
2024-01-31  7:05 ` David Sterba
2024-01-31  9:58   ` Yang Xu (Fujitsu)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.