diff mbox series

[v2,3/4] btrfs: add metadata_uuid to fsinfo ioctl

Message ID 20200713122901.1773-4-johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series Two furhter additions for fsinfo ioctl | expand

Commit Message

Johannes Thumshirn July 13, 2020, 12:29 p.m. UTC
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(-)

Comments

Nikolay Borisov July 15, 2020, 7:22 a.m. UTC | #1
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>
diff mbox series

Patch

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 */
 };