Skip to contentSkip to conversation

btrfs: clarify btrfs_ioctl_get_dev_stats padding

PATCH In review Hans van Kranenburg 2 participants 2 messages Aug 3, 2019 – Aug 5, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: clarify btrfs_ioctl_get_dev_stats padding

From: Hans van Kranenburg <[email protected]>

In commit c11d2c236cc26 the get_dev_stats ioctl was added.

Shortly thereafter, in commit b27f7c0c150f7, the flags field was added. However, the calculation for unused padding space was not updated, which also invalidated the comment.

Clarify what happened to reduce confusion and wasted time for anyone implementing this.

---
 include/uapi/linux/btrfs.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/uapi/linux/btrfs.h +6 -1
index 7885d79f7515..3ee0678c0a83 100644
@@ -665,7 +665,12 @@ struct btrfs_ioctl_get_dev_stats {
 	/* out values: */
 	__u64 values[BTRFS_DEV_STAT_VALUES_MAX];
 
-	__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */
+	/*
+	 * This pads the struct to 1032 bytes. It was originally meant to pad to
+	 * 1024 bytes, but when adding the flags field, the padding calculation
+	 * was not adjusted.
+	 */
+	__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
 };
 
 #define BTRFS_QUOTA_CTL_ENABLE	1
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hans van Kranenburg

From: Hans van Kranenburg <[email protected]>

In commit c11d2c236cc26 the get_dev_stats ioctl was added.

Quoted 8 lines

Shortly thereafter, in commit b27f7c0c150f7, the flags field was added. However, the calculation for unused padding space was not updated, which also invalidated the comment.

Clarify what happened to reduce confusion and wasted time for anyone implementing this.