Skip to contentSkip to conversation

btrfs: move enum btrfs_compression_type to the UAPI header

PATCH In review Eugene Syromiatnikov 2 participants 2 messages Apr 19, 2020 – Apr 20, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: move enum btrfs_compression_type to the UAPI header

It is passed in struct btrfs_ioctl_defrag_range_args.compress_type to BTRFS_IOC_DEFRAG_RANGE, so it has to be a part of UAPI. Also, rely on enum definition rules to get BTRFS_NR_COMPRESS_TYPES value and mark it as non-ABI.

Complements: 33ca913349962208 ("btrfs: uapi/linux/btrfs.h migration, move struct btrfs_ioctl_defrag_range_args")

---
 fs/btrfs/compression.h     |  9 +--------
 include/uapi/linux/btrfs.h | 10 ++++++++++
 2 files changed, 11 insertions(+), 8 deletions(-)
fs/btrfs/compression.h +1 -8
index d253f7a..3483b26 100644
@@ -6,6 +6,7 @@
 #ifndef BTRFS_COMPRESSION_H
 #define BTRFS_COMPRESSION_H
 
+#include <linux/btrfs.h>
 #include <linux/sizes.h>
 
 /*
@@ -100,14 +101,6 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
 
 unsigned int btrfs_compress_str2level(unsigned int type, const char *str);
 
-enum btrfs_compression_type {
-	BTRFS_COMPRESS_NONE  = 0,
-	BTRFS_COMPRESS_ZLIB  = 1,
-	BTRFS_COMPRESS_LZO   = 2,
-	BTRFS_COMPRESS_ZSTD  = 3,
-	BTRFS_NR_COMPRESS_TYPES = 4,
-};
-
 struct workspace_manager {
 	struct list_head idle_ws;
 	spinlock_t ws_lock;
include/uapi/linux/btrfs.h +10 -0
index e6b6cb0f..82cc9ac 100644
@@ -558,6 +558,16 @@ struct btrfs_ioctl_clone_range_args {
  */
 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
 #define BTRFS_DEFRAG_RANGE_START_IO 2
+
+enum btrfs_compression_type {
+	BTRFS_COMPRESS_NONE  = 0,
+	BTRFS_COMPRESS_ZLIB  = 1,
+	BTRFS_COMPRESS_LZO   = 2,
+	BTRFS_COMPRESS_ZSTD  = 3,
+
+	BTRFS_NR_COMPRESS_TYPES /* non-ABI */
+};
+
 struct btrfs_ioctl_defrag_range_args {
 	/* start of the defrag operation */
 	__u64 start;
Signature · 1 line
2.1.4
#1 lore raw
Quoted 4 lines · Eugene Syromiatnikov

It is passed in struct btrfs_ioctl_defrag_range_args.compress_type to BTRFS_IOC_DEFRAG_RANGE, so it has to be a part of UAPI. Also, rely on enum definition rules to get BTRFS_NR_COMPRESS_TYPES value and mark it as non-ABI.

Adding the compression types makes sense for the UAPI, Qu has sent patch to move more code to the exported headers ("btrfs: move on-disk structure definitions to btrfs_tree.h"), including the compression type definition.

I'd prefer to move the code in a bigger chunk than one by one, unless it's breaking compilation.