aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChao Yu2020-11-02 00:21:31 -0600
committerJaegeuk Kim2020-12-21 15:33:11 -0600
commita6d99e8e3169d02c7c4999f8cca70776ca0b3913 (patch)
tree38a61478ae03d96a42a6d5c7e61d24a8dcbaac9a
parentcb94abe12ad29c0296855b665fa46ce3d042646c (diff)
downloadkernel-a6d99e8e3169d02c7c4999f8cca70776ca0b3913.tar.gz
kernel-a6d99e8e3169d02c7c4999f8cca70776ca0b3913.tar.xz
kernel-a6d99e8e3169d02c7c4999f8cca70776ca0b3913.zip
f2fs: move ioctl interface definitions to separated file
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 <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--MAINTAINERS1
-rw-r--r--fs/f2fs/f2fs.h79
-rw-r--r--fs/f2fs/file.c1
-rw-r--r--include/trace/events/f2fs.h1
-rw-r--r--include/uapi/linux/f2fs.h87
5 files changed, 90 insertions, 79 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 281de213ef47..fb1ac04ccf6d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6694,6 +6694,7 @@ F: Documentation/filesystems/f2fs.rst
6694F: fs/f2fs/ 6694F: fs/f2fs/
6695F: include/linux/f2fs_fs.h 6695F: include/linux/f2fs_fs.h
6696F: include/trace/events/f2fs.h 6696F: include/trace/events/f2fs.h
6697F: include/uapi/linux/f2fs.h
6697 6698
6698F71805F HARDWARE MONITORING DRIVER 6699F71805F HARDWARE MONITORING DRIVER
6699M: Jean Delvare <jdelvare@suse.com> 6700M: Jean Delvare <jdelvare@suse.com>
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,
402 return size <= MAX_SIT_JENTRIES(journal); 402 return size <= MAX_SIT_JENTRIES(journal);
403} 403}
404 404
405/*
406 * f2fs-specific ioctl commands
407 */
408#define F2FS_IOCTL_MAGIC 0xf5
409#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
410#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
411#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
412#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
413#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
414#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
415#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
416#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
417 struct f2fs_defragment)
418#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
419 struct f2fs_move_range)
420#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
421 struct f2fs_flush_device)
422#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
423 struct f2fs_gc_range)
424#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
425#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
426#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
427#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
428#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
429#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
430#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
431 _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
432#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
433 _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
434#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
435 struct f2fs_sectrim_range)
436
437/*
438 * should be same as XFS_IOC_GOINGDOWN.
439 * Flags for going down operation used by FS_IOC_GOINGDOWN
440 */
441#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
442#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
443#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
444#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
445#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
446#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
447
448/*
449 * Flags used by F2FS_IOC_SEC_TRIM_FILE
450 */
451#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
452#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
453#define F2FS_TRIM_FILE_MASK 0x3
454
455struct f2fs_gc_range {
456 u32 sync;
457 u64 start;
458 u64 len;
459};
460
461struct f2fs_defragment {
462 u64 start;
463 u64 len;
464};
465
466struct f2fs_move_range {
467 u32 dst_fd; /* destination fd */
468 u64 pos_in; /* start position in src_fd */
469 u64 pos_out; /* start position in dst_fd */
470 u64 len; /* size to move */
471};
472
473struct f2fs_flush_device {
474 u32 dev_num; /* device number to flush */
475 u32 segments; /* # of segments to flush */
476};
477
478struct f2fs_sectrim_range {
479 u64 start;
480 u64 len;
481 u64 flags;
482};
483
484/* for inline stuff */ 405/* for inline stuff */
485#define DEF_INLINE_RESERVED_SIZE 1 406#define DEF_INLINE_RESERVED_SIZE 1
486static inline int get_extra_isize(struct inode *inode); 407static inline int get_extra_isize(struct inode *inode);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index fe39e591e5b4..89c451f09344 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -31,6 +31,7 @@
31#include "gc.h" 31#include "gc.h"
32#include "trace.h" 32#include "trace.h"
33#include <trace/events/f2fs.h> 33#include <trace/events/f2fs.h>
34#include <uapi/linux/f2fs.h>
34 35
35static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf) 36static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf)
36{ 37{
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 @@
6#define _TRACE_F2FS_H 6#define _TRACE_F2FS_H
7 7
8#include <linux/tracepoint.h> 8#include <linux/tracepoint.h>
9#include <uapi/linux/f2fs.h>
9 10
10#define show_dev(dev) MAJOR(dev), MINOR(dev) 11#define show_dev(dev) MAJOR(dev), MINOR(dev)
11#define show_dev_ino(entry) show_dev(entry->dev), (unsigned long)entry->ino 12#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..28bcfe8d2c27
--- /dev/null
+++ b/include/uapi/linux/f2fs.h
@@ -0,0 +1,87 @@
1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2
3#ifndef _UAPI_LINUX_F2FS_H
4#define _UAPI_LINUX_F2FS_H
5#include <linux/types.h>
6#include <linux/ioctl.h>
7
8/*
9 * f2fs-specific ioctl commands
10 */
11#define F2FS_IOCTL_MAGIC 0xf5
12#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1)
13#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
14#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
15#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
16#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
17#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
18#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
19#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
20 struct f2fs_defragment)
21#define F2FS_IOC_MOVE_RANGE _IOWR(F2FS_IOCTL_MAGIC, 9, \
22 struct f2fs_move_range)
23#define F2FS_IOC_FLUSH_DEVICE _IOW(F2FS_IOCTL_MAGIC, 10, \
24 struct f2fs_flush_device)
25#define F2FS_IOC_GARBAGE_COLLECT_RANGE _IOW(F2FS_IOCTL_MAGIC, 11, \
26 struct f2fs_gc_range)
27#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, __u32)
28#define F2FS_IOC_SET_PIN_FILE _IOW(F2FS_IOCTL_MAGIC, 13, __u32)
29#define F2FS_IOC_GET_PIN_FILE _IOR(F2FS_IOCTL_MAGIC, 14, __u32)
30#define F2FS_IOC_PRECACHE_EXTENTS _IO(F2FS_IOCTL_MAGIC, 15)
31#define F2FS_IOC_RESIZE_FS _IOW(F2FS_IOCTL_MAGIC, 16, __u64)
32#define F2FS_IOC_GET_COMPRESS_BLOCKS _IOR(F2FS_IOCTL_MAGIC, 17, __u64)
33#define F2FS_IOC_RELEASE_COMPRESS_BLOCKS \
34 _IOR(F2FS_IOCTL_MAGIC, 18, __u64)
35#define F2FS_IOC_RESERVE_COMPRESS_BLOCKS \
36 _IOR(F2FS_IOCTL_MAGIC, 19, __u64)
37#define F2FS_IOC_SEC_TRIM_FILE _IOW(F2FS_IOCTL_MAGIC, 20, \
38 struct f2fs_sectrim_range)
39
40/*
41 * should be same as XFS_IOC_GOINGDOWN.
42 * Flags for going down operation used by FS_IOC_GOINGDOWN
43 */
44#define F2FS_IOC_SHUTDOWN _IOR('X', 125, __u32) /* Shutdown */
45#define F2FS_GOING_DOWN_FULLSYNC 0x0 /* going down with full sync */
46#define F2FS_GOING_DOWN_METASYNC 0x1 /* going down with metadata */
47#define F2FS_GOING_DOWN_NOSYNC 0x2 /* going down */
48#define F2FS_GOING_DOWN_METAFLUSH 0x3 /* going down with meta flush */
49#define F2FS_GOING_DOWN_NEED_FSCK 0x4 /* going down to trigger fsck */
50
51/*
52 * Flags used by F2FS_IOC_SEC_TRIM_FILE
53 */
54#define F2FS_TRIM_FILE_DISCARD 0x1 /* send discard command */
55#define F2FS_TRIM_FILE_ZEROOUT 0x2 /* zero out */
56#define F2FS_TRIM_FILE_MASK 0x3
57
58struct f2fs_gc_range {
59 __u32 sync;
60 __u64 start;
61 __u64 len;
62};
63
64struct f2fs_defragment {
65 __u64 start;
66 __u64 len;
67};
68
69struct f2fs_move_range {
70 __u32 dst_fd; /* destination fd */
71 __u64 pos_in; /* start position in src_fd */
72 __u64 pos_out; /* start position in dst_fd */
73 __u64 len; /* size to move */
74};
75
76struct f2fs_flush_device {
77 __u32 dev_num; /* device number to flush */
78 __u32 segments; /* # of segments to flush */
79};
80
81struct f2fs_sectrim_range {
82 __u64 start;
83 __u64 len;
84 __u64 flags;
85};
86
87#endif /* _UAPI_LINUX_F2FS_H */