All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Two furhter additions for fsinfo ioctl
@ 2020-07-13 12:28 Johannes Thumshirn
  2020-07-13 12:28 ` [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 12:28 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, Johannes Thumshirn

This series extents the fsinfo ioctl by adding two new often requested
members, the filesystem generation and the metadata UUID. Both can be
retrieved from the kernel by setting the appropriate flag in the ioctl
structure.

The last patch adds a compile time assertion on the structure sizes, so we're
not accidentally breaking size assumptions.

The series was tested using the following test tool, strace support will be
written once the kernel side is accepted.

--- 8< ---
#include <linux/types.h>
#include <linux/btrfs.h>

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>

struct btrfs_ioctl_fs_info_args_new {
	__u64 max_id;                           /* out */
	__u64 num_devices;                      /* out */
	__u8 fsid[BTRFS_FSID_SIZE];             /* out */
	__u32 nodesize;                         /* out */
	__u32 sectorsize;                       /* out */
	__u32 clone_alignment;                  /* out */
	__u16 csum_type;
	__u16 csum_size;
	__u64 flags;                            /* out */
	__u64 generation;
	__u8 metadata_uuid[BTRFS_FSID_SIZE];
	__u8 reserved[944];                    /* pad to 1k */
};

#define BTRFS_FS_INFO_FLAG_CSUM_TYPE_SIZE	(1 << 0)
#define BTRFS_FS_INFO_FLAG_GENERATION		(1 << 1)
#define BTRFS_FS_INFO_FLAG_METADATA_UUID	(1 << 2)


static const char hex_chars[16] = "0123456789abcdef";
# define BYTE_HEX_CHARS(b_) \
	hex_chars[((uint8_t) (b_)) >> 4], hex_chars[((uint8_t) (b_)) & 0xf]

void format_uuid(const unsigned char *uuid, char *buf) 
{                                                                                                                                                                                    
	const char str[] = {                                                                                                                                                         
		BYTE_HEX_CHARS(uuid[0]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[1]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[2]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[3]),                                                                                                                                             
		'-',                                                                                                                                                                 
		BYTE_HEX_CHARS(uuid[4]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[5]),                                                                                                                                             
		'-',                                                                                                                                                                 
		BYTE_HEX_CHARS(uuid[6]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[7]),                                                                                                                                             
		'-',                                                                                                                                                                 
		BYTE_HEX_CHARS(uuid[8]),                                                                                                                                             
		BYTE_HEX_CHARS(uuid[9]),                                                                                                                                             
		'-',                                                                                                                                                                 
		BYTE_HEX_CHARS(uuid[10]),                                                                                                                                            
		BYTE_HEX_CHARS(uuid[11]),                                                                                                                                            
		BYTE_HEX_CHARS(uuid[12]),                                                                                                                                            
		BYTE_HEX_CHARS(uuid[13]),                                                                                                                                            
		BYTE_HEX_CHARS(uuid[14]),                                                                                                                                            
		BYTE_HEX_CHARS(uuid[15]),                                                                                                                                            
		'\0'                                                                                                                                                                 
	};                                                                                                                                                                           

	sprintf(buf, "%s", str);
}                                                      

int call_ioctl(int fd, bool csum, bool gen, bool meta)
{
	struct btrfs_ioctl_fs_info_args_new args = { 0 };
	char fsid[37], meta_uuid[37];
	int ret;

	if (csum)
		args.flags |= BTRFS_FS_INFO_FLAG_CSUM_TYPE_SIZE;
	if (gen)
		args.flags |= BTRFS_FS_INFO_FLAG_GENERATION;
	if (meta)
		args.flags |= BTRFS_FS_INFO_FLAG_METADATA_UUID;

	ret = ioctl(fd, BTRFS_IOC_FS_INFO, &args);
	if (ret < 0) {
		perror("ioctl");
		return ret;
	}

	format_uuid(args.fsid, fsid);
	format_uuid(args.metadata_uuid, meta_uuid);

	printf("\tfsid: %s\n", fsid);
	printf("\tmax_id: %llu\n", args.max_id);
	printf("\tnum_devices: %llu\n", args.num_devices);
	printf("\tnodesize: %u\n", args.nodesize);
	printf("\tsectorsize: %u\n", args.sectorsize);
	printf("\tclone_alignment: %u\n", args.clone_alignment);
	printf("\tflags: 0x%llx\n", args.flags);
	if (args.flags & BTRFS_FS_INFO_FLAG_CSUM_TYPE_SIZE) {
		printf("\tcsum_type: %u\n", args.csum_type);
		printf("\tcsum_size: %u\n", args.csum_size);
	}
	if (args.flags & BTRFS_FS_INFO_FLAG_GENERATION)
		printf("\tgeneration: %llu\n", args.generation);
	if (args.flags & BTRFS_FS_INFO_FLAG_METADATA_UUID)
		printf("\tmetadata UUID: %s\n", meta_uuid);

	return 0;
}

int main(int argc, char **argv)
{
	int fd, ret;

	if (argc != 2) {
		printf("Usage: %s file\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	fd = open(argv[1], O_RDWR);
	if (fd == -1) {
		perror("open");
		exit(1);
	}

	printf("%s: (old)\n", argv[1]);
	ret = call_ioctl(fd, false, false, false);
	if (ret)
		goto close_fd;

	printf("%s: (new)\n", argv[1]);
	ret = call_ioctl(fd, true, true, true);

close_fd:
	close(fd);
	exit(EXIT_SUCCESS);
}
--- >8 ---

Changes to v1:
- Fix "generation" to be u64 (Anand)
- Swap flags and csum_* and make flags u64 to not have holes (David)

Johannes Thumshirn (4):
  btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
  btrfs: add filesystem generation to fsinfo ioctl
  btrfs: add metadata_uuid to fsinfo ioctl
  btrfs: assert sizes of ioctl structures

 fs/btrfs/ioctl.c           | 27 ++++++++++++++++++++++++---
 include/uapi/linux/btrfs.h | 30 ++++++++++++++++++++++++++++--
 2 files changed, 52 insertions(+), 5 deletions(-)

-- 
2.26.2


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

* [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
  2020-07-13 12:28 [PATCH v2 0/4] Two furhter additions for fsinfo ioctl Johannes Thumshirn
@ 2020-07-13 12:28 ` Johannes Thumshirn
  2020-07-13 14:27   ` David Sterba
  2020-07-13 12:28 ` [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl Johannes Thumshirn
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 12:28 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, Johannes Thumshirn, stable

With the recent addition of filesystem checksum types other than CRC32c,
it is not anymore hard-coded which checksum type a btrfs filesystem uses.

Up to now there is no good way to read the filesystem checksum, apart from
reading the filesystem UUID and then query sysfs for the checksum type.

Add a new csum_type and csum_size fields to the BTRFS_IOC_FS_INFO ioctl
command which usually is used to query filesystem features. Also add a
flags member indicating that the kernel responded with a set csum_type and
csum_size field.

For compatibility reasons, only return the csum_type and csum_size if
the BTRFS_FS_INFO_FLAG_CSUM_INFO flag was passed to the kernel. Also
clear any unknown flags so we don't pass false positives to user-space
newer than the kernel.

To simplify further additions to the ioctl, also switch the padding to a
u8 array. Pahole was used to verify the result of this switch:

pahole -C btrfs_ioctl_fs_info_args fs/btrfs/btrfs.ko
struct btrfs_ioctl_fs_info_args {
        __u64                      max_id;               /*     0     8 */
        __u64                      num_devices;          /*     8     8 */
        __u8                       fsid[16];             /*    16    16 */
        __u32                      nodesize;             /*    32     4 */
        __u32                      sectorsize;           /*    36     4 */
        __u32                      clone_alignment;      /*    40     4 */
        __u16                      csum_type;            /*    44     2 */
        __u16                      csum_size;            /*    46     2 */
        __u64                      flags;                /*    48     8 */
        __u8                       reserved[968];        /*    56   968 */

        /* size: 1024, cachelines: 16, members: 10 */
};

Fixes: 3951e7f050ac ("btrfs: add xxhash64 to checksumming algorithms")
Fixes: 3831bf0094ab ("btrfs: add sha256 to checksumming algorithm")
CC: stable@vger.kernel.org # 5.5+
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/ioctl.c           | 16 +++++++++++++---
 include/uapi/linux/btrfs.h | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index ab34179d7cbc..3a566cf71fc6 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3217,11 +3217,15 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
 	struct btrfs_ioctl_fs_info_args *fi_args;
 	struct btrfs_device *device;
 	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+	u32 flags_in;
 	int ret = 0;
 
-	fi_args = kzalloc(sizeof(*fi_args), GFP_KERNEL);
-	if (!fi_args)
-		return -ENOMEM;
+	fi_args = memdup_user(arg, sizeof(*fi_args));
+	if (IS_ERR(fi_args))
+		return PTR_ERR(fi_args);
+
+	flags_in = fi_args->flags;
+	memset(fi_args, 0, sizeof(*fi_args));
 
 	rcu_read_lock();
 	fi_args->num_devices = fs_devices->num_devices;
@@ -3237,6 +3241,12 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
 	fi_args->sectorsize = fs_info->sectorsize;
 	fi_args->clone_alignment = fs_info->sectorsize;
 
+	if (flags_in & BTRFS_FS_INFO_FLAG_CSUM_INFO) {
+		fi_args->csum_type = btrfs_super_csum_type(fs_info->super_copy);
+		fi_args->csum_size = btrfs_super_csum_size(fs_info->super_copy);
+		fi_args->flags |= BTRFS_FS_INFO_FLAG_CSUM_INFO;
+	}
+
 	if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
 		ret = -EFAULT;
 
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index e6b6cb0f8bc6..b3e0af77642f 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -243,6 +243,13 @@ struct btrfs_ioctl_dev_info_args {
 	__u8 path[BTRFS_DEVICE_PATH_NAME_MAX];	/* out */
 };
 
+/*
+ * Retrieve information about the filesystem
+ */
+
+/* Request information about checksum type and size */
+#define BTRFS_FS_INFO_FLAG_CSUM_INFO			(1 << 0)
+
 struct btrfs_ioctl_fs_info_args {
 	__u64 max_id;				/* out */
 	__u64 num_devices;			/* out */
@@ -250,10 +257,14 @@ struct btrfs_ioctl_fs_info_args {
 	__u32 nodesize;				/* out */
 	__u32 sectorsize;			/* out */
 	__u32 clone_alignment;			/* out */
-	__u32 reserved32;
-	__u64 reserved[122];			/* pad to 1k */
+	/* See BTRFS_FS_INFO_FLAG_* */
+	__u16 csum_type;			/* out */
+	__u16 csum_size;			/* out */
+	__u64 flags;				/* in/out */
+	__u8 reserved[968];			/* pad to 1k */
 };
 
+
 /*
  * feature flags
  *
-- 
2.26.2


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

* [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl
  2020-07-13 12:28 [PATCH v2 0/4] Two furhter additions for fsinfo ioctl Johannes Thumshirn
  2020-07-13 12:28 ` [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
@ 2020-07-13 12:28 ` Johannes Thumshirn
  2020-07-15  7:21   ` Nikolay Borisov
  2020-07-13 12:29 ` [PATCH v2 3/4] btrfs: add metadata_uuid " Johannes Thumshirn
  2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
  3 siblings, 1 reply; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 12:28 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, Johannes Thumshirn

Add retrieval of the filesystem's generation to the fsinfo ioctl. This is
driven by setting the BTRFS_FS_INFO_FLAG_GENERATION flag in
btrfs_ioctl_fs_info_args::flags.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/ioctl.c           | 5 +++++
 include/uapi/linux/btrfs.h | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3a566cf71fc6..f1b433ec09e8 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3247,6 +3247,11 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
 		fi_args->flags |= BTRFS_FS_INFO_FLAG_CSUM_INFO;
 	}
 
+	if (flags_in & BTRFS_FS_INFO_FLAG_GENERATION) {
+		fi_args->generation = fs_info->generation;
+		fi_args->flags |= BTRFS_FS_INFO_FLAG_GENERATION;
+	}
+
 	if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
 		ret = -EFAULT;
 
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index b3e0af77642f..b8373723eb4a 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -250,6 +250,9 @@ struct btrfs_ioctl_dev_info_args {
 /* Request information about checksum type and size */
 #define BTRFS_FS_INFO_FLAG_CSUM_INFO			(1 << 0)
 
+/* Request information about filesystem generation */
+#define BTRFS_FS_INFO_FLAG_GENERATION			(1 << 1)
+
 struct btrfs_ioctl_fs_info_args {
 	__u64 max_id;				/* out */
 	__u64 num_devices;			/* out */
@@ -261,7 +264,8 @@ struct btrfs_ioctl_fs_info_args {
 	__u16 csum_type;			/* out */
 	__u16 csum_size;			/* out */
 	__u64 flags;				/* in/out */
-	__u8 reserved[968];			/* pad to 1k */
+	__u64 generation;			/* out */
+	__u8 reserved[960];			/* pad to 1k */
 };
 
 
-- 
2.26.2


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

* [PATCH v2 3/4] btrfs: add metadata_uuid to fsinfo ioctl
  2020-07-13 12:28 [PATCH v2 0/4] Two furhter additions for fsinfo ioctl Johannes Thumshirn
  2020-07-13 12:28 ` [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
  2020-07-13 12:28 ` [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl Johannes Thumshirn
@ 2020-07-13 12:29 ` Johannes Thumshirn
  2020-07-15  7:22   ` Nikolay Borisov
  2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
  3 siblings, 1 reply; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 12:29 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, Johannes Thumshirn

Add retrieval of the filesystem's metadata UUID to the fsinfo ioctl. This is
driven by setting the BTRFS_FS_INFO_FLAG_METADATA_UUID flag in
btrfs_ioctl_fs_info_args::flags.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/ioctl.c           | 6 ++++++
 include/uapi/linux/btrfs.h | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f1b433ec09e8..9e4d6915b6c9 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3252,6 +3252,12 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
 		fi_args->flags |= BTRFS_FS_INFO_FLAG_GENERATION;
 	}
 
+	if (flags_in & BTRFS_FS_INFO_FLAG_METADATA_UUID) {
+		memcpy(&fi_args->metadata_uuid, fs_devices->metadata_uuid,
+		       sizeof(fi_args->metadata_uuid));
+		fi_args->flags |= BTRFS_FS_INFO_FLAG_METADATA_UUID;
+	}
+
 	if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
 		ret = -EFAULT;
 
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index b8373723eb4a..69b88f6cb57f 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -252,6 +252,8 @@ struct btrfs_ioctl_dev_info_args {
 
 /* Request information about filesystem generation */
 #define BTRFS_FS_INFO_FLAG_GENERATION			(1 << 1)
+/* Request information about filesystem metadata UUID */
+#define BTRFS_FS_INFO_FLAG_METADATA_UUID		(1 << 2)
 
 struct btrfs_ioctl_fs_info_args {
 	__u64 max_id;				/* out */
@@ -265,7 +267,8 @@ struct btrfs_ioctl_fs_info_args {
 	__u16 csum_size;			/* out */
 	__u64 flags;				/* in/out */
 	__u64 generation;			/* out */
-	__u8 reserved[960];			/* pad to 1k */
+	__u8 metadata_uuid[BTRFS_FSID_SIZE];	/* out */
+	__u8 reserved[944];			/* pad to 1k */
 };
 
 
-- 
2.26.2


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

* [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 12:28 [PATCH v2 0/4] Two furhter additions for fsinfo ioctl Johannes Thumshirn
                   ` (2 preceding siblings ...)
  2020-07-13 12:29 ` [PATCH v2 3/4] btrfs: add metadata_uuid " Johannes Thumshirn
@ 2020-07-13 12:29 ` Johannes Thumshirn
  2020-07-13 14:58   ` David Sterba
                     ` (2 more replies)
  3 siblings, 3 replies; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 12:29 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs, Johannes Thumshirn

When expanding ioctl interfaces we want to make sure we're not changing
the size of the structures, otherwise it can lead to incorrect transfers
between kernel and user-space.

Build time assert the size of each structure so we're not running into any
incompatibilities.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 include/uapi/linux/btrfs.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 69b88f6cb57f..d3c363398e10 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -32,6 +32,7 @@ struct btrfs_ioctl_vol_args {
 	__s64 fd;
 	char name[BTRFS_PATH_NAME_MAX + 1];
 };
+static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
 
 #define BTRFS_DEVICE_PATH_NAME_MAX	1024
 #define BTRFS_SUBVOL_NAME_MAX 		4039
@@ -190,6 +191,7 @@ struct btrfs_ioctl_scrub_args {
 	/* pad to 1k */
 	__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
 };
+static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
 
 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS	0
 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID	1
@@ -242,6 +244,7 @@ struct btrfs_ioctl_dev_info_args {
 	__u64 unused[379];			/* pad to 4k */
 	__u8 path[BTRFS_DEVICE_PATH_NAME_MAX];	/* out */
 };
+static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
 
 /*
  * Retrieve information about the filesystem
@@ -270,7 +273,7 @@ struct btrfs_ioctl_fs_info_args {
 	__u8 metadata_uuid[BTRFS_FSID_SIZE];	/* out */
 	__u8 reserved[944];			/* pad to 1k */
 };
-
+static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
 
 /*
  * feature flags
@@ -453,6 +456,7 @@ struct btrfs_ioctl_balance_args {
 
 	__u64 unused[72];			/* pad to 1k */
 };
+static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
 
 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
 struct btrfs_ioctl_ino_lookup_args {
@@ -460,6 +464,7 @@ struct btrfs_ioctl_ino_lookup_args {
 	__u64 objectid;
 	char name[BTRFS_INO_LOOKUP_PATH_MAX];
 };
+static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
 
 #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
 struct btrfs_ioctl_ino_lookup_user_args {
@@ -475,6 +480,7 @@ struct btrfs_ioctl_ino_lookup_user_args {
 	 */
 	char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
 };
+static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
 
 /* Search criteria for the btrfs SEARCH ioctl family. */
 struct btrfs_ioctl_search_key {
@@ -553,6 +559,7 @@ struct btrfs_ioctl_search_args {
 	struct btrfs_ioctl_search_key key;
 	char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
 };
+static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
 
 struct btrfs_ioctl_search_args_v2 {
 	struct btrfs_ioctl_search_key key; /* in/out - search parameters */
@@ -710,6 +717,7 @@ struct btrfs_ioctl_get_dev_stats {
 	 */
 	__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
 };
+static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
 
 #define BTRFS_QUOTA_CTL_ENABLE	1
 #define BTRFS_QUOTA_CTL_DISABLE	2
-- 
2.26.2


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

* Re: [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
  2020-07-13 12:28 ` [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
@ 2020-07-13 14:27   ` David Sterba
  2020-07-13 14:28     ` Johannes Thumshirn
  0 siblings, 1 reply; 19+ messages in thread
From: David Sterba @ 2020-07-13 14:27 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs, stable

On Mon, Jul 13, 2020 at 09:28:58PM +0900, Johannes Thumshirn wrote:
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3217,11 +3217,15 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
>  	struct btrfs_ioctl_fs_info_args *fi_args;
>  	struct btrfs_device *device;
>  	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
> +	u32 flags_in;

u64 here too, I'll fix it.

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

* Re: [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
  2020-07-13 14:27   ` David Sterba
@ 2020-07-13 14:28     ` Johannes Thumshirn
  2020-07-13 14:50       ` David Sterba
  0 siblings, 1 reply; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 14:28 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, stable

On 13/07/2020 16:27, David Sterba wrote:
> On Mon, Jul 13, 2020 at 09:28:58PM +0900, Johannes Thumshirn wrote:
>> --- a/fs/btrfs/ioctl.c
>> +++ b/fs/btrfs/ioctl.c
>> @@ -3217,11 +3217,15 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
>>  	struct btrfs_ioctl_fs_info_args *fi_args;
>>  	struct btrfs_device *device;
>>  	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
>> +	u32 flags_in;
> 
> u64 here too, I'll fix it.
> 

Uh, surprised why GCC didn't warn me about the truncation

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

* Re: [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl
  2020-07-13 14:28     ` Johannes Thumshirn
@ 2020-07-13 14:50       ` David Sterba
  0 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2020-07-13 14:50 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: dsterba, linux-btrfs, stable

On Mon, Jul 13, 2020 at 02:28:36PM +0000, Johannes Thumshirn wrote:
> On 13/07/2020 16:27, David Sterba wrote:
> > On Mon, Jul 13, 2020 at 09:28:58PM +0900, Johannes Thumshirn wrote:
> >> --- a/fs/btrfs/ioctl.c
> >> +++ b/fs/btrfs/ioctl.c
> >> @@ -3217,11 +3217,15 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
> >>  	struct btrfs_ioctl_fs_info_args *fi_args;
> >>  	struct btrfs_device *device;
> >>  	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
> >> +	u32 flags_in;
> > 
> > u64 here too, I'll fix it.
> 
> Uh, surprised why GCC didn't warn me about the truncation

The right warning for that is -Wconversion but it's off by default.
Integer type truncations are common becasue we know what we're doing
(except for the bugs).

fs/btrfs/ioctl.c: In function ‘btrfs_ioctl_fs_info’:
fs/btrfs/ioctl.c:3228:13: warning: conversion from ‘__u64’ {aka ‘long long unsigned int’} to ‘u32’ {aka ‘unsigned int’} may change value [-Wconversion]
 3228 |  flags_in = fi_args->flags;

Otherwise:

$ make ccflags-y=-Wconversion fs/btrfs/ioctl.o 2>&1 | grep warning: | wc -l
533

Most of them are from included headers.

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
@ 2020-07-13 14:58   ` David Sterba
  2020-07-13 16:13     ` Johannes Thumshirn
  2020-07-13 21:01     ` kernel test robot
  2020-07-13 21:30   ` kernel test robot
  2 siblings, 1 reply; 19+ messages in thread
From: David Sterba @ 2020-07-13 14:58 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs

On Mon, Jul 13, 2020 at 09:29:01PM +0900, Johannes Thumshirn wrote:
> When expanding ioctl interfaces we want to make sure we're not changing
> the size of the structures, otherwise it can lead to incorrect transfers
> between kernel and user-space.
> 
> Build time assert the size of each structure so we're not running into any
> incompatibilities.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

The structure size is ABI once it's part of the ioctl defintion, ie. in
any of the _IOWR/_IOR/_IOW macros. I don't see the assert added for
btrfs_ioctl_vol_args_v2 or btrfs_ioctl_quota_rescan_args and I haven't
checked all.

Can you please add the static asserts for all of them? The file ioctl.h
in progs should have that already so you can copy or cross-verify from
there.

I'll merge the patches 1-3 now.

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 14:58   ` David Sterba
@ 2020-07-13 16:13     ` Johannes Thumshirn
  0 siblings, 0 replies; 19+ messages in thread
From: Johannes Thumshirn @ 2020-07-13 16:13 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs

On 13/07/2020 16:58, David Sterba wrote:
> On Mon, Jul 13, 2020 at 09:29:01PM +0900, Johannes Thumshirn wrote:
>> When expanding ioctl interfaces we want to make sure we're not changing
>> the size of the structures, otherwise it can lead to incorrect transfers
>> between kernel and user-space.
>>
>> Build time assert the size of each structure so we're not running into any
>> incompatibilities.
>>
>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> The structure size is ABI once it's part of the ioctl defintion, ie. in
> any of the _IOWR/_IOR/_IOW macros. I don't see the assert added for
> btrfs_ioctl_vol_args_v2 or btrfs_ioctl_quota_rescan_args and I haven't
> checked all.
> 
> Can you please add the static asserts for all of them? The file ioctl.h
> in progs should have that already so you can copy or cross-verify from
> there.

OK will do.

> I'll merge the patches 1-3 now.
> 


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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
@ 2020-07-13 21:01     ` kernel test robot
  2020-07-13 21:01     ` kernel test robot
  2020-07-13 21:30   ` kernel test robot
  2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2020-07-13 21:01 UTC (permalink / raw)
  To: Johannes Thumshirn, David Sterba
  Cc: kbuild-all, clang-built-linux, linux-btrfs, Johannes Thumshirn

[-- Attachment #1: Type: text/plain, Size: 6441 bytes --]

Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on v5.8-rc5]
[cannot apply to kdave/for-next btrfs/next next-20200713]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
base:    11ba468877bb23f28956a35e896356252d63c983
config: x86_64-randconfig-a016-20200713 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from <built-in>:1:
   In file included from ./usr/include/linux/btrfs_tree.h:5:
>> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
                 ^
>> ./usr/include/linux/btrfs.h:35:15: error: expected ')'
   ./usr/include/linux/btrfs.h:35:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
                ^
>> ./usr/include/linux/btrfs.h:35:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:192:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:192:15: error: expected ')'
   ./usr/include/linux/btrfs.h:192:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:192:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:245:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:245:15: error: expected ')'
   ./usr/include/linux/btrfs.h:245:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:245:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:274:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:274:15: error: expected ')'
   ./usr/include/linux/btrfs.h:274:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:274:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:457:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:457:15: error: expected ')'
   ./usr/include/linux/btrfs.h:457:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:457:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:465:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:465:15: error: expected ')'
   ./usr/include/linux/btrfs.h:465:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:465:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:481:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:481:15: error: expected ')'
   ./usr/include/linux/btrfs.h:481:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:481:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:560:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:560:15: error: expected ')'
   ./usr/include/linux/btrfs.h:560:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:560:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:718:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
                 ^
   ./usr/include/linux/btrfs.h:718:15: error: expected ')'
   ./usr/include/linux/btrfs.h:718:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
                ^
   ./usr/include/linux/btrfs.h:718:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
   ^
   int
   9 warnings and 18 errors generated.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33333 bytes --]

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
@ 2020-07-13 21:01     ` kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2020-07-13 21:01 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6576 bytes --]

Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on v5.8-rc5]
[cannot apply to kdave/for-next btrfs/next next-20200713]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
base:    11ba468877bb23f28956a35e896356252d63c983
config: x86_64-randconfig-a016-20200713 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from <built-in>:1:
   In file included from ./usr/include/linux/btrfs_tree.h:5:
>> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
                 ^
>> ./usr/include/linux/btrfs.h:35:15: error: expected ')'
   ./usr/include/linux/btrfs.h:35:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
                ^
>> ./usr/include/linux/btrfs.h:35:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:192:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:192:15: error: expected ')'
   ./usr/include/linux/btrfs.h:192:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:192:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:245:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:245:15: error: expected ')'
   ./usr/include/linux/btrfs.h:245:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:245:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:274:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:274:15: error: expected ')'
   ./usr/include/linux/btrfs.h:274:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:274:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:457:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
                 ^
   ./usr/include/linux/btrfs.h:457:15: error: expected ')'
   ./usr/include/linux/btrfs.h:457:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
                ^
   ./usr/include/linux/btrfs.h:457:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
   ^
   int
   ./usr/include/linux/btrfs.h:465:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:465:15: error: expected ')'
   ./usr/include/linux/btrfs.h:465:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:465:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:481:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:481:15: error: expected ')'
   ./usr/include/linux/btrfs.h:481:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:481:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:560:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
                 ^
   ./usr/include/linux/btrfs.h:560:15: error: expected ')'
   ./usr/include/linux/btrfs.h:560:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
                ^
   ./usr/include/linux/btrfs.h:560:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
   ^
   int
   ./usr/include/linux/btrfs.h:718:15: error: expected parameter declarator
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
                 ^
   ./usr/include/linux/btrfs.h:718:15: error: expected ')'
   ./usr/include/linux/btrfs.h:718:14: note: to match this '('
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
                ^
   ./usr/include/linux/btrfs.h:718:1: warning: declaration specifier missing, defaulting to 'int'
   static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
   ^
   int
   9 warnings and 18 errors generated.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 33333 bytes --]

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
  2020-07-13 14:58   ` David Sterba
  2020-07-13 21:01     ` kernel test robot
@ 2020-07-13 21:30   ` kernel test robot
  2 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2020-07-13 21:30 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2915 bytes --]

Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on v5.8-rc5]
[cannot apply to kdave/for-next btrfs/next next-20200713]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
base:    11ba468877bb23f28956a35e896356252d63c983
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from ./usr/include/linux/btrfs_tree.h:5,
                    from <command-line>:32:
>> ./usr/include/linux/btrfs.h:35:15: error: expected declaration specifiers or '...' before 'sizeof'
      35 | static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:192:15: error: expected declaration specifiers or '...' before 'sizeof'
     192 | static_assert(sizeof(struct btrfs_ioctl_scrub_args) == 1024);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:245:15: error: expected declaration specifiers or '...' before 'sizeof'
     245 | static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:274:15: error: expected declaration specifiers or '...' before 'sizeof'
     274 | static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:457:15: error: expected declaration specifiers or '...' before 'sizeof'
     457 | static_assert(sizeof(struct btrfs_ioctl_balance_args) == 1024);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:465:15: error: expected declaration specifiers or '...' before 'sizeof'
     465 | static_assert(sizeof(struct btrfs_ioctl_ino_lookup_args) == 4096);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:481:15: error: expected declaration specifiers or '...' before 'sizeof'
     481 | static_assert(sizeof(struct btrfs_ioctl_ino_lookup_user_args) == 4096);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:560:15: error: expected declaration specifiers or '...' before 'sizeof'
     560 | static_assert(sizeof(struct btrfs_ioctl_search_args) == 4096);
         |               ^~~~~~
   ./usr/include/linux/btrfs.h:718:15: error: expected declaration specifiers or '...' before 'sizeof'
     718 | static_assert(sizeof(struct btrfs_ioctl_get_dev_stats) == 1032);
         |               ^~~~~~

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 75224 bytes --]

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-13 21:01     ` kernel test robot
@ 2020-07-14 11:20       ` David Sterba
  -1 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2020-07-14 11:20 UTC (permalink / raw)
  To: kernel test robot
  Cc: Johannes Thumshirn, David Sterba, kbuild-all, clang-built-linux,
	linux-btrfs

On Tue, Jul 14, 2020 at 05:01:21AM +0800, kernel test robot wrote:
> Hi Johannes,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on v5.8-rc5]
> [cannot apply to kdave/for-next btrfs/next next-20200713]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use  as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
> base:    11ba468877bb23f28956a35e896356252d63c983
> config: x86_64-randconfig-a016-20200713 (attached as .config)
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install x86_64 cross compiling tool for clang build
>         # apt-get install binutils-x86-64-linux-gnu
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from <built-in>:1:
>    In file included from ./usr/include/linux/btrfs_tree.h:5:
> >> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
>    static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
>                  ^

Does that mean that clang (11.0) does not support static_assert? We
aren't doing anything special here, include only the standard kernel
headers and use macros as intended.

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
@ 2020-07-14 11:20       ` David Sterba
  0 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2020-07-14 11:20 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1857 bytes --]

On Tue, Jul 14, 2020 at 05:01:21AM +0800, kernel test robot wrote:
> Hi Johannes,
> 
> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on v5.8-rc5]
> [cannot apply to kdave/for-next btrfs/next next-20200713]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use  as documented in
> https://git-scm.com/docs/git-format-patch]
> 
> url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
> base:    11ba468877bb23f28956a35e896356252d63c983
> config: x86_64-randconfig-a016-20200713 (attached as .config)
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install x86_64 cross compiling tool for clang build
>         # apt-get install binutils-x86-64-linux-gnu
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
> 
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All error/warnings (new ones prefixed by >>):
> 
>    In file included from <built-in>:1:
>    In file included from ./usr/include/linux/btrfs_tree.h:5:
> >> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
>    static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
>                  ^

Does that mean that clang (11.0) does not support static_assert? We
aren't doing anything special here, include only the standard kernel
headers and use macros as intended.

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
  2020-07-14 11:20       ` David Sterba
@ 2020-07-14 11:23         ` David Sterba
  -1 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2020-07-14 11:23 UTC (permalink / raw)
  To: dsterba, kernel test robot, Johannes Thumshirn, kbuild-all,
	clang-built-linux, linux-btrfs

On Tue, Jul 14, 2020 at 01:20:53PM +0200, David Sterba wrote:
> On Tue, Jul 14, 2020 at 05:01:21AM +0800, kernel test robot wrote:
> > Hi Johannes,
> > 
> > I love your patch! Yet something to improve:
> > 
> > [auto build test ERROR on v5.8-rc5]
> > [cannot apply to kdave/for-next btrfs/next next-20200713]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use  as documented in
> > https://git-scm.com/docs/git-format-patch]
> > 
> > url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
> > base:    11ba468877bb23f28956a35e896356252d63c983
> > config: x86_64-randconfig-a016-20200713 (attached as .config)
> > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # install x86_64 cross compiling tool for clang build
> >         # apt-get install binutils-x86-64-linux-gnu
> >         # save the attached .config to linux build tree
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> > All error/warnings (new ones prefixed by >>):
> > 
> >    In file included from <built-in>:1:
> >    In file included from ./usr/include/linux/btrfs_tree.h:5:
> > >> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
> >    static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
> >                  ^
> 
> Does that mean that clang (11.0) does not support static_assert? We
> aren't doing anything special here, include only the standard kernel
> headers and use macros as intended.

Never mind, Johanness fixed it in v2, the macro is not defined for
non-kernel build.

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

* Re: [PATCH v2 4/4] btrfs: assert sizes of ioctl structures
@ 2020-07-14 11:23         ` David Sterba
  0 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2020-07-14 11:23 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2083 bytes --]

On Tue, Jul 14, 2020 at 01:20:53PM +0200, David Sterba wrote:
> On Tue, Jul 14, 2020 at 05:01:21AM +0800, kernel test robot wrote:
> > Hi Johannes,
> > 
> > I love your patch! Yet something to improve:
> > 
> > [auto build test ERROR on v5.8-rc5]
> > [cannot apply to kdave/for-next btrfs/next next-20200713]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use  as documented in
> > https://git-scm.com/docs/git-format-patch]
> > 
> > url:    https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Two-furhter-additions-for-fsinfo-ioctl/20200713-203321
> > base:    11ba468877bb23f28956a35e896356252d63c983
> > config: x86_64-randconfig-a016-20200713 (attached as .config)
> > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # install x86_64 cross compiling tool for clang build
> >         # apt-get install binutils-x86-64-linux-gnu
> >         # save the attached .config to linux build tree
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> > 
> > All error/warnings (new ones prefixed by >>):
> > 
> >    In file included from <built-in>:1:
> >    In file included from ./usr/include/linux/btrfs_tree.h:5:
> > >> ./usr/include/linux/btrfs.h:35:15: error: expected parameter declarator
> >    static_assert(sizeof(struct btrfs_ioctl_vol_args) == 4096);
> >                  ^
> 
> Does that mean that clang (11.0) does not support static_assert? We
> aren't doing anything special here, include only the standard kernel
> headers and use macros as intended.

Never mind, Johanness fixed it in v2, the macro is not defined for
non-kernel build.

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

* Re: [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl
  2020-07-13 12:28 ` [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl Johannes Thumshirn
@ 2020-07-15  7:21   ` Nikolay Borisov
  0 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2020-07-15  7:21 UTC (permalink / raw)
  To: Johannes Thumshirn, David Sterba; +Cc: linux-btrfs



On 13.07.20 г. 15:28 ч., Johannes Thumshirn wrote:
> Add retrieval of the filesystem's generation to the fsinfo ioctl. This is
> driven by setting the BTRFS_FS_INFO_FLAG_GENERATION flag in
> btrfs_ioctl_fs_info_args::flags.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/ioctl.c           | 5 +++++
>  include/uapi/linux/btrfs.h | 6 +++++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 3a566cf71fc6..f1b433ec09e8 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3247,6 +3247,11 @@ static long btrfs_ioctl_fs_info(struct btrfs_fs_info *fs_info,
>  		fi_args->flags |= BTRFS_FS_INFO_FLAG_CSUM_INFO;
>  	}
>  
> +	if (flags_in & BTRFS_FS_INFO_FLAG_GENERATION) {
> +		fi_args->generation = fs_info->generation;
> +		fi_args->flags |= BTRFS_FS_INFO_FLAG_GENERATION;
> +	}
> +
>  	if (copy_to_user(arg, fi_args, sizeof(*fi_args)))
>  		ret = -EFAULT;
>  
> diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
> index b3e0af77642f..b8373723eb4a 100644
> --- a/include/uapi/linux/btrfs.h
> +++ b/include/uapi/linux/btrfs.h
> @@ -250,6 +250,9 @@ struct btrfs_ioctl_dev_info_args {
>  /* Request information about checksum type and size */
>  #define BTRFS_FS_INFO_FLAG_CSUM_INFO			(1 << 0)
>  
> +/* Request information about filesystem generation */
> +#define BTRFS_FS_INFO_FLAG_GENERATION			(1 << 1)
> +
>  struct btrfs_ioctl_fs_info_args {
>  	__u64 max_id;				/* out */
>  	__u64 num_devices;			/* out */
> @@ -261,7 +264,8 @@ struct btrfs_ioctl_fs_info_args {
>  	__u16 csum_type;			/* out */
>  	__u16 csum_size;			/* out */
>  	__u64 flags;				/* in/out */
> -	__u8 reserved[968];			/* pad to 1k */
> +	__u64 generation;			/* out */
> +	__u8 reserved[960];			/* pad to 1k */
>  };
>  
>  
> 

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

* Re: [PATCH v2 3/4] btrfs: add metadata_uuid to fsinfo ioctl
  2020-07-13 12:29 ` [PATCH v2 3/4] btrfs: add metadata_uuid " Johannes Thumshirn
@ 2020-07-15  7:22   ` Nikolay Borisov
  0 siblings, 0 replies; 19+ messages in thread
From: Nikolay Borisov @ 2020-07-15  7:22 UTC (permalink / raw)
  To: Johannes Thumshirn, David Sterba; +Cc: linux-btrfs



On 13.07.20 г. 15:29 ч., Johannes Thumshirn wrote:
> Add retrieval of the filesystem's metadata UUID to the fsinfo ioctl. This is
> driven by setting the BTRFS_FS_INFO_FLAG_METADATA_UUID flag in
> btrfs_ioctl_fs_info_args::flags.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>


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

end of thread, other threads:[~2020-07-15  7:26 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 12:28 [PATCH v2 0/4] Two furhter additions for fsinfo ioctl Johannes Thumshirn
2020-07-13 12:28 ` [PATCH v2 1/4] btrfs: pass checksum type via BTRFS_IOC_FS_INFO ioctl Johannes Thumshirn
2020-07-13 14:27   ` David Sterba
2020-07-13 14:28     ` Johannes Thumshirn
2020-07-13 14:50       ` David Sterba
2020-07-13 12:28 ` [PATCH v2 2/4] btrfs: add filesystem generation to fsinfo ioctl Johannes Thumshirn
2020-07-15  7:21   ` Nikolay Borisov
2020-07-13 12:29 ` [PATCH v2 3/4] btrfs: add metadata_uuid " Johannes Thumshirn
2020-07-15  7:22   ` Nikolay Borisov
2020-07-13 12:29 ` [PATCH v2 4/4] btrfs: assert sizes of ioctl structures Johannes Thumshirn
2020-07-13 14:58   ` David Sterba
2020-07-13 16:13     ` Johannes Thumshirn
2020-07-13 21:01   ` kernel test robot
2020-07-13 21:01     ` kernel test robot
2020-07-14 11:20     ` David Sterba
2020-07-14 11:20       ` David Sterba
2020-07-14 11:23       ` David Sterba
2020-07-14 11:23         ` David Sterba
2020-07-13 21:30   ` kernel test robot

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.