Like other filesystem does, we introduce a new file f2fs.h in path of
include/uapi/linux/, and move f2fs-specified ioctl interface definitions
to that file, after then, in order to use those definitions, userspace
developer only need to include the new header file rather than
copy & paste definitions from fs/f2fs/f2fs.h.
Signed-off-by: Chao Yu <[email protected]>
---
v2: add missing "WITH Linux-syscall-note" for SPDX-License-Identifier
MAINTAINERS | 1 +
fs/f2fs/f2fs.h | 79 ----------------------------------
fs/f2fs/file.c | 1 +
include/trace/events/f2fs.h | 1 +
include/uapi/linux/f2fs.h | 86 +++++++++++++++++++++++++++++++++++++
5 files changed, 89 insertions(+), 79 deletions(-)
create mode 100644 include/uapi/linux/f2fs.h
diff --git a/MAINTAINERS b/MAINTAINERS
index d1d4e49a695a..b79a911f1e32 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6686,6 +6686,7 @@ F: Documentation/filesystems/f2fs.rst
F: fs/f2fs/
F: include/linux/f2fs_fs.h
F: include/trace/events/f2fs.h
+F: include/uapi/linux/f2fs.h
F71805F HARDWARE MONITORING DRIVER
M: Jean Delvare <[email protected]>
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index cb700d797296..99bcf4b44a9c 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -402,85 +402,6 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
return size <= MAX_SIT_JENTRIES(journal);
}
-/*
- * f2fs-specific ioctl commands
- */
-#define F2FS_IOCTL_MAGIC 0xf5
-#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
-#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
-#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
-#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
-#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
-#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
-#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
-#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
- struct f2fs_defragment)
-#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
- struct f2fs_move_range)
-#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
- struct f2fs_flush_device)
-#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
- struct f2fs_gc_range)
-#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
-#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
-#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
-#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
-#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
-#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
-#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
- _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
-#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
- _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
-#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
- struct f2fs_sectrim_range)
-
-/*
- * should be same as XFS_IOC_GOINGDOWN.
- * Flags for going down operation used by FS_IOC_GOINGDOWN
- */
-#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
-#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
-#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
-#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
-#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
-#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
-
-/*
- * Flags used by F2FS_IOC_SEC_TRIM_FILE
- */
-#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
-#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
-#define F2FS_TRIM_FILE_MASK 0x3
-
-struct f2fs_gc_range {
- u32 sync;
- u64 start;
- u64 len;
-};
-
-struct f2fs_defragment {
- u64 start;
- u64 len;
-};
-
-struct f2fs_move_range {
- u32 dst_fd; /* destination fd */
- u64 pos_in; /* start position in src_fd */
- u64 pos_out; /* start position in dst_fd */
- u64 len; /* size to move */
-};
-
-struct f2fs_flush_device {
- u32 dev_num; /* device number to flush */
- u32 segments; /* # of segments to flush */
-};
-
-struct f2fs_sectrim_range {
- u64 start;
- u64 len;
- u64 flags;
-};
-
/* for inline stuff */
#define DEF_INLINE_RESERVED_SIZE 1
static inline int get_extra_isize(struct inode *inode);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ee861c6d9ff0..d898f1e2764b 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -31,6 +31,7 @@
#include "gc.h"
#include "trace.h"
#include <trace/events/f2fs.h>
+#include <uapi/linux/f2fs.h>
static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf)
{
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index f8f1e85ff130..56b113e3cd6a 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -6,6 +6,7 @@
#define _TRACE_F2FS_H
#include <linux/tracepoint.h>
+#include <uapi/linux/f2fs.h>
#define show_dev(dev) MAJOR(dev), MINOR(dev)
#define show_dev_ino(entry) show_dev(entry->dev), (unsigned long)entry->ino
diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h
new file mode 100644
index 000000000000..ad25786feaa1
--- /dev/null
+++ b/include/uapi/linux/f2fs.h
@@ -0,0 +1,86 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_F2FS_H
+#define _UAPI_LINUX_F2FS_H
+
+#include <linux/ioctl.h>
+
+/*
+ * f2fs-specific ioctl commands
+ */
+#define F2FS_IOCTL_MAGIC 0xf5
+#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
+#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
+#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
+#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
+#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
+#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
+#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
+#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
+ struct f2fs_defragment)
+#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
+ struct f2fs_move_range)
+#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
+ struct f2fs_flush_device)
+#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
+ struct f2fs_gc_range)
+#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
+#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
+#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
+#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
+#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
+#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
+#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
+ _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
+#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
+ _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
+#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
+ struct f2fs_sectrim_range)
+
+/*
+ * should be same as XFS_IOC_GOINGDOWN.
+ * Flags for going down operation used by FS_IOC_GOINGDOWN
+ */
+#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
+#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
+#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
+#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
+#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
+#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
+
+/*
+ * Flags used by F2FS_IOC_SEC_TRIM_FILE
+ */
+#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
+#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
+#define F2FS_TRIM_FILE_MASK 0x3
+
+struct f2fs_gc_range {
+ u32 sync;
+ u64 start;
+ u64 len;
+};
+
+struct f2fs_defragment {
+ u64 start;
+ u64 len;
+};
+
+struct f2fs_move_range {
+ u32 dst_fd; /* destination fd */
+ u64 pos_in; /* start position in src_fd */
+ u64 pos_out; /* start position in dst_fd */
+ u64 len; /* size to move */
+};
+
+struct f2fs_flush_device {
+ u32 dev_num; /* device number to flush */
+ u32 segments; /* # of segments to flush */
+};
+
+struct f2fs_sectrim_range {
+ u64 start;
+ u64 len;
+ u64 flags;
+};
+
+#endif /* _UAPI_LINUX_F2FS_H */
--
2.26.2
Hi Chao,
Can we make a documentation for this in f2fs.rst?
Thanks,
On 10/30, Chao Yu wrote:
> Like other filesystem does, we introduce a new file f2fs.h in path of
> include/uapi/linux/, and move f2fs-specified ioctl interface definitions
> to that file, after then, in order to use those definitions, userspace
> developer only need to include the new header file rather than
> copy & paste definitions from fs/f2fs/f2fs.h.
>
> Signed-off-by: Chao Yu <[email protected]>
> ---
> v2: add missing "WITH Linux-syscall-note" for SPDX-License-Identifier
> MAINTAINERS | 1 +
> fs/f2fs/f2fs.h | 79 ----------------------------------
> fs/f2fs/file.c | 1 +
> include/trace/events/f2fs.h | 1 +
> include/uapi/linux/f2fs.h | 86 +++++++++++++++++++++++++++++++++++++
> 5 files changed, 89 insertions(+), 79 deletions(-)
> create mode 100644 include/uapi/linux/f2fs.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index d1d4e49a695a..b79a911f1e32 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6686,6 +6686,7 @@ F: Documentation/filesystems/f2fs.rst
> F: fs/f2fs/
> F: include/linux/f2fs_fs.h
> F: include/trace/events/f2fs.h
> +F: include/uapi/linux/f2fs.h
>
> F71805F HARDWARE MONITORING DRIVER
> M: Jean Delvare <[email protected]>
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index cb700d797296..99bcf4b44a9c 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -402,85 +402,6 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
> return size <= MAX_SIT_JENTRIES(journal);
> }
>
> -/*
> - * f2fs-specific ioctl commands
> - */
> -#define F2FS_IOCTL_MAGIC 0xf5
> -#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
> -#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
> -#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
> -#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
> -#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
> -#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
> -#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
> -#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
> - struct f2fs_defragment)
> -#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
> - struct f2fs_move_range)
> -#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
> - struct f2fs_flush_device)
> -#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> - struct f2fs_gc_range)
> -#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
> -#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
> -#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
> -#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
> -#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
> -#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
> -#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
> - _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
> -#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
> - _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
> -#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
> - struct f2fs_sectrim_range)
> -
> -/*
> - * should be same as XFS_IOC_GOINGDOWN.
> - * Flags for going down operation used by FS_IOC_GOINGDOWN
> - */
> -#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
> -#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
> -#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
> -#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
> -#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
> -#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
> -
> -/*
> - * Flags used by F2FS_IOC_SEC_TRIM_FILE
> - */
> -#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
> -#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
> -#define F2FS_TRIM_FILE_MASK 0x3
> -
> -struct f2fs_gc_range {
> - u32 sync;
> - u64 start;
> - u64 len;
> -};
> -
> -struct f2fs_defragment {
> - u64 start;
> - u64 len;
> -};
> -
> -struct f2fs_move_range {
> - u32 dst_fd; /* destination fd */
> - u64 pos_in; /* start position in src_fd */
> - u64 pos_out; /* start position in dst_fd */
> - u64 len; /* size to move */
> -};
> -
> -struct f2fs_flush_device {
> - u32 dev_num; /* device number to flush */
> - u32 segments; /* # of segments to flush */
> -};
> -
> -struct f2fs_sectrim_range {
> - u64 start;
> - u64 len;
> - u64 flags;
> -};
> -
> /* for inline stuff */
> #define DEF_INLINE_RESERVED_SIZE 1
> static inline int get_extra_isize(struct inode *inode);
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ee861c6d9ff0..d898f1e2764b 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -31,6 +31,7 @@
> #include "gc.h"
> #include "trace.h"
> #include <trace/events/f2fs.h>
> +#include <uapi/linux/f2fs.h>
>
> static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf)
> {
> diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
> index f8f1e85ff130..56b113e3cd6a 100644
> --- a/include/trace/events/f2fs.h
> +++ b/include/trace/events/f2fs.h
> @@ -6,6 +6,7 @@
> #define _TRACE_F2FS_H
>
> #include <linux/tracepoint.h>
> +#include <uapi/linux/f2fs.h>
>
> #define show_dev(dev) MAJOR(dev), MINOR(dev)
> #define show_dev_ino(entry) show_dev(entry->dev), (unsigned long)entry->ino
> diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h
> new file mode 100644
> index 000000000000..ad25786feaa1
> --- /dev/null
> +++ b/include/uapi/linux/f2fs.h
> @@ -0,0 +1,86 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +#ifndef _UAPI_LINUX_F2FS_H
> +#define _UAPI_LINUX_F2FS_H
> +
> +#include <linux/ioctl.h>
> +
> +/*
> + * f2fs-specific ioctl commands
> + */
> +#define F2FS_IOCTL_MAGIC 0xf5
> +#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
> +#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
> +#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
> +#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
> +#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
> +#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
> +#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
> +#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
> + struct f2fs_defragment)
> +#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
> + struct f2fs_move_range)
> +#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
> + struct f2fs_flush_device)
> +#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
> + struct f2fs_gc_range)
> +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
> +#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
> +#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
> +#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
> +#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
> +#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
> +#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
> + _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
> +#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
> + _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
> +#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
> + struct f2fs_sectrim_range)
> +
> +/*
> + * should be same as XFS_IOC_GOINGDOWN.
> + * Flags for going down operation used by FS_IOC_GOINGDOWN
> + */
> +#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
> +#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
> +#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
> +#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
> +#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
> +#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
> +
> +/*
> + * Flags used by F2FS_IOC_SEC_TRIM_FILE
> + */
> +#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
> +#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
> +#define F2FS_TRIM_FILE_MASK 0x3
> +
> +struct f2fs_gc_range {
> + u32 sync;
> + u64 start;
> + u64 len;
> +};
> +
> +struct f2fs_defragment {
> + u64 start;
> + u64 len;
> +};
> +
> +struct f2fs_move_range {
> + u32 dst_fd; /* destination fd */
> + u64 pos_in; /* start position in src_fd */
> + u64 pos_out; /* start position in dst_fd */
> + u64 len; /* size to move */
> +};
> +
> +struct f2fs_flush_device {
> + u32 dev_num; /* device number to flush */
> + u32 segments; /* # of segments to flush */
> +};
> +
> +struct f2fs_sectrim_range {
> + u64 start;
> + u64 len;
> + u64 flags;
> +};
> +
> +#endif /* _UAPI_LINUX_F2FS_H */
> --
> 2.26.2
On 2020-10-30 20:30, Jaegeuk Kim wrote:
> Hi Chao,
>
> Can we make a documentation for this in f2fs.rst?
Jaegeuk,
Sure, let me work on this.
Thanks,
>
> Thanks,
>
> On 10/30, Chao Yu wrote:
>> Like other filesystem does, we introduce a new file f2fs.h in path of
>> include/uapi/linux/, and move f2fs-specified ioctl interface definitions
>> to that file, after then, in order to use those definitions, userspace
>> developer only need to include the new header file rather than
>> copy & paste definitions from fs/f2fs/f2fs.h.
>>
>> Signed-off-by: Chao Yu <[email protected]>
>> ---
>> v2: add missing "WITH Linux-syscall-note" for SPDX-License-Identifier
>> MAINTAINERS | 1 +
>> fs/f2fs/f2fs.h | 79 ----------------------------------
>> fs/f2fs/file.c | 1 +
>> include/trace/events/f2fs.h | 1 +
>> include/uapi/linux/f2fs.h | 86 +++++++++++++++++++++++++++++++++++++
>> 5 files changed, 89 insertions(+), 79 deletions(-)
>> create mode 100644 include/uapi/linux/f2fs.h
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index d1d4e49a695a..b79a911f1e32 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -6686,6 +6686,7 @@ F: Documentation/filesystems/f2fs.rst
>> F: fs/f2fs/
>> F: include/linux/f2fs_fs.h
>> F: include/trace/events/f2fs.h
>> +F: include/uapi/linux/f2fs.h
>>
>> F71805F HARDWARE MONITORING DRIVER
>> M: Jean Delvare <[email protected]>
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index cb700d797296..99bcf4b44a9c 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -402,85 +402,6 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,
>> return size <= MAX_SIT_JENTRIES(journal);
>> }
>>
>> -/*
>> - * f2fs-specific ioctl commands
>> - */
>> -#define F2FS_IOCTL_MAGIC 0xf5
>> -#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
>> -#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
>> -#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
>> -#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
>> -#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
>> -#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
>> -#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
>> -#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
>> - struct f2fs_defragment)
>> -#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
>> - struct f2fs_move_range)
>> -#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
>> - struct f2fs_flush_device)
>> -#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
>> - struct f2fs_gc_range)
>> -#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
>> -#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
>> -#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
>> -#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
>> -#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
>> -#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
>> -#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
>> - _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
>> -#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
>> - _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
>> -#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
>> - struct f2fs_sectrim_range)
>> -
>> -/*
>> - * should be same as XFS_IOC_GOINGDOWN.
>> - * Flags for going down operation used by FS_IOC_GOINGDOWN
>> - */
>> -#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
>> -#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
>> -#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
>> -#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
>> -#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
>> -#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
>> -
>> -/*
>> - * Flags used by F2FS_IOC_SEC_TRIM_FILE
>> - */
>> -#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
>> -#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
>> -#define F2FS_TRIM_FILE_MASK 0x3
>> -
>> -struct f2fs_gc_range {
>> - u32 sync;
>> - u64 start;
>> - u64 len;
>> -};
>> -
>> -struct f2fs_defragment {
>> - u64 start;
>> - u64 len;
>> -};
>> -
>> -struct f2fs_move_range {
>> - u32 dst_fd; /* destination fd */
>> - u64 pos_in; /* start position in src_fd */
>> - u64 pos_out; /* start position in dst_fd */
>> - u64 len; /* size to move */
>> -};
>> -
>> -struct f2fs_flush_device {
>> - u32 dev_num; /* device number to flush */
>> - u32 segments; /* # of segments to flush */
>> -};
>> -
>> -struct f2fs_sectrim_range {
>> - u64 start;
>> - u64 len;
>> - u64 flags;
>> -};
>> -
>> /* for inline stuff */
>> #define DEF_INLINE_RESERVED_SIZE 1
>> static inline int get_extra_isize(struct inode *inode);
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index ee861c6d9ff0..d898f1e2764b 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -31,6 +31,7 @@
>> #include "gc.h"
>> #include "trace.h"
>> #include <trace/events/f2fs.h>
>> +#include <uapi/linux/f2fs.h>
>>
>> static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf)
>> {
>> diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
>> index f8f1e85ff130..56b113e3cd6a 100644
>> --- a/include/trace/events/f2fs.h
>> +++ b/include/trace/events/f2fs.h
>> @@ -6,6 +6,7 @@
>> #define _TRACE_F2FS_H
>>
>> #include <linux/tracepoint.h>
>> +#include <uapi/linux/f2fs.h>
>>
>> #define show_dev(dev) MAJOR(dev), MINOR(dev)
>> #define show_dev_ino(entry) show_dev(entry->dev), (unsigned long)entry->ino
>> diff --git a/include/uapi/linux/f2fs.h b/include/uapi/linux/f2fs.h
>> new file mode 100644
>> index 000000000000..ad25786feaa1
>> --- /dev/null
>> +++ b/include/uapi/linux/f2fs.h
>> @@ -0,0 +1,86 @@
>> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
>> +#ifndef _UAPI_LINUX_F2FS_H
>> +#define _UAPI_LINUX_F2FS_H
>> +
>> +#include <linux/ioctl.h>
>> +
>> +/*
>> + * f2fs-specific ioctl commands
>> + */
>> +#define F2FS_IOCTL_MAGIC 0xf5
>> +#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
>> +#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
>> +#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
>> +#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
>> +#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
>> +#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
>> +#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
>> +#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
>> + struct f2fs_defragment)
>> +#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
>> + struct f2fs_move_range)
>> +#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
>> + struct f2fs_flush_device)
>> +#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
>> + struct f2fs_gc_range)
>> +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
>> +#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
>> +#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
>> +#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
>> +#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
>> +#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
>> +#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
>> + _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
>> +#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
>> + _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
>> +#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
>> + struct f2fs_sectrim_range)
>> +
>> +/*
>> + * should be same as XFS_IOC_GOINGDOWN.
>> + * Flags for going down operation used by FS_IOC_GOINGDOWN
>> + */
>> +#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
>> +#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
>> +#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
>> +#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
>> +#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
>> +#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
>> +
>> +/*
>> + * Flags used by F2FS_IOC_SEC_TRIM_FILE
>> + */
>> +#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
>> +#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
>> +#define F2FS_TRIM_FILE_MASK 0x3
>> +
>> +struct f2fs_gc_range {
>> + u32 sync;
>> + u64 start;
>> + u64 len;
>> +};
>> +
>> +struct f2fs_defragment {
>> + u64 start;
>> + u64 len;
>> +};
>> +
>> +struct f2fs_move_range {
>> + u32 dst_fd; /* destination fd */
>> + u64 pos_in; /* start position in src_fd */
>> + u64 pos_out; /* start position in dst_fd */
>> + u64 len; /* size to move */
>> +};
>> +
>> +struct f2fs_flush_device {
>> + u32 dev_num; /* device number to flush */
>> + u32 segments; /* # of segments to flush */
>> +};
>> +
>> +struct f2fs_sectrim_range {
>> + u64 start;
>> + u64 len;
>> + u64 flags;
>> +};
>> +
>> +#endif /* _UAPI_LINUX_F2FS_H */
>> --
>> 2.26.2
On Fri, Oct 30, 2020 at 03:26:10PM +0800, Chao Yu wrote:
> +
> +struct f2fs_gc_range {
> + u32 sync;
> + u64 start;
> + u64 len;
> +};
Userspace headers need to use __u32, __u64, etc. instead of u32, u64, etc.
Did you try installing this header, and including it in a userspace program?
- Eric
Hi Chao,
I love your patch! Yet something to improve:
[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on linus/master v5.10-rc1 next-20201030]
[cannot apply to linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-move-ioctl-interface-definitions-to-separated-file/20201030-152809
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-randconfig-a013-20201030 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project fa5a13276764a2657b3571fa3c57b07ee5d2d661)
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
# https://github.com/0day-ci/linux/commit/652525531fd95cc9ef1011882abec714d0d853dc
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Chao-Yu/f2fs-move-ioctl-interface-definitions-to-separated-file/20201030-152809
git checkout 652525531fd95cc9ef1011882abec714d0d853dc
# 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 <[email protected]>
All errors (new ones prefixed by >>):
In file included from <built-in>:1:
>> ./usr/include/linux/f2fs.h:58:2: error: unknown type name 'u32'
u32 sync;
^
>> ./usr/include/linux/f2fs.h:59:2: error: unknown type name 'u64'
u64 start;
^
./usr/include/linux/f2fs.h:60:2: error: unknown type name 'u64'
u64 len;
^
./usr/include/linux/f2fs.h:64:2: error: unknown type name 'u64'
u64 start;
^
./usr/include/linux/f2fs.h:65:2: error: unknown type name 'u64'
u64 len;
^
./usr/include/linux/f2fs.h:69:2: error: unknown type name 'u32'
u32 dst_fd; /* destination fd */
^
./usr/include/linux/f2fs.h:70:2: error: unknown type name 'u64'
u64 pos_in; /* start position in src_fd */
^
./usr/include/linux/f2fs.h:71:2: error: unknown type name 'u64'
u64 pos_out; /* start position in dst_fd */
^
./usr/include/linux/f2fs.h:72:2: error: unknown type name 'u64'
u64 len; /* size to move */
^
./usr/include/linux/f2fs.h:76:2: error: unknown type name 'u32'
u32 dev_num; /* device number to flush */
^
./usr/include/linux/f2fs.h:77:2: error: unknown type name 'u32'
u32 segments; /* # of segments to flush */
^
./usr/include/linux/f2fs.h:81:2: error: unknown type name 'u64'
u64 start;
^
./usr/include/linux/f2fs.h:82:2: error: unknown type name 'u64'
u64 len;
^
./usr/include/linux/f2fs.h:83:2: error: unknown type name 'u64'
u64 flags;
^
14 errors generated.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
On 2020/10/31 0:55, Eric Biggers wrote:
> On Fri, Oct 30, 2020 at 03:26:10PM +0800, Chao Yu wrote:
>> +
>> +struct f2fs_gc_range {
>> + u32 sync;
>> + u64 start;
>> + u64 len;
>> +};
>
> Userspace headers need to use __u32, __u64, etc. instead of u32, u64, etc.
Correct.
>
> Did you try installing this header, and including it in a userspace program?
Let me do more test before next version.
Thanks,
>
> - Eric
> .
>