f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl
PATCH v7 1/1 f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl
From: Daeho Jeong <[email protected]>
Added a new ioctl to send discard commands or/and zero out to selected data area of a regular file for security reason.
The way of handling range.len of F2FS_IOC_SEC_TRIM_FILE:
1. Added -1 value support for range.len to secure trim the whole blocks starting from range.start regardless of i_size.
2. If the end of the range passes over the end of file, it means until the end of file (i_size).
3. ignored the case of that range.len is zero to prevent the function from making end_addr zero and triggering different behaviour of the function.
---
Changes in v7:
- Polish coding style
---
Changes in v6:
- Support zeroout for encrypted files
--- fs/f2fs/f2fs.h | 15 ++++ fs/f2fs/file.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 206 insertions(+)
fs/f2fs/f2fs.h +15 -0
@@ -430,6 +430,8 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal, _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.
@@ -442,6 +444,13 @@ static inline bool __has_cursum_space(struct f2fs_journal *journal,#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;
@@ -465,6 +474,12 @@ struct f2fs_flush_device {u32 segments;/* # of segments to flush */ }; +struct f2fs_sectrim_range { +u64 start; +u64 len; +u64 flags; +}; +/* for inline stuff */ #define DEF_INLINE_RESERVED_SIZE 1static inline int get_extra_isize (struct inode *inode);
fs/f2fs/file.c +191 -0
215 lines not on this page · raw message
Signature · 1 line
2.28.0.rc0.105.gf9edc3c819-goog